1

I have tried the Python module for handling speech recognition Dragonfly and successfully run notepad example with Windows speech recognition. Now I would like to try something more general, but I cannot find how contexts are switched, i.e. grammars loaded. There are always lines like:

grammar = Grammar("Eclipse", context=DynamicContext(winContext, nixContext))
grammar.add_rule(rules)
grammar.load()

But the context is always tied to an executable or window title. How do I switch between grammars at will, like a word command or at least mouse click, key press?

Ryan
  • 2,167
  • 2
  • 28
  • 33
comodoro
  • 1,489
  • 1
  • 19
  • 30

1 Answers1

0

Create a rule which calls a function which does this:

grammar.disable()
other_grammar.enable()

Have a look at grammar_base.py for other relevant functions.

synkarius
  • 324
  • 1
  • 8
  • Answer accepted with reservations, this is working, but I am not sure if explicit enabling and disabling grammars is always viable – comodoro Jan 18 '17 at 17:14