Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

C# Microsoft SPeech Recognition Enabled Problem? Must repeat word twice.

$
0
0

Each time a word is identified I want to turn one grammar off and the other one on. 

private void sRecognize_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            textBox1.Text = e.Result.Text.ToString();
            sRecognize.Grammars[sRecognize.Grammars.IndexOf(stategr)].Enabled=!sRecognize.Grammars[sRecognize.Grammars.IndexOf(stategr)].Enabled;         sRecognize.Grammars[sRecognize.Grammars.IndexOf(objgr)].Enabled=!sRecognize.Grammars[sRecognize.Grammars.IndexOf(objgr)].Enabled;
        }

The enable and disable of grammars works except, I have to say the word twice. stategr contains "hello", and objgr contain "person". If I say hello it doesn't write anything, after I say hello again it writes it then turns one grammar one and the other off. Then if I say person again it doesn't write it. If I say person again it writes it. Why do I have to say the words twice for the speech recognition to work?

Thanks in advance!


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>