0
我正在嘗試使用c#(windows窗體)來製作語音識別應用程序。如何識別不在語法中的單詞
這裏是我使用
//recognizing speech
SpeechRecognitionEngine r = new SpeechRecognitionEngine();
//then load the grammar
r.LoadGrammar(new Grammar(new GrammarBuilder
(new Choices("hello","how are you","nice to meet you")))
{ Name = "speechGrammar" });
r.SetInputToDefaultAudioDevice(); // set the input of the speech recognizer to the default audio device
r.RecognizeAsync(RecognizeMode.Multiple); // recognize speech asynchronous
//adding a event handler
r.SpeechRecognized += r_SpeechRecognized;
//then create a method for that
void r_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
if (e.Result.Text == "test") // e.Result.Text contains the recognized text
{
SpeechSynthesizer s = new SpeechSynthesizer();
s.Speak("hello");
MessageBox.Show("Hi User");
s.Dispose();
}
}
的代碼,所以我想要的程序來改變文本框的詞/短語先前所說,但沒有在語法中的文本。
前 send a mail to xyz
句子是不是在語法列表 所以當它說我想
textbox1.text = spokenword;
我應該爲這個結果代碼什麼樣的變化。
如果你特別希望是無法識別的文本,那麼'SpeechRecognized'事件是不是你所需要的。其他活動可用..? – stuartd
@stuartd我希望計算機聽到的文本不在語法列表中。那麼我應該使用哪個事件 – Rico
@stuard我應該使用哪個事件? – Rico