我制作了一个在NAO机器人上运行的Python应用程序,它在Watson语音到文本和Watson会话服务的帮助下起到了“朋友”的作用。机器人将在提问和回答问题之间交替进行。在
当机器人处于“提问”模式时,它将倾听人类的声音并将语音流式传输给Watson STT。这个演讲是用录音带录下来的。一旦用户结束通话,录音就会停止。转录后的语音将被发送到对话中,然后机器人将相应地回答问题。通常,“回答问题”模式将持续不到30秒。但是有些回复足够长,以至于Watson STT将触发会话超时。在
“我们每10秒发送一次消息”来阻止这个会话。在
def keepAlive(self):
self.send({"action": "no-op"})
但是,Watson recently deprecated发送“no op”消息以防止会话超时。作为发送“no op”的替代方法,您可以发送静音音频数据以防止会话超时。根据文件:
"Sending audio data, including silence, to the service to avoid the 30-second >session timeout. You will be charged for any data sent to the service, >including the silence that you send to extend the session."
所以我试了一下:
^{pr2}$但是,我收到了这个错误:
Msg received: {u'error': u'could not detect endianness after looking at the tail 924 non-zero byte string in a data stream of 1024 bytes. Is the bytestream really PCM data?'}
websocket也在那之后立即关闭。向Watson STT发送静音音频数据的正确方法是什么?或者有没有其他的方法来防止会话超时?在
目前没有回答
相关问题 更多 >
编程相关推荐