Short Speech Code :)

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

  1. KathySbeat

    KathySbeat New Member

    Joined:
    Aug 28, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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;
    }
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice