2
votes

I have this error when I am using Speech to text from azure whith free trial version : CANCELED CancellationDetails(reason=CancellationReason.Error, error_details="WebSocket upgrade failed: Authentication error (401). Please check subscription information and region name.

I created an acompt Microsoft azure and I followed the documentation for Speech service. When I created a resource I got two keys and a location.

In my code I wrote this :

speech_key, service_region = "<key>", "<location>"
speech_config = speechsdk.SpeechConfig(subscription=speech_key, region=service_region)

And when I run this code this error is displayed. I am sure that I put the correct key and location.

Do you know if I forgot something or I am doing something bad?

1

1 Answers

0
votes

I just tested the code and it works fine,

import azure.cognitiveservices.speech as speechsdk
from azure.cognitiveservices.speech.audio import AudioOutputConfig


# Replace with your own subscription key and service region (e.g., "westus")
# Side note: some regions do not support text-to-speech
speech_key, service_region = "subscription_key", "service_region"

# Replace with input file name and format
input_file = open("input_file.txt", "r")
text = input_file.read()

# Replace desired output file name and format
output_file = "output_file.mp3"


# Creates an instance of a speech config with a specified subscription key and service region
speech_config = speechsdk.SpeechConfig(subscription=speech_key, region=service_region)