[英]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.