Stephen Stewart
Stephen Stewart

Reputation: 179

Azure Cognitive Services - Text-to-Speech - SpeakTextAsync does not return

I am having an issue with my .NET WPF application freezing when using Azure Text-to-Speech services.

From debugging it seems the SpeakTextAsync synthesizes the text I send, but never completes/returns a value, causing the application to be unresponsive.

I have experience with Java and some web technologies but I am fairly new to C#, .NET and Azure.

I have a sample app here to highlight the issue I am having; perhaps if anyone has any ideas they can give me some tips on debugging in the future :)

For the sample app to work, replace line 12 of SpeechSample.UI/SpeechSample.Services/SpeechService.cs with your Azure subscription key.

Thanks for your time.

Upvotes: 0

Views: 322

Answers (1)

Stephen Stewart
Stephen Stewart

Reputation: 179

I updated my sample app with the fix. I was running the initial async task TriggerEventAsync wrong

//Switched this line
TriggerEventAsync(eventManager).GetAwaiter().GetResult();

//For this line
Task.Run(async () => await TriggerEventAsync(eventManager));

Upvotes: 2

Related Questions