1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Short Speech Code :)

Discussion in 'C#' started by KathySbeat, Aug 28, 2010.

  1. KathySbeat

    KathySbeat New Member

    Aug 28, 2010
    Likes Received:
    Trophy Points:
    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);

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

Share This Page