0
votes

I'm trying to use several grammars for a Speech Recognition in C# and I want to disable them in certain cases.

My problem is that if I disable them nothing changes, here's a part of my code:

recognizer.LoadGrammar(g_init);
recognizer.LoadGrammar(g_menu);
recognizer.LoadGrammar(g_timer);
recognizer.LoadGrammar(g_say);

recognizer.Grammars[recognizer.Grammars.IndexOf(g_menu)].Enabled = false;
recognizer.Grammars[recognizer.Grammars.IndexOf(g_timer)].Enabled = false;
recognizer.Grammars[recognizer.Grammars.IndexOf(g_say)].Enabled = false;

Here I want to disable the init grammar and enable the menu grammar

recognizer.Grammars[recognizer.Grammars.IndexOf(g_init)].Enabled = false;
recognizer.Grammars[recognizer.Grammars.IndexOf(g_menu)].Enabled = true;

I want to know how to disable grammars and enable them in a later stage

1

1 Answers

1
votes

Grammar objects have an Enabled property that you can manipulate directly. However, you may also need to synchronize the recognizer after updating the grammars.

So:

g_init.Enabled = false;
recognizer.RequestRecognizerUpdate();