Text-input engine back-end¶
The text-input engine is a convenient, always available implementation
designed to be used via the
To initialise the text-input engine, do the following:
dragonfly.engines.get_engine() called without
will never initialise the text-input engine. This is because real speech
recognition backends should be returned from the function by default.
All dragonfly elements and rule classes should be supported. Use all
uppercase words to mimic input for
Dictation elements, e.g.
“find SOME TEXT” to match the dragonfly spec “find <text>”.
executable, title, and handle keyword arguments may optionally be
engine.mimic() to simulate a particular foreground window.
Dragonfly’s command-line interface can be used to test command modules with the text-input engine. Below are a few use cases for this engine:
# Example 1: # Initialize the text-input engine back-end, load a command module and # recognize from stdin. echo "hello world" | python -m dragonfly test _module1.py # Example 2: # Initialize the text-input engine back-end and load a command module # for browser commands and recognize from stdin with a processing delay # of 2 seconds. This allows testing context-specific browser commands. python -m dragonfly test _browser.py --delay 2 # Example 3: # Initialize the text-input engine back-end using German (de) as the # language, then load a command module and recognize from stdin. python -m dragonfly test _german_commands.py --language de
Text-input Engine class.
Connect to back-end SR engine.
create_timer(callback, interval, repeating=True)¶
Create and return a timer using the specified callback and repeat interval.
Timers created using this engine will be run in a separate daemon thread, meaning that their callbacks will not be thread safe.
threading.Timer()may be used instead with no blocking issues.
Disconnect from back-end SR engine.
Current user language of the SR engine.
Return type: str
Mimic a recognition of the given words.
Parameters: words (str|iter) – words to mimic Keyword Arguments: optional executable, title and/or handle keyword arguments may be used to simulate a specific foreground window context. The current foreground window attributes will be used instead for any keyword arguments not present.
Any dictation words should be all uppercase, e.g. “HELLO WORLD”. Dictation words not in uppercase will result in the engine not decoding and recognizing the command!
Set the exclusiveness of a grammar.
Speak the given text using text-to-speech.