SAPI v5.1的帮助SpeechRecognitionEngine与C#总是给出相同的错误结果
||
我在玩这个SAPI v5.1库。因此,我正在测试样本WAV文件。 (从此处下载)。无论如何,该文件中的声音清晰清晰。它仅包含一个单词,即第三个单词。现在,当我运行以下代码时,我得到数字8或\“八\”。如果将其删除,则得到7。如果尝试随机化列表,则得到不同的结果,依此类推。我真的很困惑,开始认为SAPI库中的SpeachRecognition根本不起作用...
反正这就是我在做什么
private void button1_Click(object sender, EventArgs e)
{
//Add choices to grammar.
Choices mychoices = new Choices();
mychoices.Add(\"one\");
mychoices.Add(\"two\");
mychoices.Add(\"three\");
mychoices.Add(\"four\");
mychoices.Add(\"five\");
mychoices.Add(\"six\");
mychoices.Add(\"seven\");
mychoices.Add(\"eight\");
mychoices.Add(\"nine\");
mychoices.Add(\"zero\");
mychoices.Add(\"1\");
mychoices.Add(\"2\");
mychoices.Add(\"3\");
mychoices.Add(\"4\");
mychoices.Add(\"5\");
mychoices.Add(\"6\");
mychoices.Add(\"7\");
mychoices.Add(\"8\");
mychoices.Add(\"9\");
mychoices.Add(\"0\");
Grammar myGrammar = new Grammar(new GrammarBuilder(mychoices));
//Create the engine.
SpeechRecognitionEngine reco = new SpeechRecognitionEngine();
//Read audio stream from wav file.
reco.SetInputToWaveFile(\"3.wav\");
reco.LoadGrammar(myGrammar);
//Get the recognized value.
reco.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(reco_SpeechRecognized);
reco.RecognizeAsync(RecognizeMode.Multiple);
}
void reco_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
MessageBox.Show(e.Result.Text);
}
没有找到相关结果
已邀请:
1 个回复
闪票仇门韧
您还应该从语法中删除数字选项。现在,识别器返回两个替代项:\“ three \”和\“ 3 \”。这可能不是您想要的。您可以在语法中使用语义结果值来返回单词“三”的数字3。