Engines sub-package

Dragonfly supports multiple speech recognition engines as its backend. The engines sub-package implements the interface code for each supported engine.

Main SR engine back-end interface

get_current_engine()[source]

Get the currently initialized SR engine object.

If an SR engine has not been initialized yet, None will be returned instead.

Return type:EngineBase | None
Returns:engine object or None

Usage example:

# Print the name of the current engine if one has been
# initialized.
from dragonfly import get_current_engine
engine = get_current_engine()
if engine:
    print("Engine name: %r" % engine.name)
else:
    print("No engine has been initialized.")
get_engine(name=None, **kwargs)[source]

Get the engine implementation.

This function will initialize an engine object using the get_engine and is_engine_available functions in the engine packages and return an instance of the first available engine. If one has already been initialized, it will be returned instead.

Parameters:
  • name (str) – optional human-readable name of the engine to return.
  • **kwargs – optional keyword arguments passed through to the engine for engine-specific configuration.
Return type:

EngineBase

Returns:

engine object

Raises:

EngineError

register_engine_init(engine)[source]

Register initialization of an engine.

This function sets the default engine to the first engine initialized.