本文介绍了Microsoft Cognitive TTS onAudioEnd 事件不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
关于 SpeechSynthesizer,我在其中包含了 SpeakerAudioDestination.我想在音频播放完成后做一些事情,所以我添加了 onAudioEnd 事件,但它从未被触发.下面的代码正确吗?
About the SpeechSynthesizer, I include SpeakerAudioDestination to it. I want to do something when the audio playback is done so I add onAudioEnd event, but it is never fired.Is the code below correct?
player = new SpeechSDK.SpeakerAudioDestination();
player.onAudioEnd = function (s) {
console.log("onAudioEnd", s);
};
synthesizer = new SpeechSDK.SpeechSynthesizer(speechConfig,
SpeechSDK.AudioConfig.fromSpeakerOutput(player));
感谢任何帮助!
推荐答案
在 synthesizer.speakTextAsync() 回调中,需要调用 synthesizer.close() 来触发 player.onAudioEnd 事件.
Inside the synthesizer.speakTextAsync() callback, synthesizer.close() needs to called for player.onAudioEnd event to be fired.
这篇关于Microsoft Cognitive TTS onAudioEnd 事件不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!