PeakGen
PeakGen

Reputation: 23025

Stop responding to windows commands

Please have a look at the following code

  private void button2_Click(object sender, EventArgs e)
        {
            SpeechRecognizer sr = new SpeechRecognizer();

            Choices colors = new Choices();
            colors.Add(new string[] { "red arrow", "green", "blue" });

            GrammarBuilder gb = new GrammarBuilder();
            gb.Append(colors);

            Grammar g = new Grammar(gb);

            sr.LoadGrammar(g);

           // SpeechSynthesizer s = new SpeechSynthesizer();
           // s.SpeakAsync("start speaking");

            sr.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(sr_SpeechRecognized);
        }

        void sr_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            MessageBox.Show(e.Result.Text);
        }

This is normal speech recognition code which uses the MS speech engine. You can see here that I have loaded some grammar. But, there is an issue as well. That is, this is not responding only to the given grammar but also to the MS Built-In speech commands! Like speech command to minimize a window, open start menu etc!

I really don't need that. My application should only respond to my grammar and not to MS built-in commands. Is there is a way I can achieve this?

Upvotes: 1

Views: 103

Answers (1)

keyboardP
keyboardP

Reputation: 69372

The SpeechRecognizer object builds on top of the existing Windows Speech system. From MSDN:

Applications use the shared recognizer to access Windows Speech Recognition. Use the SpeechRecognizer object to add to the Windows speech user experience.

Consider using a SpeechRecognitionEngine object instead as this runs in-process rather than system-wide.

Upvotes: 1

Related Questions