javascript - Microsoft azure“文本到语音”javascript,onend 事件
问题描述
再会。
我正在制作一个网站,集成了 microsoft text-to-speech API。当音频播放完毕时,我需要激活一个功能。
我一直在做很多研究,但我没有找到任何真正有效的方法。
一些有效的“onend”事件。
你知道我怎么能做到这一点吗?谢谢
startSpeakTextAsyncButton.addEventListener("click", function () {
startSpeakTextAsyncButton.disabled = true;
resultDiv.innerHTML = "";
synthesizer = new SpeechSDK.SpeechSynthesizer(speechConfig);
synthesizer.speakTextAsync(
phraseDiv.value,
function (result) {
startSpeakTextAsyncButton.disabled = false;
resultDiv.innerHTML = "synthesis in process";
if (result.reason === SpeechSDK.ResultReason.SynthesizingAudioCompleted) {
resultDiv.innerHTML = "synthesis finished";
} else if (result.reason === SpeechSDK.ResultReason.Canceled) {
resultDiv.innerHTML = "synthesis failed. Error detail: " + result.errorDetails + "\n";
}
synthesizer.close();
synthesizer = undefined;
},
function (err) {
startSpeakTextAsyncButton.disabled = false;
resultDiv.innerHTML = "Error: ";
resultDiv.innerHTML = err;
resultDiv.innerHTML = "\n";
window.console.log(err);
synthesizer.close();
synthesizer = undefined;
});
});
解决方案
推荐阅读
- amazon-web-services - AWS ECS 集群中的自动磁盘清理
- bootstrap-4 - 弹出框内的 DataTable 范围滑块
- java - 找不到 Javafx/应用程序 Gradle JavaFX
- python - 如何在 PyQt5 中显示表情符号?
- ssl - Fluentd TLS 加密
- rust - 对从函数返回的临时对象的引用
- python - 我对这个哨兵值的实现有什么问题?
- swift - 初始化 CGSize 的一个奇怪问题或错误
- angular - 带有蓝牙设备检测器的 Angular 应用程序
- javascript - 为什么这些按钮在 iPhone 上是矩形的,而在我的桌面浏览器上却是方形的?