【问题标题】:Watson STT Java - Varying results between Websockets Java and HTTP POSTWatson STT Java - Websockets Java 和 HTTP POST 之间的不同结果
【发布时间】:2016-07-30 00:41:31
【问题描述】:

我正在尝试构建一个应用程序,它采用流式音频输入(例如:麦克风中的一条线)并使用 IBM Bluemix (Watson) 进行语音到文本。

我对@9​​87654321@ 找到的示例Java 代码进行了简单的修改。此示例发送 WAV,但我发送的是 FLAC……这 [应该] 无关紧要。

结果很糟糕,非常糟糕。这是我在使用 Java Websockets 代码时得到的:

{
  "result_index": 0,
  "results": [
    {
      "final": true,
      "alternatives": [
        {
          "transcript": "it was six weeks ago today the terror ",
          "confidence": 0.92
        }
      ]
    }
  ]
}

现在,将上面的结果与下面的结果进行比较。这些是发送相同内容但使用 cURL (HTTP POST) 时的结果:

{
   "results": [
  {
     "alternatives": [
        {
           "confidence": 0.945,
           "transcript": "it was six weeks ago today the terrorists attacked the U. S. consulate in Benghazi Libya now we've obtained email alerts that were put out by the state department as the attack unfolded as you know four Americans were killed including ambassador Christopher Stevens "
        }
     ],
     "final": true
  },
  {
     "alternatives": [
        {
           "confidence": 0.942,
           "transcript": "sharyl Attkisson has our story "
        }
     ],
     "final": true
  }
   ],
   "result_index": 0
}

这是一个几乎完美的结果。

为什么在使用 Websockets 时会有所不同?

【问题讨论】:

标签: java api ibm-cloud speech-to-text ibm-watson


【解决方案1】:

该问题已在 3.0.0-RC1 版本中得到修复。

您可以从以下位置获取新 jar:

  1. Maven

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

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

    下载jar-with-dependencies(~1.4MB)


这是一个如何使用 WebSockets 识别 flac 音频文件的示例

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 文件:https://s3.amazonaws.com/mozart-company/tmp/4.flac


注意:3.0.0-RC1候选发布版。我们将在下周发布产品版本 (3.0.1)。

【讨论】:

  • 太棒了。我会检查并告诉你。
猜你喜欢
  • 2017-09-11
  • 2011-03-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-07-26
  • 1970-01-01
  • 1970-01-01
  • 2018-08-08
相关资源
最近更新 更多