[英]I can't stop sound with C# Form(SpVoice)
我正在开发字典。 我可以听字典中的单词。 如果我们很快听了很多话。 不听旧词我听不到当前选择的词。 所以我在等着听选定的词。 '''
class Voicer1
{
public string read;
public SpVoice Sound_SV = new SpVoice();
public Thread th_WP;
public void Sound_Stp(string vocalist)
{
read = vocalist.ToString();
thread_Stp();
}
public void thread_Stp()
{
th_WP = new Thread(new ThreadStart(sound_1));
th_WP.Start();
}
public void sound_1()
{
Sound_SV.Speak(read.ToString(), SpeechVoiceSpeakFlags.SVSFDefault);
GC.Collect();
GC.WaitForPendingFinalizers();
}
}
这是在听
Voicer1 Sound_1= new Voicer1();
Snd.Sound_Stp(label1.Text.ToString());
我在必要时使用;
SoundPlayer stoprrr= new SoundPlayer();
stoprrr.Stop();
但这不起作用。
你能帮助我吗
我用; using System.Speech.Synthesis;
然后, SpeechSynthesizer SSObj;
当我想听新词时,
if (SSObj!= null)
{
SSObj.Dispose();
}
SSObj= new SpeechSynthesizer();
SSObj.SpeakAsync(read);
这种方法奏效了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.