1
votes

I'm following this link where we can use the Speech recognition in the bot framework.

The default code is working with Option 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()
  };

But when I tried to use cognitive services it's not working, meaning the mic is not going to listening mode.

This is the change I made,

      // // 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)'
        })
      };

Apart from the commenting and uncommenting i didn't do any thing. But still the code is working only with Option 2

Pls help me solve this

1
There was a similar issue related to this thread - github.com/Microsoft/BotFramework-WebChat/issues/687 Please check and see if it helps. - Mohit Verma
@MohitVerma-MSFT thanks for the link. I think it's not related to that issue since I tried with almost all browsers like Chrome, Firefox, and Edge because cognitive can work in cross platform browsers. I tired with all different one. None of them works when I click the mike icon, the browsers got struct and going to the listening mode in none of the browsers. - Jayendran

1 Answers

3
votes

After some deep digging from my colleague, we found the issue.

The original code is using the javascript from https://cdn.botframework.com/botframework-webchat/latest/CognitiveServices.js

 <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>

If we open that JS file, you can find a line like below where it's using bing speech url

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

Since bing speech is depricted we have to update this line into our own subsciption

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

Once we updated it's working fine now