如何在Bot Framework Web聊天中使用Azure语音服务



我正在使用Bot Framework Web聊天,我正确地设置了一个前端,供用户与我的机器人聊天。我正在尝试为它启用语音功能,我尝试按照这里的教程进行操作:https://learn.microsoft.com/en-us/azure/bot-service/bot-service-channel-connect-webchat-speech?view=azure-bot-service-3.0

我遇到的问题是,我尝试使用Azure语音服务,我正确设置了服务,并设置了密钥。但我不确定在哪里可以获得认知服务?教程没有具体说明在哪里可以买到。

这是我的代码:

<div  id="bot"/>
<script src="https://cdn.botframework.com/botframework-webchat/latest/botchat.js"></script>
<script>
const speechOptionsRemote = {
speechRecognizer: new CognitiveServices.SpeechRecognizer({ subscriptionKey: '...' }),
speechSynthesizer: new CognitiveServices.SpeechSynthesizer({
gender: CognitiveServices.SynthesisGender.Female,
subscriptionKey: '...',
voiceName: 'Microsoft Server Speech Text to Speech Voice (en-US, JessaRUS)'
})
};
BotChat.App({
directLine: { secret: '...' },
user: { id: 'WebChat' },
bot: { id: '...' },
resize: 'detect',
speechOptions: speechOptionsRemote,
showUploadButton: false
}, document.getElementById("bot"));
var header = document.getElementsByClassName("wc-header");
header[0].innerHTML = "<span ><p align='center' >My Bot</p></span>"
</script>

它抱怨当我导航到页面时找不到CognitiveService。我从哪里得到它?

您的代码示例使用的是Webchat的v3,现在已经弃用,请参阅此处。GitHub存储库上有一个BotFramework WebChat的v4,几天前已经更新了。

因此,当您在代码中下载cdn.botframework.com/botframework-webchat/latest/botchat.js时,v4:解释了它找不到CognitiveServices的原因:它已经被重构了。

要在v4中使用认知服务语音,请查看专用示例:https://github.com/Microsoft/BotFramework-WebChat/tree/master/samples/speech-cognitive-services-bing-speech

最新更新