微软语音合成朗读c#
生活随笔
收集整理的这篇文章主要介绍了
微软语音合成朗读c#
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
经过测试,发现微软的语音服务在发音方面略强于科大讯飞。
using Microsoft.CognitiveServices.Speech; ... public async Task SynthesisToSpeakerAsync(string text){if (text == ""){textBox1.Text += $"识别读取文本: [{text}]\r\n";return;}var config = SpeechConfig.FromSubscription("6666666666666666", "westus2");config.SpeechRecognitionLanguage = "zh-CN";config.SpeechSynthesisLanguage = "zh-CN";//https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/language-support#neural-voicesconfig.SpeechSynthesisVoiceName = comboBox1.Text;synthesizer = null;using (synthesizer = new SpeechSynthesizer(config)){using (var result = await synthesizer.SpeakTextAsync(text)){if (result.Reason == ResultReason.SynthesizingAudioCompleted){AudioCompleted = true;textBox1.Text += $"识别读取文本: [{text}]\r\n";}else if (result.Reason == ResultReason.Canceled){var cancellation = SpeechSynthesisCancellationDetails.FromResult(result);textBox1.Text += ($"CANCELED: Reason={cancellation.Reason}\r\n");if (cancellation.Reason == CancellationReason.Error){textBox1.Text += ($"CANCELED: ErrorCode={cancellation.ErrorCode}\r\n");textBox1.Text += ($"CANCELED: ErrorDetails=[{cancellation.ErrorDetails}]\r\n");textBox1.Text += ($"CANCELED: Did you update the subscription info?\r\n");}}}// This is to give some time for the speaker to finish playing back the audio}}总结
以上是生活随笔为你收集整理的微软语音合成朗读c#的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: 深度学习基础 - 三角函数
- 下一篇: C#音效播放PlaySound