我正在构建一个语音控制的应用程序,我想在用户说出他的用户名和密码时设置文本框的文本,但是这没有发生,但是如果我显示使用消息识别的字符串
public Form1()
{
InitializeComponent();
GrammarBuilder g = new Choices("wissam.h44", "jordan_6");
Grammar g1 = new Grammar(g);
Grammar g2 = new Grammar(g);
InitializeComponent();
this.Shown += new System.EventHandler(this.Form1_Shown);
Recognizer1.LoadGrammar(g1);
Recognizer2.LoadGrammar(g2);
}
private void Form1_Shown(Object sender, EventArgs e)
{
Synthesizer1.Speak("Application is loaded.");
Synthesizer1.Speak("Please Enter Your Email: ");
Recognizer1.SpeechRecognized +=
new EventHandler<SpeechRecognizedEventArgs>(recognizer1_SpeechRecognized);
Recognizer1.SetInputToDefaultAudioDevice();
Recognizer1.Recognize();
Synthesizer1.Speak("Please Enter Your Password: ");
Recognizer2.SpeechRecognized +=
new EventHandler<SpeechRecognizedEventArgs>(recognizer2_SpeechRecognized);
Recognizer2.SetInputToDefaultAudioDevice();
Recognizer2.Recognize();
}
void recognizer1_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
string eml = e.Result.Text;
txtemail.Text = eml;
}
void recognizer2_SpeechRecognized(object sender, SpeechRecognizedEventArgs r)
{
txtpwd.Text = r.Result.Text;
}
所以在语音识别事件中,如果我把 MessageBox.Show(eml) 电子邮件正确显示,但文本框的文本没有改变