using System;
using System.Speech.Synthesis; namespace testvoice
{
class Program
{
static void Main(string[] args)
{
SpeechSynthesizer synth = new SpeechSynthesizer(); //获取本机上所安装的所有的Voice的名称
string voicestring = ""; foreach (InstalledVoice iv in synth.GetInstalledVoices())
{
voicestring += iv.VoiceInfo.Name + ",";
}
//voicestring的值是Microsoft Lili,Microsoft Anna
synth.Volume = ;
synth.Rate = -;
//根据Voice的name属性确定要使用的Voice
//synth.SelectVoice("Microsoft Anna");//美式发音,但只能读英文
synth.SelectVoice("Microsoft Lili");//能读中英文
//根据文字内容合成语音
synth.Speak("你好");
Console.Read();
}
}
}