Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void synt(String s) {
- String REQUEST = "https://tts.voicetech.yandex.net/generate?"
- + "text="+s
- + "&format="+"opus"
- + "&lang="+"ru-RU"
- + "&speaker="+"oksana"
- + "&emotion="+"good"
- + "&key="+Core.API_KEY;
- try{
- URL url = new URL(REQUEST);
- HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
- connection.setRequestMethod("GET");
- connection.setDoInput(true);
- connection.connect();
- InputStream in = connection.getInputStream();
- OutputStream writer = new FileOutputStream("lastSyntesis.opus");
- byte buffer[] = new byte[1024];
- int c = in.read(buffer);
- while (c > 0) {
- writer.write(buffer, 0, c);
- c = in.read(buffer);
- }
- writer.flush();
- writer.close();
- in.close();
- } catch (IOException e) {
- System.out.println(e);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement