问题描述
限时送ChatGPT账号..我正在使用来自 https 的 Microsoft 认知服务语音 SDK 的 JavaScript 版本://github/Azure-Samples/cognitive-services-speech-sdk.
关于 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 事件不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论