1. 添加 System.Speech 引用,该引用来自于 .NET Framework
2. 添加 using System.Speech.Synthesis; 命名空间
3. 调用语音合成并发声
/// <summary>
/// 语音播放提示文字
/// </summary>
private void SpeechTipTextAudio()
{
try
{
string tipText = "语音提示文字";
SpeechSynthesizer synth = new SpeechSynthesizer();
synth.SetOutputToDefaultAudioDevice();
synth.Speak(tipText);
}
catch
{
return;
}
}