1
votes

When I was trying to translate a sample audio from English to some other language using Azure Bing Speech to Text Api, I am getting Error: Voice recognition failed miserably: Wrong status code 401 in Bing Speech API / token

I have tried increasing open_timeout to a higher value like 50000(which was suggested for slow-internet) hard-coded in bingspeech-api-client in Line 110 , but still the error persists.

let audioStream = fs.createReadStream('hello.wav'); 
// Bing Speech Key (https://www.microsoft.com/cognitive-services/en-us/subscriptions)
let subscriptionKey = '******';         
let client = new BingSpeechClient(subscriptionKey);

      client.recognizeStream(audioStream).then(function(response)
      {

        console.log("response is ",response);
        console.log("-------------------------------------------------");
        console.log("response is ",response.results[0]);
      }).catch(function(error)
      {
        console.log("error occured is ",error);
      });

This code should generate the text from that sample audio file.

1

1 Answers

0
votes

Code 401 means unauthorized - wrong key in your case. I suspect you followed an outdated version of some tutorial since by now the service is not called Bing Speech API anymore. See here for a current tutorial using the microsoft-cognitiveservices-speech-sdk SDK for node.js.

https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/quickstart-js-node#use-the-speech-sdk