How to switch context in Dragonfly
<p>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:</p>

<pre><code>grammar = Grammar("Eclipse", context=DynamicContext(winContext, nixContext))
grammar.add_rule(rules)
grammar.load()
</code></pre>

<p>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?</p>

<p>Create a rule which calls a function which does this:</p>

<pre><code>grammar.disable()
other_grammar.enable()
</code></pre>

<p>Have a look at <code>grammar_base.py</code> for other relevant functions.</p>

python python-dragonfly