TTS:如何在保持连接打开的情况下检测语音何时结束?
我有一个移动网络应用程序,其中有多个语音提示,每个提示后用户都会说出响应。用户可以按下按钮来启动该过程,但随后必须能够免提回答提示。
为了使音频在 Safari 和 Chrome 移动设备上不被阻止,合成器必须通过用户交互(例如按下按钮)启动。这最初有效。如果我可以保持合成器对象打开,我可以通过按下一个按钮继续使用它,而不需要用户按下另一个按钮。
但是,我还需要检测语音何时完成:
const player = new SpeechSDK.SpeakerAudioDestination();
player.onAudioEnd = () => {
resolve();
};
看起来 onAudioEnd
仅在说话后关闭合成器时触发:
synthesizer.speakSsmlAsync(`...`,
(result) => {
if (result) {
synthesizer.close(); // <---- Without this onAudioEnd never fires
return result.audioData;
}
return undefined;
});
但是当我关闭合成器时,移动浏览器需要在之前按下另一个按钮我可以打开一个新的合成器。
有什么办法可以解决这个问题吗?
I have a mobile web app where there are multiple spoken prompts, each one followed by the user speaking a response. The user can press a button to start the process but then must be able to answer the prompts hands free.
In order for the audio to not be blocked on Safari and Chrome mobile the synthesizer must be started with a user interaction like a button press. This works initially. If I could keep the synthesizer object open I could continue to use it from this one button press without needing the user to press another button.
However, I also need to detect when the spoken voice is complete:
const player = new SpeechSDK.SpeakerAudioDestination();
player.onAudioEnd = () => {
resolve();
};
It looks like onAudioEnd
only fires when the synthesizer is closed after speaking:
synthesizer.speakSsmlAsync(`...`,
(result) => {
if (result) {
synthesizer.close(); // <---- Without this onAudioEnd never fires
return result.audioData;
}
return undefined;
});
But when I close the synthesizer, then mobile browsers require another button press before I can open a new synthesizer.
Is there any way I can get around this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论