Command-line Interface (CLI)

Command-line interface to the Dragonfly speech recognition framework

usage: python -m dragonfly [-h] {test,load,load-directory} ...

Positional Arguments

command Possible choices: test, load, load-directory

Sub-commands:

test

Load grammars from Python files for testing with a dragonfly engine. By default input from stdin is passed to engine.mimic() after command modules are loaded.

python -m dragonfly test [-h] [-e ENGINE] [-o ENGINE_OPTIONS]
                         [--language LANGUAGE] [-n] [-d DELAY]
                         [-l {DEBUG,INFO,WARNING,ERROR,CRITICAL}] [-q]
                         [file [file ...]]

Positional Arguments

file Command module file(s).

Named Arguments

-e, --engine

Name of the engine to use for testing.

Default: “text”

-o, --engine-options
 

One or more engine options to be passed to get_engine(). Each option should specify a key word argument and value. Multiple options should be separated by spaces or commas.

Default: {}

--language

Speaker language to use. Only applies if using an engine backend that supports changing the language (e.g. the “text” engine).

Default: “en”

-n, --no-input

Whether to load command modules and then exit without reading input from stdin or recognizing speech.

Default: False

-d, --delay

Time in seconds to delay before mimicking each command. This is useful for testing contexts.

Default: 0

-l, --log-level
 

Possible choices: DEBUG, INFO, WARNING, ERROR, CRITICAL

Log level to use.

Default: “INFO”

-q, --quiet

Equivalent to ‘-l WARNING’ – suppresses INFO and DEBUG logging.

Default: False

load

Load and recognize from command module files.

python -m dragonfly load [-h] [-e ENGINE] [-o ENGINE_OPTIONS]
                         [--language LANGUAGE] [-n] [--no-recobs-messages]
                         [-l {DEBUG,INFO,WARNING,ERROR,CRITICAL}] [-q]
                         [file [file ...]]

Positional Arguments

file Command module file(s).

Named Arguments

-e, --engine Name of the engine to use for loading and recognizing from command modules. By default, this is the first available engine backend.
-o, --engine-options
 

One or more engine options to be passed to get_engine(). Each option should specify a key word argument and value. Multiple options should be separated by spaces or commas.

Default: {}

--language

Speaker language to use. Only applies if using an engine backend that supports changing the language (e.g. the “text” engine).

Default: “en”

-n, --no-input

Whether to load command modules and then exit without reading input from stdin or recognizing speech.

Default: False

--no-recobs-messages
 

Disable recognition state messages for each spoken phrase.

Default: False

-l, --log-level
 

Possible choices: DEBUG, INFO, WARNING, ERROR, CRITICAL

Log level to use.

Default: “INFO”

-q, --quiet

Equivalent to ‘-l WARNING’ – suppresses INFO and DEBUG logging.

Default: False

load-directory

Load and recognize from command module files in a directory.

python -m dragonfly load-directory [-h] [-r] [-e ENGINE] [-o ENGINE_OPTIONS]
                                   [--language LANGUAGE] [-n]
                                   [--no-recobs-messages]
                                   [-l {DEBUG,INFO,WARNING,ERROR,CRITICAL}]
                                   [-q]
                                   module_dir

Positional Arguments

module_dir Directory with command module files.

Named Arguments

-r, --recursive
 

Whether to recursively load command modules in sub-directories.

Default: False

-e, --engine Name of the engine to use for loading and recognizing from command modules. By default, this is the first available engine backend.
-o, --engine-options
 

One or more engine options to be passed to get_engine(). Each option should specify a key word argument and value. Multiple options should be separated by spaces or commas.

Default: {}

--language

Speaker language to use. Only applies if using an engine backend that supports changing the language (e.g. the “text” engine).

Default: “en”

-n, --no-input

Whether to load command modules and then exit without reading input from stdin or recognizing speech.

Default: False

--no-recobs-messages
 

Disable recognition state messages for each spoken phrase.

Default: False

-l, --log-level
 

Possible choices: DEBUG, INFO, WARNING, ERROR, CRITICAL

Log level to use.

Default: “INFO”

-q, --quiet

Equivalent to ‘-l WARNING’ – suppresses INFO and DEBUG logging.

Default: False

Usage Examples

Below are some examples using each of the available sub-commands. All examples should work in Bash, PowerShell, cmd.exe, etc.

test examples

# Load a command module and mimic two commands separately.
echo "command one\n command two" | python -m dragonfly test module.py

# Same test without the pipe.
python -m dragonfly test module.py
command one
command two

# Same test with quieter output.
echo "command one\n command two" | python -m dragonfly test -q module.py

# Test loading two modules with the sphinx engine and exit without
# checking input.
python -m dragonfly test -e sphinx --no-input module1.py module2.py

# Load a command module with the text engine's language set to German.
python -m dragonfly test --language de module.py

# Use the --delay command to test context-dependent commands.
echo "save file" | python -m dragonfly test --delay 1 _notepad_example.py

load examples

# Load command modules and recognize speech in a loop using the default
# engine.
python -m dragonfly load _*.py

# Load command modules and exit afterwards.
python -m dragonfly load --no-input _*.py

# Load command modules and disable recognition state messages such as
# "Speech start detected".
python -m dragonfly load --no-recobs-messages _*.py

# Load one command module with the Sphinx engine.
python -m dragonfly load --engine sphinx sphinx_commands.py

# Initialize the Kaldi engine backend with custom arguments, then load
# command modules and recognize speech.
python -m dragonfly load _*.py --engine kaldi --engine-options " \
    model_dir=kaldi_model_zamia \
    vad_padding_end_ms=300"

load-directory examples

# Load command modules in the "command-modules" directory and recognize
# speech in a loop using the default engine.
python -m dragonfly load-directory command-modules

# Load command modules in the "command-modules" directory and any sub-
# directories, then recognize speech in a loop using the default engine.
python -m dragonfly load-directory -r command-modules
python -m dragonfly load-directory --recursive command-modules

# Load command modules in the "command-modules" directory and recognize
# speech without printing recognition state messages.
python -m dragonfly load-directory --no-recobs-messages command-modules

# Load command modules in the "wsr-modules" directory and recognize
# speech using the WSR/SAPI5 in-process engine backend.
python -m dragonfly load-directory -e sapi5inproc wsr-modules

# Initialize the Kaldi engine backend with some custom arguments, then
# load command modules in the current directory and recognize speech.
python -m dragonfly load-directory . --engine kaldi --engine-options " \
    model_dir=kaldi_model_zamia \
    vad_padding_end_ms=300"