Microsoft Cognitive TTS onAudioEnd 事件不起作用

编程入门 行业动态 更新时间:2024-10-13 20:15:32
本文介绍了Microsoft Cognitive TTS onAudioEnd 事件不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送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:关键词]

本文发布于:2023-04-30 19:30:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1398914.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不起作用   事件   Cognitive   Microsoft   onAudioEnd

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!