Pankaj Singh

Pankaj Singh

  • NA
  • 97
  • 0

C# Speech Recognition - Is this what the user said?

Apr 21 2012 11:43 PM
Hi,

I have need to write an application which uses a speech recognition engine. I am using following code:

private void Form1_Load(object sender, EventArgs e)
{
// Speech Recognition Object
SpSharedRecoContext listener;

// Grammar object
ISpeechRecoGrammar grammar;
listener = new SpeechLib.SpSharedRecoContext();
listener.Recognition += new _ISpeechRecoContextEvents_RecognitionEventHandler(listener_Reco);
grammar = listener.CreateGrammar(0);
grammar.DictationLoad(richTextBox1.Text, SpeechLoadOption.SLOStatic);
grammar.DictationSetState(SpeechRuleState.SGDSActive);
}

public void listener_Reco(int StreamNumber, object StreamPosition, SpeechRecognitionType RecognitionType, ISpeechRecoResult Result)
{
string heard = Result.PhraseInfo.GetText(0, -1, true);
textbox1.Text += heard; // name

textbox2.Text += heard; // city
}

Its working but it have an issue that i have multiple textboxes for name,city,etc. And its type in both textboxes Simultaneously. I want display name ,city indivisually.

Thanks in advance