Hi,
I'm following these MS Learn docs on Microsoft Entra authentication with the Speech SDK
I am successfully getting back a token issued to me which I pass onto the SpeechConfig object as per the docs but then SpeechRecogniser immediately errors out with:
"WebSocket upgrade failed: Authentication error (401). Please check subscription information and region name. "
I an on the S0 standard pricing tier.
I have given myself 'Speech Services Speech User' and 'Contributor' role on the Speech Services instance.
Region is 'uksouth' and I have a custom domain name for the endpoint all as per the docs. Is there anything else I need to do that I'm missing?
private async Task CreateContinuousRecognizer(TextAreaObject textAreaObject)
{
string region = "uksouth";
var authorizationToken = await ResourceToken();
SpeechConfig sc = SpeechConfig.FromAuthorizationToken(authorizationToken, region);
AudioConfig ac = AudioConfig.FromDefaultMicrophoneInput();
SpeechRecognizer sr = new SpeechRecognizer(sc, ac);
_original = textAreaObject.Text;
StringBuilder sb = new();
success = true;
AppendNewLines(_original);
sr.Recognizing += Recognizing;
sr.Recognized += Recognized;
sr.Canceled += Canceled;
}
private async Task<string> ResourceToken()
{
string resourceId = "<our resource id>";
string[] scopes = { "https://cognitiveservices.azure.com/.default", };
TokenRequestContext context = new(scopes);
InteractiveBrowserCredential cred = new();
string aadToken = (await cred.GetTokenAsync(context)).Token;
string token = $"aad#{resourceId}#{aadToken}";
return token;
}