使用下面的代码,它可以工作并返回第一个识别,但不会返回其他所有内容。我究竟做错了什么?我想是在某种循环中吗?
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)
{
}
答案 0 :(得分:3)
使用SpeechRecognized作为事件处理程序来执行Console.WriteLine()。我刚刚遇到了同样的事情。