我是新来的语音识别系统,并且开发了一个文本编辑器来编写我所说的内容。我遇到了可以通过代码启用语音识别的问题,但无法禁用它。任何人都可以请建议如何禁用语音识别。我的语音识别代码如下:.net问题中的语音识别
//function to start/stop speech recognition
private void enableSpeechRecognitionToolStripMenuItem_Click(object sender, EventArgs e)
{
listener = new SpeechLib.SpSharedRecoContext();
//crating a share recognition object
listener.Recognition += new _ISpeechRecoContextEvents_RecognitionEventHandler(listener_Reco);
//creating a recgnition event handler object
grammar = listener.CreateGrammar(0);
//create grammar interface with ID = 0
grammar.DictationLoad("", SpeechLoadOption.SLOStatic);
//setting grammar load type to static
grammar.DictationSetState(SpeechRuleState.SGDSActive);
//activating speech dictation
enableSpeechRecognitionToolStripMenuItem.Checked = true;
//checked
toolStripStatusLabel1.Text = "[Speech Recognition Enabled]";
}
//function to append the listened text to the text box's text
public void listener_Reco(int StreamNumber, object StreamPosition, SpeechRecognitionType RecognitionType, ISpeechRecoResult Result)
{
string heard = Result.PhraseInfo.GetText(0, -1, true);
//setting heard text to a variable
richTextBox1.Text += " " + heard;
//appending heard text
}
我无法删除识别处理程序。你能告诉我,我能怎么做? – impiyush 2011-03-26 15:08:28
编辑我的回复以包含删除处理程序的示例。 – Jason 2011-03-27 01:29:29