c# - Visual Studio 中的 Microsoft Text To Speech Infinite Await
问题描述
var config = SpeechConfig.FromSubscription("", "westeurope");
var synthesizer = new SpeechSynthesizer(config);
var result = await synthesizer.SpeakSsmlAsync(xmlFirstPart + voice + xmlSecondPart + synthesisText + xmlThirdPart);
var stream = AudioDataStream.FromResult(result);
string file = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), fileName + ".wav");
await stream.SaveToWaveFileAsync(file);
您好,此代码片段可与 Visual Studio 中的 Microsoft.CognitiveServices.Speech NuGet 配合使用 - 它将请求的字符串输出到音频。问题是输出音频后,程序冻结。我认为第三行代码是问题所在,因为 await 函数没有结束,即使它完成了它的工作。有谁知道我该如何解决这个问题?先感谢您。
解决方案
推荐阅读
- c - 如何在 C 中获取字符的 8 位二进制表示?
- javascript - 如何使用节点 js 为 Alexa Skill 在函数内返回 handlerinput.responsebuilder
- c++ - 在自定义 std::vector-like 容器中处理指针和非指针模板类型的最佳方法是什么?
- powershell - Powershell #Requires path/to/Name.exe
- html - 特异性和 CSS 边界半径问题
- php - 灯箱插件不适用于自定义开发主题
- microservices - 桌面应用程序可以有微服务架构吗?
- php - cUrl PHP Get 请求返回 400 BAD REQUEST 但在 Postman 中工作
- sql - 在 postgresql 中使用 split_part 给出错误的结果
- c++ - fopen_s 未在范围内声明(C++:codeblocks)