SpeechRecognitionEngine sre = new SpeechRecognitionEngine();
Choices clist = new Choices();
// just assume I have added words in clist not shown here
Grammar gr = new Grammar(new GrammarBuilder(clist));
sre.RequestRecognizerUpdate();
sre.LoadGrammar(gr);
sre.SpeechRecognized += sre_SpeechRecognized;
sre.SetInputToDefaultAudioDevice();
sre.RecognizeAsync(RecognizeMode.Multiple);
void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
//This only outputs words present in grammar
Console.WriteLine(e.Result.Text);
}总之,为什么我们需要一个语法在语音识别。如果需要语法,有什么意义。如果识别器必须匹配语法中的字符串,为什么我们不能输出没有语法的语音识别器呢?
谢谢,请纠正我错的地方。
https://stackoverflow.com/questions/42942196
复制相似问题