speech to text Authentication error (401) on GitHub SDK samples c++ console

Jose Fernando Garcia 21 Reputation points
2021-02-23T18:31:20.387+00:00

I am testing an azure cognitive services speech. Pricing tier is free (f0). I followed instructions for creating instance and service. It is listed as Cognitive services, API type: speech

I am getting error code= 1 : ErrorDetails=WebSocket upgrade failed: Authentication error (401). Please check subscription information

This is pointing to either subscriptionkey or service region. I am using a C++ console sdk sample from https://github.com/Azure-Samples/cognitive-services-speech-sdk/tree/master/samples/cpp/windows/console

I am targeting the SpeechContinuousRecognitionWithFile() from SpeechRecognitionSamples ( option 1 then option 3). I only replaced key and region on this method.
I tried with two different regions in different instances: northeurope and westus. I tried three different keys. None worked.

I verified the subscription using this on powershell
$FetchTokenHeader = @{
'Content-type'='application/x-www-form-urlencoded';
'Content-Length'= '0';
'Ocp-Apim-Subscription-Key' = 'YOUR_SUBSCRIPTION_KEY'
}

$OAuthToken = Invoke-RestMethod -Method POST -Uri https://westus.api.cognitive.microsoft.com/sts/v1.0/issueToken
-Headers $FetchTokenHeader

show the token received

$OAuthToken

Any idea on what to check is very much appreciated.

Azure AI Speech
Azure AI Speech
An Azure service that integrates speech processing into apps and services.
1,398 questions
Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
2,387 questions
0 comments No comments
{count} votes

Accepted answer
  1. GiftA-MSFT 11,151 Reputation points
    2021-02-23T23:04:31.323+00:00

    Hi, thanks for reaching out. The error is most likely due to invalid endpoint for your region/service or issues with your subscription key. Please go to Azure portal > speech resource > resource management > Keys and Endpoint to confirm your authentication details.


0 additional answers

Sort by: Most helpful