Watson IBM 语音转文本 c# api

Watson IBM Speech to Text c# api

我使用以下示例来识别音频中的文本 https://gist.github.com/nfriedly/0240e862901474a9447a600e5795d500 但我还需要时间码,我在第 40 行添加了 "timestamps" : true,并删除了 "interim_results": true 因为我只需要最终结果.但是它坏了,在 { "state": "listening" } 消息之后需要一些时间并引发异常 "Text" received message is invalid after the call Websocket.Closeasync. Websockets.In cases closeasync, so you should only use those when you do not expect to receive other data from the remote endpoint. Use "Websockets.CloseOutputAsync" to preserve the possibility of obtaining additional data, but to close the outgoing channel.

并且如果我设置 "continuous" : false,它只执行语音的第一次迭代(停顿前几个词),然后重复 {"state": "listening" } 并冻结。

你能帮我吗,如何将该示例更新为 return 时间码?

continuous: false 表示 "only transcribe until the first pause" - 所以它不是 "freezing",它只是在您告诉它时停止。

服务然后发送最终结果,然后发送第二条 {"state": "listening"} 消息以指示它已完成发送结果。示例代码在那之后关闭了连接,但听起来您在关闭连接后仍在尝试发送音频。

我不确定,但我认为 timestampsinterim_results 可能会在您设置 continuous: false 后按照您想要的方式工作。

不过,如果您只需要最终结果,那么 HTTP 接口可能更有意义。它比 WebSockets 简单得多。

最后,正如我在电子邮件中提到的,官方 IBM Watson .net SDK 即将在 development branch right now, and should have it included in a release 中支持 Speech to Text。