1

so I'm making an application to dictate speech into a textbox using IBM Watson Speech to text java API. Essentially I want to remake the demo using a microphone in this link.

https://speech-to-text-demo.mybluemix.net/?cm_mc_uid=46038392292114635825813&cm_mc_sid_50200000=1464188794

I want to remake this in JAVA. So I have this sample code from their documentation

public class SimpleServlet {
  private static CountDownLatch lock = new CountDownLatch(1);

  public static void main(String[] args) throws FileNotFoundException, InterruptedException {
    SpeechToText service = new SpeechToText();
    service.setUsernameAndPassword("username","pass");

    //FileInputStream audio = new FileInputStream("src/test/resources/4.flac");

    AudioInputStream audio = null;


    RecognizeOptions options = new RecognizeOptions.Builder()
        .continuous(true)
        .interimResults(true)
        .contentType(HttpMediaType.AUDIO_FLAC)
        .build();

    service.recognizeUsingWebSocket(audio, options, new BaseRecognizeCallback() {
      @Override
      public void onTranscription(SpeechResults speechResults) {
        System.out.println(speechResults);
        if (speechResults.isFinal())
          lock.countDown();
      }
    });

    lock.await(1, TimeUnit.MINUTES);
  }
}

How would you open a socket to continuously add in an audiostream? If that is even the correct way to go about this.

Any help is appreciated.

user3221162
  • 127
  • 1
  • 9
  • Well, so is there no way to stream live audio onto Speech to text then? – user3221162 May 25 '16 at 17:03
  • This is a duplicate of http://stackoverflow.com/questions/37232560/stream-audio-from-mic-to-ibm-watson-speechtotext-web-service-using-java-sdk which I already answered. – German Attanasio Aug 02 '16 at 19:10
  • Possible duplicate of [Stream audio from mic to IBM Watson SpeechToText Web service using Java SDK](https://stackoverflow.com/questions/37232560/stream-audio-from-mic-to-ibm-watson-speechtotext-web-service-using-java-sdk) – German Attanasio Feb 18 '18 at 01:00
  • @GermanAttanasio It doesn't work with the latest java-sdk version of IBM `5.1.1` please fix. – GOXR3PLUS Mar 29 '18 at 11:28
  • @GOXR3PLUS try to use the examples from the repository or open an issue with some steps to reproduce it and I will get someone to look at it. I'm not at the office today :( – German Attanasio Mar 30 '18 at 21:08

0 Answers0