0
我有這樣的代碼來設置自定義的語法並將其加載到一個語音識別引擎識別多個語法選擇
DictationGrammar customDictationGrammar = new DictationGrammar();
customDictationGrammar.Name = "Dictation";
customDictationGrammar.Enabled = true;
GrammarBuilder grammar = new GrammarBuilder();
grammar.Append(new Choices("turn", "on", "off", "lamp"));
grammar.Culture = ri.Culture;
Grammar g = new Grammar(grammar);
spRecEng.LoadGrammar(g);
spRecEng.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(spRecEng_SpeechRecognized);
spRecEng.SpeechRecognitionRejected += new EventHandler<SpeechRecognitionRejectedEventArgs>(spRecEng_SpeechRecognitionRejected);
spRecEng.SetInputToAudioStream(source.Start(), new SpeechAudioFormatInfo(EncodingFormat.Pcm, 16000, 16, 1, 32000, 2, null));
spRecEng.RecognizeAsync(RecognizeMode.Multiple);
是否有可能使它所以它會如識別多個選項turn
,on
和lamp
或者我是否必須寫出所有變體,我可以在我的Choices數組中進行說明?
您的代碼不用'customDictationGrammar'做任何事情,只是創建一個對象並拋出它離開? –
此外,此示例顯示如何將字詞順序放在一起:http://msdn.microsoft.com/en-us/library/system.speech.recognition.grammarbuilder(v=vs.110).aspx –