简体   繁体   中英

How to switch context in Dragonfly

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, ie 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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM