An even smaller speech recognizer
Project description
SoundSwallower: an even smaller speech recognizer
"Time and change have a voice; eternity is silent. The human ear is always searching for one or the other."
Leena Krohn, Datura, or a delusion we all see
SoundSwallower is a refactored version of PocketSphinx intended primarily for embedding in web applications. The goal is not to provide a fast implementation of large-vocabulary continuous speech recognition, but rather to provide a small implementation of simple, useful speech technologies.
With that in mind the current version is limited to finite-state grammar recognition. In addition, the eternally problematic and badly-designed audio library as well as all other external dependencies have been removed.
Compiling SoundSwallower
Currently SoundSwallower can be built in several different ways. To build the C shared library, run CMake in the standard way:
mkdir build
cd build
cmake ..
make
make test
make install
Note that this isn't terribly useful as there is no command-line frontend. You probably want to target JavaScript or Python.
Installing the Python module and CLI
The SoundSwallower command-line is a Python module
(soundswallower.cli) and can be installed using setup.py
or pip
.
It is highly recommended to do this in a virtualenv
. You can simply
install it from PyPI:
pip install soundswallower
Or compile from source:
pip install .
For development, you can install it in-place, but please make sure to remove any existing global installation:
pip uninstall soundswallower
python setup.py develop
The command-line supports JSGF grammars and word-level force alignment for one or more input files, for example:
soundswallower --align tests/data/goforward.txt tests/data/goforward.wav
soundswallower --align-text "go forward ten meters" tests/data/goforward.wav
soundswallower --grammar tests/data/goforward.gram tests/data/goforward.wav
Note that multiple input files are not particularly useful for
--align
or --align-text
as they will simply (try to) align the
same text to each file. The output results (a list of time-aligned
words) can be written to a JSON file with --output
.
Compiling to JavaScript/WebAssembly
To build the JavaScript library, use CMake with Emscripten:
mkdir jsbuild
cd jsbuild
emcmake cmake ..
emmake make
This will create js/soundswallower.js
and js/soundswallower.wasm
in the jsbuild
directory, which you can then include in your
projects. It will also set up this directory to run a trivial demo
application, which you can launch with server.py
, and access at
http://localhost:8000. It seems to work
fine with recent versions of Chrome, Firefox, and Edge.
For more details on JavaScript, see js/README.js.
Creating binary distributions for Python
To build the Python extension, I suggest using pip, as it will install the build dependencies:
pip wheel .
In all cases the resulting binary is self-contained and should not need any other components aside from the system libraries. To create wheels that are compatible with multiple Linux distributions, see the instructions in README.manylinux.md.
Compiling on Windows in Visual Studio Code
The method for building distributions noted above will also work on Windows, from within a Conda environment, provided you have Visual Studio or the Visual Studio Build Tools installed. This is somewhat magic.
If you don't have Conda, then what you will need to do is:
-
Install Visual Studio build tools. Unfortunately, a direct link does not seem to exist, but you can find them under Microsoft's downloads page. The 2019 version is probably the optimal one to use as it is compatible with all recent versions of Windows.
-
Install the version of Python you wish to use.
-
Launch the Visual Studio command-line prompt from the Start menu. Note that if your Python is 64-bit (recommended), you must be sure to launch the "x64 Native Command Line Prompt".
-
Create and activate a virtual environment using your Python binary, which may or may not be in your AppData directory:
%USERPROFILE%\AppData\Local\Programs\Python\Python310\python -m venv py310 py310\scripts\activate
-
now you can build wheels with pip, using the same method mentioned above.
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 Distributions
Hashes for soundswallower-0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44750eba201a19e1ae9aa2ea0a761f885a26498211d8333de9b6e5b960cb1751 |
|
MD5 | 20adadd586036f02669b6a4d372597ee |
|
BLAKE2b-256 | c6ab852c520a616e6a4475fda7b9d377464a2dbf0ca5b89da0860bc7c4b74f07 |
Hashes for soundswallower-0.2-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 576729b6b2d233961a6279fe2b2ecedf18bf16d192df8cd029667fbdfa7a59fb |
|
MD5 | c3d9f30f14660fe2882588045a2d048b |
|
BLAKE2b-256 | c2bccac2944e5c6c7ba14a9d3dbfca7a7b865d3901cefc1de132058e3096f139 |
Hashes for soundswallower-0.2-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 115664606b3ae4d36276f1a65cd5f3aae2e998b2126b74a1f58e00e45ee4d19a |
|
MD5 | 8d55129d27aedc1499a821c226aafabc |
|
BLAKE2b-256 | 97fb52b2312ec5fbcb7c560aa952510766fff32a8423ca1f610227bd538fccd7 |
Hashes for soundswallower-0.2-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47b367fec452203fc5510845766b08818b2a42e12d04d9cb6996c23a450cbbef |
|
MD5 | 02a2b3f74ddc8b9c2af0f4114e3c2634 |
|
BLAKE2b-256 | fcb7df55e3565eb04e9ad888de8182c8c107484893d8188cb28f0e70752dc85a |