首页 > 解决方案 > 无法为 Bot Framework 网络聊天合成语音

问题描述

我正在为 BOT 演讲。我一直在浏览此处找到的 Microsoft 教程。我已经从那里找到了示例 Echo BOT 示例,在此处找到,作为基础,因此我可以将其用作前进的基础。这已成功部署到我的 Azure 环境。同样在本教程中,您通过 Direct Line Speech Client v1 运行您的 Bot,执行此操作时一切正常。

我查看了Bot Framework 网络聊天语音笔记,让 Bot 使用它作为我的频道工作。这是我的代码:

<!DOCTYPE html>
<html lang="en-US">
  <head>
    <title>Web Chat: Browser-supported speech</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.botframework.com/botframework-webchat/latest/webchat.js"></script>
    <style>
      html, body { height: 100% }
      body { margin: 0 }
      #webchat {
        height: 100%;
        width: 100%;
      }
    </style>
  </head>
  <body>
    <div id="webchat" role="main"></div>
    <script>
         (async function () {

            window.WebChat.renderWebChat({
            directLine: createDirectLine({
                secret: '<My Direct Line secret>'
              }),
              language: 'en-US',
              webSpeechPonyfillFactory: await createCognitiveServicesSpeechServicesPonyfillFactory({
                region: '<Speech cognitive service region>',
                subscriptionKey: '<Speech cognitive service key>'
              })
            }, document.getElementById('webchat'));
            document.querySelector('#webchat > *').focus();
          })().catch(err => console.error(err));
      </script>
  </body>
</html>

我能够让这个工作,我可以对文本和文本输入进行语音,并且内容被写回,但是当它尝试将文本返回到语音时,我在浏览器控制台中收到以下错误:

POST https://<region>.tts.speech.microsoft.com/cognitiveservices/v1 net::ERR_ABORTED 400 (Speak node can only be the root.)
webchat.js:1 Error: Failed to syntheis speech, server returned 400
    at webchat.js:1
    at c (webchat.js:1)
    at Generator._invoke (webchat.js:1)
    at Generator.e.<computed> [as next] (webchat.js:1)
    at n (webchat.js:1)
    at s (webchat.js:1)

我不太确定它是在脚本代码中还是在 Bot 中,如果您需要更多详细信息,请告诉我。提前致谢!

标签: botframeworkmicrosoft-cognitivespeechdirect-line-botframeworkweb-chat

解决方案


这很奇怪......我在 Azure 上托管了一个 echo bot,只是复制并粘贴了你的 html 代码并做了一些配置,我在 edge firefox 和 chrome 上进行了测试,但一切正常,包括 tts 调用: 在此处输入图像描述

您可以在这里尝试并检查配置。希望能帮助到你 。


推荐阅读