Microsoft Bot Framework 语音识别网络聊天集成

Microsoft Bot Framework speech recognition webchat integration

我在将语音识别集成到网络聊天时遇到问题。这是我使用的代码。就像这里的代码一样:https://github.com/microsoft/BotFramework-WebChat/blob/master/SPEECH.md#integrating-web-chat-into-your-page

但我总是收到错误:Uncaught SyntaxError: Unexpected identifier at line...

错误行是:webSpeechPonyfillFactory: await createSpeechRecognitionOnlyPonyfillFactory({

没有语音识别,一切正常。你有什么想法吗?

const { createCognitiveServicesSpeechServicesPonyfillFactory, createDirectLine, renderWebChat } = window.WebChat;

const styleOptions = {
  botAvatarInitials: 'Bot',
  userAvatarInitials: 'You'
  };


         renderWebChat(
            {
               directLine: createDirectLine({
                  secret: 'FFFFFFFFFFFFFFFF'
               }),
      
      language: 'de-DE',
      webSpeechPonyfillFactory: await createSpeechRecognitionOnlyPonyfillFactory({
      region: 'westeurope',
      subscriptionKey: 'FFFFFFFFFFFFFFFFFFFFFF'
      }),
             
       styleOptions
        
            },
            document.getElementById('webchat')
 );
         
document.querySelector('#webchat > *').focus();

试试这个:

 <!DOCTYPE html>
  <html lang="en-US">
    <head>
      <title>Web Chat: Cognitive Services Speech Services using JavaScript</title>
      <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 () {
            const styleOptions = {
                botAvatarInitials: 'Bot',
                userAvatarInitials: 'You'
                };

            window.WebChat.renderWebChat({
            directLine: createDirectLine({
                secret: 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'
              }),
              language: 'de-DE',
              webSpeechPonyfillFactory: await createCognitiveServicesSpeechServicesPonyfillFactory({
                region: 'westeurope',
                subscriptionKey: 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'
              }),
              styleOptions
            }, document.getElementById('webchat'));
            document.querySelector('#webchat > *').focus();
        })().catch(err => console.error(err));
      </script>
    </body>  
  </html>