GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [speech-to-text] Added Websocket example #15 · einsnull/java-sdk@211ac07

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • examples/java/com/ibm/watson/developer_cloud/speech_to_text/v1
    • RecognizeUsingWebSockets.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎examples/java/com/ibm/watson/developer_cloud/speech_to_text/v1/RecognizeUsingWebSockets.java‎

Copy file name to clipboard
+32Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.ibm.watson.developer_cloud.speech_to_text.v1;
2+
3+
import java.io.FileInputStream;
4+
import java.io.FileNotFoundException;
5+
6+
import com.ibm.watson.developer_cloud.http.HttpMediaType;
7+
import com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechResults;
8+
import com.ibm.watson.developer_cloud.speech_to_text.v1.websocket.BaseRecognizeDelegate;
9+
10+
/**
11+
* Recognize using WebSockets a sample wav file and print the transcript into the console output.
12+
*/
13+
public class RecognizeUsingWebSockets {
14+
public static void main(String[] args) throws FileNotFoundException {
15+
SpeechToText service = new SpeechToText();
16+
service.setUsernameAndPassword("<username>", "<password>");
17+
18+
FileInputStream audio = new FileInputStream("src/test/resources/speech_to_text/sample1.wav");
19+
20+
RecognizeOptions options =
21+
new RecognizeOptions().continuous(true).interimResults(true)
22+
.contentType(HttpMediaType.AUDIO_WAV);
23+
24+
service.recognizeUsingWebSockets(audio, options, new BaseRecognizeDelegate() {
25+
26+
@Override
27+
public void onMessage(SpeechResults speechResults) {
28+
System.out.println(speechResults);
29+
}
30+
});
31+
}
32+
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.