Last active
July 22, 2016 17:18
-
-
Save snippet-java/adc1f3b6acd684f4e6d7d07ae0173ed4 to your computer and use it in GitHub Desktop.
Text To Speech Snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.ibm.watson.developer_cloud.text_to_speech.v1.*; | |
import com.ibm.watson.developer_cloud.text_to_speech.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
TextToSpeech service = new TextToSpeech(); | |
service.setEndPoint("https://watson-api-explorer.mybluemix.net/text-to-speech/api"); // SET YOUR URL | |
//service.setUsernameAndPassword(username,password); // SET YOUR USERNAME AND PASSWORD | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.ibm.watson.developer_cloud.text_to_speech.v1.*; | |
import com.ibm.watson.developer_cloud.text_to_speech.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
List<Voice> getVoices() | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.ibm.watson.developer_cloud.text_to_speech.v1.*; | |
import com.ibm.watson.developer_cloud.text_to_speech.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
TextToSpeech service = new TextToSpeech(); | |
service.setEndPoint("https://watson-api-explorer.mybluemix.net/text-to-speech/api"); // SET YOUR URL | |
//service.setUsernameAndPassword(username,password); // SET YOUR USERNAME AND PASSWORD | |
List<Voice> voices = service.getVoices(); | |
System.out.println(voices); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.ibm.watson.developer_cloud.text_to_speech.v1.*; | |
import com.ibm.watson.developer_cloud.text_to_speech.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
InputStream synthesize(String text, String format) | |
InputStream synthesize(String text, Voice voice) | |
InputStream synthesize(String text, Voice voice, String outputFormat) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.ibm.watson.developer_cloud.text_to_speech.v1.*; | |
import com.ibm.watson.developer_cloud.text_to_speech.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
TextToSpeech service = new TextToSpeech(); | |
service.setEndPoint("https://watson-api-explorer.mybluemix.net/text-to-speech/api"); // SET YOUR URL | |
//service.setUsernameAndPassword(username,password); // SET YOUR USERNAME AND PASSWORD | |
try { | |
String text = "Hello world."; | |
InputStream stream = service.synthesize (text, Voice.EN_ALLISON, "audio/wav"); | |
InputStream in = WaveUtils.reWriteWaveHeader(stream); | |
OutputStream out = new FileOutputStream("hello_world.wav"); | |
byte[] buffer = new byte[1024]; | |
int length; | |
while ((length = in.read(buffer)) > 0) { | |
out.write(buffer, 0, length); | |
} | |
out.close(); | |
in.close(); | |
stream.close(); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment