Watson STT Java - Varying results between Websockets Java and HTTP POST

后端 未结 1 906
轮回少年
轮回少年 2021-01-01 04:20

I\'m trying to build an app that takes a streamed audio input (eg: a line in microphone) and does Speech-to-Text using IBM Bluemix (Watson).

I briefly modified the e

相关标签:
1条回答
  • 2021-01-01 04:59

    The issue was fixed in the 3.0.0-RC1 version.

    You can get the new jar from:

    1. Maven

      <dependency>
          <groupId>com.ibm.watson.developer_cloud</groupId>
          <artifactId>java-sdk</artifactId>
          <version>3.0.0-RC1</version>
      </dependency>
      
    2. Gradle

      'com.ibm.watson.developer_cloud:java-sdk:3.0.0-RC1'
      
    3. JAR

      Download the jar-with-dependencies(~1.4MB)


    Here is an example of how to recognize a flac audio file using WebSockets

    SpeechToText service = new SpeechToText();
    service.setUsernameAndPassword("<username>", "<password>");
    
    FileInputStream audio = new FileInputStream("path-to-audio-file.flac");
    
    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);
      }
    });
    

    }

    FLAC file to test: https://s3.amazonaws.com/mozart-company/tmp/4.flac


    NOTE: 3.0.0-RC1 is a release candidate. We will do a production release next week (3.0.1).

    0 讨论(0)
提交回复
热议问题