Skip to main content

Kaldi speech recognition with grammars that can be set active/inactive dynamically at decode-time

Project description

Kaldi Active Grammar

Python Kaldi speech recognition with grammars that can be set active/inactive dynamically at decode-time

PyPI - Status PyPI - Version PyPI - Python Version PyPI - Wheel PyPI - Downloads Batteries-Included

Python package developed to enable context-based command & control of computer applications, as in the Dragonfly speech recognition framework, using the Kaldi automatic speech recognition engine.

UNDER ACTIVE DEVELOPMENT

Normally, Kaldi decoding graphs are monolithic, require expensive up-front off-line compilation, and are static during decoding. Kaldi's new grammar framework allows multiple independent grammars with nonterminals, to be compiled separately and stitched together dynamically at decode-time, but all the grammars are always active and capable of being recognized.

This project extends that to allow each grammar/rule to be independently marked as active/inactive dynamically on a per-utterance basis (set at the beginning of each utterance). Dragonfly is then capable of activating only the appropriate grammars for the current environment, resulting in increased accuracy due to fewer possible recognitions. Furthermore, the dictation grammar can be shared between all the command grammars, which can be compiled quickly without needing to include large-vocabulary dictation directly.

  • The Python package includes all necessary binaries for decoding on Linux or Windows. Available on PyPI.
  • A compatible general English Kaldi nnet3 chain model is trained on ~1200 hours of open audio. Available under project releases.
  • A compatible backend for Dragonfly is under development in the kaldi branch of my fork.
    • You can try it out easily on Windows using a simple no-install package: see Getting Started below.
    • A beta version has been merged as of Dragonfly v0.15.0!
    • Support for KaldiAG v0.5.0 has been merged as of Dragonfly v0.16.0!
      • User Lexicon: you can add new words/pronunciations to the model's lexicon to be recognized & used in grammars, and the pronunciations can be either specified explicitly or inferred automatically.
      • Compilation Optimizations: compilation while loading grammars uses the disk much less, and far fewer passes are made over the graphs, as separate modules have been customized & combined.
      • Better Model: 50% more training data.
    • Support for KaldiAG v0.6.0 has been merged as of Dragonfly v0.16.1!
      • Caster: many big fixes and optimizations to get Caster running.

Donations are appreciated to encourage development.

Donate Donate

Getting Started

Want to get started quickly & easily on Windows? Available under project releases:

  • kaldi-dragonfly-winpython: A self-contained, portable, batteries-included (python & libraries & model) distribution of kaldi-active-grammar + dragonfly2. Just unzip and run!
  • kaldi-dragonfly-winpython-dev: [more recent development version] A self-contained, portable, batteries-included (python & libraries & model) distribution of kaldi-active-grammar + dragonfly2. Just unzip and run!
  • kaldi-caster-winpython-dev: [more recent development version] A self-contained, portable, batteries-included (python & libraries & model) distribution of kaldi-active-grammar + dragonfly2 + caster. Just unzip and run!

Otherwise...

Setup

Requirements:

  • Python 2.7 (3.x support planned); 64-bit required!
    • Microphone support provided by pyaudio package
  • OS: Linux or Windows; macOS planned if there is interest
  • Only supports Kaldi left-biphone models, specifically nnet3 chain models, with specific modifications
  • ~1GB+ disk space for model plus temporary storage and cache, depending on your grammar complexity
  • ~500MB+ RAM for model and grammars, depending on your model and grammar complexity

Install Python package, which includes necessary Kaldi binaries:

pip install kaldi-active-grammar

Download compatible generic English Kaldi nnet3 chain model from project releases. Unzip the model and pass the directory path to kaldi-active-grammar constructor.

Or use your own model. Standard Kaldi models must be converted to be usable. Conversion can be performed automatically, but this hasn't been fully implemented yet.

Troubleshooting

  • Errors installing
    • Make sure you're using a 64-bit Python.
    • Update your pip by executing pip install --upgrade pip.

Documentation

Documentation is sorely lacking currently. To see example usage, examine the backend for Dragonfly.

Contributing

Issues, suggestions, and feature requests are welcome & encouraged. Pull requests are considered, but project structure is in flux.

Donations are appreciated to encourage development.

Donate Donate

Author

License

This project is licensed under the GNU Affero General Public License v3 (AGPL-3.0), with the exception of the associated binaries, whose source is currently unreleased and which are only to be used by this project. See the LICENSE.txt file for details.

If this license is problematic for you, please contact me.

Acknowledgments

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

kaldi_active_grammar-0.7.2-py2.py3-none-win_amd64.whl (31.9 MB view hashes)

Uploaded Python 2 Python 3 Windows x86-64

kaldi_active_grammar-0.7.2-py2.py3-none-manylinux2010_x86_64.whl (27.2 MB view hashes)

Uploaded Python 2 Python 3 manylinux: glibc 2.12+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page