不接收第一个音频块以外的结果

Dont receive results other than those from first audio chunk

我想要某种程度的实时语音到文本的转换。我正在使用 interim_results=true 的网络套接字接口。但是,我只收到第一个音频块的结果。第二个、第三个……我发送的音频块没有被转录。我确实知道我的接收器没有被阻止,因为我确实收到了不活动消息。

json {"error": "Session timed out due to inactivity after 30 seconds."}

如果我需要提供更多上下文信息,请告诉我是否遗漏了什么。

仅供参考,这是我的初始化 json。

{
 "action": "start",
 "content-type":"audio/wav",
 "interim_results": true,
 "continuous": true,
 "inactivity_timeout": 10
}

在我为第一个音频块获得的结果中,最终的 json 字段始终接收为 false

此外,我正在使用 golang 但这并不重要。

编辑:

考虑以下伪日志

Link to code

您收到超时消息是因为该服务在等待您发送更多音频或发送表示音频提交结束的消息。你在发那条信息吗?这很容易:

  • 通过发送 JSON 文本消息并将操作键设置为值停止:{"action": "stop"}

  • 通过发送一个空的二进制消息

https://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/doc/speech-to-text/websockets.shtml

如果这不能解决您的问题,请告诉我

这有点晚了,但我在这里为 Watson 服务开源了一个 Go SDK: https://github.com/liviosoares/go-watson-sdk

这里有一些关于语音到文本绑定的文档: https://godoc.org/github.com/liviosoares/go-watson-sdk/watson/speech_to_text

还有一个流数据到_test.go文件中的API的例子: https://github.com/liviosoares/go-watson-sdk/blob/master/watson/speech_to_text/speech_to_text_test.go

也许这可以帮到你。

这道题的解决办法是将wav文件的size header设置为0。