System.Speech.Synthesis.SpeechSynthesizer SpeechSynthesizer = new System.Speech.Synthesis.SpeechSynthesizer();
public void boFangYuyin() {
try
{
System.Threading.Tasks.Task.Factory.StartNew(boFangYuyinAction);
}
catch (Exception ex)
{
EduInterface.IEx.Handle(ex, FloatToolsErrCode.语音播放学生姓名);
}
}
public void boFangYuyinAction() {
SpeechSynthesizer.Rate = 0;
SpeechSynthesizer.Speak("正在播放语音中");
}
protected override void OnClosed(EventArgs e)
{
base.OnClosed(e);
SpeechSynthesizer.Pause();//要有这句,否则播放中突然关闭窗体会报错
SpeechSynthesizer.Dispose();//释放资源
}
SpeechSynthesizer 异步正在播放语音突然关闭窗口报错
于 2021-05-13 11:50:03 首次发布