我的文本框文本没有变化(内部信息)

时间:2013-03-23 16:40:54

标签: c#

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

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

1 个答案:

答案 0 :(得分:0)

大多数可能识别的文字包含新的行字符,或类似的东西。

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

txtemail.Text = "recognized text";
它会起作用吗?如果是,请在调试器中检查特定字符的字符串。