SpeechRecognizer.SpeechRecognized事件无法使用语音识别器(英语 - 英语)

时间:2014-08-05 04:32:42

标签: c# speech-recognition sapi

我在C#中创建了一个简单的语法,之后我使用了SpeechRecognizer.SpeechRecognized Event。但我不知道为什么它与Microsoft Speech Recognizer(英语 - 美国)一起使用,但它不适用于Microsoft Speech Recognizer(英语 - 英语)。

这是代码:

    private void button1_Click(object sender, EventArgs e)
    {
        System.Speech.Recognition.SpeechRecognizer sr = new SpeechRecognizer();
        Choices Slist = new Choices();
        Slist.Add(new string[] { "Brazil", "Germany", "Argentina", "Netherlands" });
        Grammar gr = new Grammar(new GrammarBuilder(Slist));
        sr.RequestRecognizerUpdate();
        sr.LoadGrammarAsync(gr);
        sr.SpeechRecognized += sr_SpeechRecognized;

    }

    void sr_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
    {
        if (e.Result.Text.ToString()== "Brazil")
        {
            MessageBox.Show("Fourth");
        }
        if (e.Result.Text.ToString() == "Germany")
        {
            MessageBox.Show("First");
        }
        if (e.Result.Text.ToString() == "Argentina")
        {
            MessageBox.Show("Second");
        }
        if (e.Result.Text.ToString() == "Netherlands")
        {
            MessageBox.Show("third");
        }
    }

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:1)

显然,GrammarBuilder对象上的Culture属性必须与识别器的文化匹配,才能使识别工作。