question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bot with cognitive services speech services (js) not working when using subscription key instead of a token

See original GitHub issue

Screenshots

image

Version

I’m using the template in: “06.c.cognitive-services-speech-services-js”, but with hardcoded key for DirectLine and hardcoded subscriptionKey for cognitive services speech. I did implemented this with electron but the same happen if i use npx serve.

Describe the bug

I can use the mic button to speak once, then i get: " webchat.js:1 POST https://westeurope.tts.speech.microsoft.com/cognitiveservices/v1 400 webchat.js:1 Error: Failed to syntheis speech, server returned 400 at VM127 webchat.js:1 Uncaught (in promise) Error: Failed to syntheis speech, server returned 400 Uncaught (in promise) {error: Error: Failed to syntheis speech, server returned 400 at https://cdn.botframework.com/botframew…, type: “error”, target: t} " I do get an answer from my bot but without speech and i can not click the mic button again.

To Reproduce

Steps to reproduce the behavior:

Use a subscription key instead of tokens.

Expected behavior

Not breaking 😃

Additional context

The example as is working fine, the problem started when i switched to hardcoded values. the values are correct though as the bot is functioning and the speech-to-text work one time before crashing (I did try to insert an invaild key to see what happen then i get authentication error as expected.

This is my code:

      <script>
	  (async function () {
	    const token =  'XXX';
		
		const region = 'westeurope';
		const subscriptionKey = 'YYY';
		
		const webSpeechPonyfillFactory = await window.WebChat.createCognitiveServicesSpeechServicesPonyfillFactory({
	      subscriptionKey,
		  region	   	  
	    });
		
        window.WebChat.renderWebChat({
          directLine: window.WebChat.createDirectLine({ token }),
          webSpeechPonyfillFactory
        }, document.getElementById('webchat'));

        document.querySelector('#webchat > *').focus();
      })().catch(err => console.error(err));
      </script>

[Bug]

PS: if you can point me out to somewhere which explain how to get bit token and cognitive services authorization token with js then i might just skip the hardcoded keys (as this was a first step check).

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
r3dr4goncommented, Sep 19, 2019

Awsome… Indeed changing the speak function to:

        public IActivity Speak(string message)
        {
            var activity = MessageFactory.Text(message);
            activity.Speak = message;
            return activity;
        }

Solved my problems, Thanks a lot for the help.

1reaction
tdurnfordcommented, Sep 19, 2019

@r3dr4gon Thanks for the additional information. It looks like Web Chat is nesting the Speech Synthesis Markup Language (SSML) which is causing the Cognitive Speech ponyfil to fail. If you remove the speak and voice tags from the activity’s speak property, it should work fine.

This is a known issue in Web Chat. I’m closing this issue as we are already using #1322 to track the bug.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Speech Cognitive services Authentication error (401) even ...
Speech Cognitive services Authentication error (401) even with correct subscription key. Hi I meet a problem for building a speech to text ...
Read more >
Can't fetch cognitive service token in webchat - Stack Overflow
Try this which worked for me: let authorizationToken; let region; const speechServicesTokenRes = await fetch( 'https://westus.api.cognitive. ...
Read more >
Adding speech capability to your chatbot using Bot Framework ...
js from a CDN; With our Speech API Key, a POST request is made to the issueToken endpoint to fetch a Speech Services...
Read more >
Explore text-to-speech capabilities with Azure Cognitive ...
In this video of the Azure Developer Streams series, we install text-to- speech for GIFBot with FierceKittenz on Twitch.
Read more >
SpeechToText-WebSockets-Javascript | SDK & Sample to do ...
The Speech API is part of Cognitive Services. You can get free trial subscription keys from the Cognitive Services subscription page.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found