C# 语音播报

添加引用

COM中添加Microsoft Speech Object Library

添加控件

在代码中添加 using SpeechLib;

简单代码实现

SpeechVoiceSpeakFlags flag= SpeechVoiceSpeakFlags.SVSFlagsAsync;
SpVoice voice = new SpVoice();
string voice_txt ="苟利国家生死以,岂因祸福避趋之";
voice.Voice = voice.GetVoices(string.Empty, string.Empty).Item(0);
voice.Speak(voice_txt, flag);

你可能感兴趣的:(Programming)