首页 > 解决方案 > 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#xamarintext-to-speech

解决方案


推荐阅读