javascript - 具有认知语音功能的 Azure Bot 框架无法正常工作

标签 javascript azure speech-recognition azure-cognitive-services azure-bot-service

我正在关注this link我们可以在机器人框架中使用语音识别。

默认代码适用于选项 2

  // // Option 2: Native browser speech (not supported by all browsers, no speech recognition priming support)
  //
  // Note that Chrome automatically blocks speech if the HTML file is loaded from disk. You can run a server locally
  // or launch Chrome (close all the existing Chrome browsers) with the following option:
  // chrome.exe --allow-file-access-from-files <sampleHtmlFile>
  //
  const speechOptions = {
     speechRecognizer: new BotChat.Speech.BrowserSpeechRecognizer(),
     speechSynthesizer: new BotChat.Speech.BrowserSpeechSynthesizer()
  };

但是当我尝试使用认知服务时,它不起作用,这意味着麦克风不会进入聆听模式。

这是我所做的更改,

      // // Option 3: Cognitive Services speech recognition using API key (cross browser, speech priming support)
 const speechOptions = {
        speechRecognizer: new CognitiveServices.SpeechRecognizer({ subscriptionKey: 'YOUR_COGNITIVE_SPEECH_API_KEY' }),
        speechSynthesizer: new CognitiveServices.SpeechSynthesizer({
          gender: CognitiveServices.SynthesisGender.Female,
          subscriptionKey: 'YOUR_COGNITIVE_SPEECH_API_KEY',
          voiceName: 'Microsoft Server Speech Text to Speech Voice (en-US, JessaRUS)'
        })
      };

除了评论和取消评论之外我没有做任何事情。但该代码仍然仅适用于选项 2

请帮我解决这个问题

最佳答案

经过我同事的深入挖掘,我们发现了这个问题。

原始代码使用 https://cdn.botframework.com/botframework-webchat/latest/CognitiveServices.js 中的 javascript

 <div id="BotChatGoesHere"></div>


    <!-- If you do not want to use Cognitive Services library, comment out the following line -->
    <script src="https://cdn.botframework.com/botframework-webchat/latest/CognitiveServices.js"></script>

如果我们打开该 JS 文件,您可以找到如下所示的一行,其中使用了 bing 语音 url

Storage.Local.GetOrAdd("Host","wss://speech.platform.bing.com")}

由于bing语音被描述,我们必须将此行更新为我们自己的订阅

Storage.Local.GetOrAdd("Host","wss://<region>.stt.speech.microsoft.com")}

更新后,它现在工作正常

关于javascript - 具有认知语音功能的 Azure Bot 框架无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55160058/

相关文章:

php - 如何保存裁剪后的图像

javascript - 将 jQuery 函数转换为纯 JavaScript

c# - 无法在 Azure 开发存储上创建表

python - 开始在 python 上录制之前的语音识别流延迟

javascript - 对于正则表达式模式,如何确定与该模式匹配的最长字符串的长度?

javascript - SlickGrid dataView 链接

python-3.x - 使用python索引音频以获取每个单词的时间戳

c# - 从 xml 文件读取语法时,语音识别 : Result. Semantic.ContainsKey 始终为 false

azure - Kubernetes 高可用大师

Azure AD 快速入门显示回复 URL 与应用程序不匹配