using System.Speech.Synthesis;
private static SpeechSynthesizer speech = new SpeechSynthesizer();
/// <summary>
/// read(要朗读的文字,速度,音量)
/// </summary>
/// <param name="read"></param>
/// <param name="rate"></param>
/// <param name="volume"></param>
public static void read(string read, int rate, int volume, bool yibu = true)
{
try
{
speech.Rate = rate;//速度
speech.Volume = volume;//音量,0-100
speech.SpeakAsyncCancelAll();
if (yibu)
{
speech.SpeakAsync(read);//异步播放,但是要等到前面的发音完成后才会播放该发音
}
else
{
speech.Speak(read);
}
}
catch (Exception)
{
}
}