【问题标题】:Azure Bot Framework with Cognitive Speech not working具有认知语音的 Azure Bot Framework 无法正常工作
【发布时间】:2019-04-03 20:54:21
【问题描述】:

我正在关注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)'
        })
      };

除了评论和取消评论我没有做任何事情。但代码仍然只适用于 Option 2

请帮我解决这个问题

【问题讨论】:

  • 有一个与此线程相关的类似问题 - github.com/Microsoft/BotFramework-WebChat/issues/687 请检查它是否有帮助。
  • @MohitVerma-MSFT 感谢您的链接。我认为这与该问题无关,因为我尝试了几乎所有浏览器,如 Chrome、Firefox 和 Edge,因为认知可以在跨平台浏览器中工作。我厌倦了所有不同的。当我单击麦克风图标时,它们都不起作用,浏览器得到结构并在任何浏览器中都没有进入监听模式。

标签: javascript azure speech-recognition microsoft-cognitive azure-bot-service


【解决方案1】:

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

原始代码使用来自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")}

一旦我们更新它现在工作正常

【讨论】:

  • 我也有同样的问题,能否分享一下更新后的代码?我不明白最后的事情。在哪里更新,什么? @Jayendran
  • @MarcoWirtl 在CognitiveServices.js 文件中有一个需要更新的特定行。那行是Storage.Local.GetOrAdd("Host","wss://speech.platform.bing.com"),你必须像Storage.Local.GetOrAdd("Host","wss://&lt;region&gt;.stt.speech.microsoft.com")一样更新它
  • 所以我下载了 JS 并更改了链接,也将 更改为 westus 并使用 ./CognitiveServices.js 加载脚本,按钮仍然不可点击。怎么了?
  • 抱歉,不知道出了什么问题。因为对我们来说,这样做后它起作用了
  • 子键呢?这两者都一样吗?来自语音认知服务?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-10-16
  • 2018-05-27
  • 1970-01-01
  • 1970-01-01
  • 2018-11-14
  • 1970-01-01
相关资源
最近更新 更多