Azure Bot框架与认知语音无法正常工作

问题描述 投票:0回答:1

我正在关注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

请帮我解决这个问题

javascript azure speech-recognition microsoft-cognitive azure-bot-service
1个回答
0
投票

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

原始代码使用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语音网址的行

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

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

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

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

© www.soinside.com 2019 - 2024. All rights reserved.