Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. public void synt(String s) {
  2.  
  3. String REQUEST = "https://tts.voicetech.yandex.net/generate?"
  4.  
  5. + "text="+s
  6. + "&format="+"opus"
  7. + "&lang="+"ru-RU"
  8. + "&speaker="+"oksana"
  9. + "&emotion="+"good"
  10. + "&key="+Core.API_KEY;
  11.  
  12. try{
  13.  
  14. URL url = new URL(REQUEST);
  15.  
  16. HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
  17. connection.setRequestMethod("GET");
  18. connection.setDoInput(true);
  19. connection.connect();
  20.  
  21.  
  22. InputStream in = connection.getInputStream();
  23.  
  24. OutputStream writer = new FileOutputStream("lastSyntesis.opus");
  25.  
  26. byte buffer[] = new byte[1024];
  27. int c = in.read(buffer);
  28.  
  29. while (c > 0) {
  30. writer.write(buffer, 0, c);
  31. c = in.read(buffer);
  32. }
  33.  
  34. writer.flush();
  35. writer.close();
  36.  
  37. in.close();
  38.  
  39. } catch (IOException e) {
  40. System.out.println(e);
  41. }
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement