语音识别引擎无法识别多次

时间:2010-09-01 17:29:48

标签: c# speech-recognition

使用下面的代码,它可以工作并返回第一个识别,但不会返回其他所有内容。我究竟做错了什么?我想是在某种循环中吗?

    public void Transcribe()
    {
        SpeechRecognitionEngine SRE = new SpeechRecognitionEngine();
        SRE.LoadGrammar(new DictationGrammar());

        SRE.SetInputToWaveFile(_fileName);
        SRE.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(SRE_SpeechRecognized);
        SRE.RecognizeCompleted += new EventHandler<RecognizeCompletedEventArgs>(SRE_RecognizeCompleted);
        SRE.RecognizeAsync(RecognizeMode.Multiple);    
    }

    void SRE_RecognizeCompleted(object sender, RecognizeCompletedEventArgs e)
    {
        Console.WriteLine(e.Result.Text);
    }

    void SRE_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
    {            
    }

1 个答案:

答案 0 :(得分:3)

使用SpeechRecognized作为事件处理程序来执行Console.WriteLine()。我刚刚遇到了同样的事情。