Really need help :) I got finished all the code..but i wanted you to help me for understanding the two lines (the first steps)
this is a code of .. SPEECH to TEXT .. :)


This is the lines that i need you to explain to me :)
you need to add a SpSharedRecoContext object and create an ISpeechRecoGrammar object for it. Then Add a RecognitionHandler to it...

Add another Button and a TextBox to your form and create the objects there. Then add a handler to tie into the listeners Recognition event...
view sourceprint?


and this is all the quote code :)

private void btnListen_Click(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("", 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;
}

Edited 6 Years Ago by KathySbeat: n/a

What exactly is your question? Is there a problem with your code; Does it not behave correctly?


N.B Please try to limit your use of the red font for highlighting one or tweo words; Large blocks of red text are quite hard on the eyes

thanks for replaying :)
my question is that i don't understand this lines .

you need to add a SpSharedRecoContext object and create an ISpeechRecoGrammar object for it. Then Add a RecognitionHandler to it...

Add another Button and a TextBox to your form and create the objects there. Then add a handler to tie into the listeners Recognition event...
view sourceprint?

how to add a SpSharedRecoContext object and create an ISpeechRecoGrammar object...i need it urgently...can u plz send me the total code how to convert speech to text.....plzzz

This article has been dead for over six months. Start a new discussion instead.