c# 文字朗读 播放声音
win10系统测试通过
第一种方法,最简单
private static dynamic _comTts;
Type type = Type.GetTypeFromProgID("SAPI.SpVoice");
private void Read(string text)
{
Task.Factory.StartNew(() =>
{
try
{
_comTts = Activator.CreateInstance(type);
_comTts.Speak(text);
}
catch{}
});
}
第二种方法
要引用 using System.Speech.Synthesis;
SpeechSynthesizer synth = new SpeechSynthesizer(); synth.SetOutputToDefaultAudioDevice(); synth.Speak("欢迎使用");
浙公网安备 33010602011771号