Speech recognition extension library
Project description
Dragonfly is a speech recognition framework. It is a Python package which offers a high-level object model and allows its users to easily write scripts, macros, and programs which use speech recognition. This is a fork of the original t4ngo/dragonfly project.
It currently supports the following speech recognition engines:
Dragon NaturallySpeaking (DNS), a product of Nuance
Windows Speech Recognition (WSR), included with Microsoft Windows Vista, Windows 7+, and freely available for Windows XP
Kaldi (under development)
CMU Pocket Sphinx (with caveats)
Dragonfly’s documentation is available online at Read the Docs. The changes in each release are listed in the project’s changelog. Dragonfly’s FAQ is available at Stackoverflow. Dragonfly’s mailing list/discussion group is available at Google Groups.
There are also bridged Gitter and Matrix channels:
Installation
Dragonfly is a Python package. It can be installed as dragonfly2 using pip:
pip install dragonfly2
The distribution name has been changed to dragonfly2 in order to
upload releases to PyPI.org, but everything can still be imported using
dragonfly. If you use any grammar modules that include something like
pkg_resources.require("dragonfly >= 0.6.5")
, you will need to either
replace dragonfly
with dragonfly2
or remove lines like this
altogether.
If you are installing this on X11/Linux, you will also need to install the xdotool program for the Key and Text actions to work.
If you have dragonfly installed under the original dragonfly distribution name, you’ll need to remove the old version using:
pip uninstall dragonfly
Dragonfly can also be installed by cloning this repository or downloading it from the releases page and running the following (or similar) command in the project’s root directory:
python setup.py install
To use the CMU Pocket Sphinx engine, see the relevant documentation page on it.
If pip fails to install dragonfly2 or any of its required or extra dependencies, then you may need to upgrade pip with the following command:
pip install --upgrade pip
Features
Dragonfly was written to make it very easy for Python macros, scripts, and applications to interface with speech recognition engines. Its design allows speech commands and grammar objects to be treated as first-class Python objects. This allows easy and intuitive definition of complex command grammars and greatly simplifies processing recognition results.
Existing command modules
The related resources page of Dragonfly’s documentation has a section on command modules which lists various sources.
Usage example
A very simple example of Dragonfly usage is to create a static voice command with a callback that will be called when the command is spoken. This is done as follows:
from dragonfly import Grammar, CompoundRule
# Voice command rule combining spoken form and recognition processing.
class ExampleRule(CompoundRule):
spec = "do something computer" # Spoken form of command.
def _process_recognition(self, node, extras): # Callback when command is spoken.
print("Voice command spoken.")
# Create a grammar which contains and loads the command rule.
grammar = Grammar("example grammar") # Create a grammar to contain the command rule.
grammar.add_rule(ExampleRule()) # Add the command rule to the grammar.
grammar.load() # Load the grammar.
The example above is very basic and doesn’t show any of Dragonfly’s exciting features, such as dynamic speech elements. To learn more about these, please take a look at Dragonfly’s online docs.
Rationale behind Dragonfly
Dragonfly offers a powerful and unified interface to developers who want to use speech recognition in their software. It is used for both speech-enabling applications and for automating computer activities.
In the field of scripting and automation, there are other alternatives available that add speech-commands to increase efficiency. Dragonfly differs from them in that it is a powerful development platform. The open source alternatives currently available for use with DNS are compared to Dragonfly as follows:
Vocola uses its own easy-to-use scripting language, whereas Dragonfly uses Python and gives the macro-writer all the power available.
Unimacro offers a set of macros for common activities, whereas Dragonfly is a platform on which macro-writers can easily build new commands.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for dragonfly2-0.18.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | db633ae25cc7992e4154582a3b1b18570c69569e5eb8393faebd5d0a4bfec8e1 |
|
MD5 | adcef86a243b87a80052952562bee563 |
|
BLAKE2b-256 | 7b30ee87a2641da24e3466f4684eb033031d08d528a5379063792aaccedd66dd |