55##### Maven
66``` xml
77<dependency >
8- <groupId >com.ibm.watson.developer_cloud</groupId >
9- <artifactId >speech-to-text</artifactId >
10- <version >5.1.1</version >
8+ <groupId >com.ibm.watson.developer_cloud</groupId >
9+ <artifactId >speech-to-text</artifactId >
10+ <version >5.1.1</version >
1111</dependency >
1212```
1313
@@ -26,32 +26,33 @@ service.setUsernameAndPassword("<username>", "<password>");
2626File audio = new File (" src/test/resources/sample1.wav" );
2727
2828RecognizeOptions options = new RecognizeOptions .Builder ()
29- .contentType(HttpMediaType . AUDIO_WAV )
30- .build();
29+ .audio(audio)
30+ .contentType(HttpMediaType . AUDIO_WAV )
31+ .build();
3132
32- SpeechResults transcript = service. recognize(audio, options). execute();
33+ SpeechRecognitionResults transcript = service. recognize(options). execute();
3334System . out. println(transcript);
3435```
3536
3637#### WebSocket support
3738
38- Speech to Text supports WebSocket, the url is:
39- ` wss://stream.watsonplatform.net/speech-to-text/api/v1/recognize `
39+ Speech to Text supports WebSocket, the url is: ` wss://stream.watsonplatform.net/speech-to-text/api/v1/recognize `
4040
41- ``` java
41+ ``` java
4242SpeechToText service = new SpeechToText ();
4343service. setUsernameAndPassword(" <username>" , " <password>" );
4444
4545InputStream audio = new FileInputStream (" src/test/resources/sample1.wav" );
4646
4747RecognizeOptions options = new RecognizeOptions .Builder ()
48- .interimResults(true )
49- .contentType(HttpMediaType . AUDIO_WAV )
50- .build();
48+ .audio(audio)
49+ .contentType(HttpMediaType . AUDIO_WAV )
50+ .interimResults(true )
51+ .build();
5152
52- service. recognizeUsingWebSocket(audio, options, new BaseRecognizeCallback () {
53+ service. recognizeUsingWebSocket(options, new BaseRecognizeCallback () {
5354 @Override
54- public void onTranscription (SpeechResults speechResults ) {
55+ public void onTranscription (SpeechRecognitionResults speechResults ) {
5556 System . out. println(speechResults);
5657 }
5758});
@@ -86,10 +87,11 @@ RecognizeOptions options = new RecognizeOptions.Builder()
8687 .continuous(true )
8788 .interimResults(true )
8889// .inactivityTimeout(5) // use this to stop listening when the speaker pauses, i.e. for 5s
90+ .audio(audio)
8991 .contentType(HttpMediaType . AUDIO_RAW + " ; rate=" + sampleRate)
9092 .build();
9193
92- service. recognizeUsingWebSocket(audio, options, new BaseRecognizeCallback () {
94+ service. recognizeUsingWebSocket(options, new BaseRecognizeCallback () {
9395 @Override
9496 public void onTranscription (SpeechResults speechResults ) {
9597 System . out. println(speechResults);
0 commit comments