简体   繁体   English

Azure 认知服务 - 文本转语音 - SpeakTextAsync 不返回

[英]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.使用 Azure 文本转语音服务时,我的 .NET WPF 应用程序出现冻结问题。

From debugging it seems the SpeakTextAsync synthesizes the text I send, but never completes/returns a value, causing the application to be unresponsive.从调试来看,SpeakTextAsync 似乎合成了我发送的文本,但从未完成/返回值,导致应用程序无响应。

I have experience with Java and some web technologies but I am fairly new to C#, .NET and Azure.我有 Java 和一些 Web 技术的经验,但我对 C#、.NET 和 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.要使示例应用程序正常工作,请将 SpeechSample.UI/SpeechSample.Services/SpeechService.cs 的第 12 行替换为您的 Azure 订阅密钥。

Thanks for your time.谢谢你的时间。

I updated my sample app with the fix.我用修复更新了我的示例应用程序。 I was running the initial async task TriggerEventAsync wrong我正在运行初始异步任务 TriggerEventAsync 错误

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM