0

我正在构建一个语音控制的应用程序,我想在用户说出他的用户名和密码时设置文本框的文本,但是这没有发生,但是如果我显示使用消息识别的字符串

    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) 电子邮件正确显示,但文本框的文本没有改变

4

1 回答 1

0

最有可能识别的文本包含换行符,或类似的东西。

要隔离这一点,请尝试在 *SpeechRecognized 事件中指定具体字符串,例如

txtemail.Text = "recognized text";

它会起作用吗?如果是,请在调试器中检查字符串以查找特定字符。

于 2013-03-23T18:06:12.117 回答