I'm trying to use the Azure Cognitive Services text-to-speech API, but no matter what I try, I get a 401 Unauthorized response.
I've created a Cognitive Services resource on my subscription in the West Europe region. Type is All Cognitive Services, status is active. I downloaded the CSharp sample from https://github.com/Azure-Samples/Cognitive-Speech-TTS and entered the West Europe URLs and my Cognitive Services subscription key into the code. When I run the sample, the access token is retrieved just fine, but the text-to-speech request returns 401.
Token URL: https://westeurope.api.cognitive.microsoft.com/sts/v1.0/issueToken
Service URL: https://westeurope.tts.speech.microsoft.com/cognitiveservices/v1
I've checked that the URLs are correct, I'm using the same region in both and the same one as the created resource. I went throught the troubleshooting page (https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/troubleshooting) and got the same 401 issue. I tried running the TTS request from Postman. I've tried both Key1 and Key2 from the Azure portal, and tried to regenerate a key. I've tried running the request also in Azure Functions, both locally and in the cloud.
I've decoded the access token and it seems like it has pretty much the right stuff in it, as far as I can tell. The only weird thing is, the exp field is a string and not a number (incorrect for a JWT). Could that be a bug in the auth system that is causing this error or am I doing something wrong?
Request
POST https://westeurope.tts.speech.microsoft.com/cognitiveservices/v1 HTTP/1.1
Authorization: Bearer <access-token>
User-Agent: TestApi
X-Microsoft-OutputFormat: audio-16khz-64kbitrate-mono-mp3
Content-Type: application/ssml+xml
Host: westeurope.tts.speech.microsoft.com
Content-Length: 209
<speak version="1.0" xml:lang="fi-FI">
<voice name="Microsoft Server Speech Text to Speech Voice (fi-FI, HeidiRUS)" xml:lang="fi-FI">Hei, muistathan suorittaa päivän harjoitteet ajoissa.</voice>
</speak>
Response
HTTP/1.1 401 Unauthorized
X-MSEdge-Ref: Ref A: AD369D30DDB7466B8A77086554F9DC46 Ref B: HEL02EDGE0112 Ref C: 2018-12-10T13:03:43Z
Date: Mon, 10 Dec 2018 13:03:42 GMT
Content-Length: 0
westus
towesteurope
in bothissueToken
andv1
url, it's working on my side. Will be difficult to help more.. – Nicolas R