Skip to main content

Official Python bindings for PocketSphinx

Project description

PocketSphinx 5.1.0rc2

This is PocketSphinx, one of Carnegie Mellon University's open source large vocabulary, speaker-independent continuous speech recognition engines.

Although this was at one point a research system, active development has largely ceased and it has become very, very far from the state of the art. I am making a release, because people are nonetheless using it, and there are a number of historical errors in the build system and API which needed to be corrected.

The version number is strangely large because there was a "release" that people are using called 5prealpha, and we will use proper semantic versioning from now on.

Please see the LICENSE file for terms of use.

Installation

You should be able to install this with pip for recent platforms and versions of Python:

pip3 install pocketsphinx

Alternately, you can also compile it from the source tree. I highly suggest doing this in a virtual environment (replace ~/ve_pocketsphinx with the virtual environment you wish to create), from the top level directory:

python3 -m venv ~/ve_pocketsphinx
. ~/ve_pocketsphinx/bin/activate
pip3 install .

On GNU/Linux and maybe other platforms, you must have PortAudio installed for the LiveSpeech class to work (we may add a fall-back to sox in the near future). On Debian-like systems this can be achieved by installing the libportaudio2 package:

sudo apt-get install libportaudio2

Usage

See the examples directory for a number of examples of using the library from Python. You can also read the documentation for the Python API or the C API.

It also mostly supports the same APIs as the previous pocketsphinx-python module, as described below.

LiveSpeech

An iterator class for continuous recognition or keyword search from a microphone. For example, to do speech-to-text with the default (some kind of US English) model:

from pocketsphinx import LiveSpeech
for phrase in LiveSpeech(): print(phrase)

Or to do keyword search:

from pocketsphinx import LiveSpeech

speech = LiveSpeech(keyphrase='forward', kws_threshold=1e-20)
for phrase in speech:
    print(phrase.segments(detailed=True))

With your model and dictionary:

import os
from pocketsphinx import LiveSpeech, get_model_path

speech = LiveSpeech(
    sampling_rate=16000,  # optional
    hmm=get_model_path('en-us'),
    lm=get_model_path('en-us.lm.bin'),
    dic=get_model_path('cmudict-en-us.dict')
)

for phrase in speech:
    print(phrase)

AudioFile

This is an iterator class for continuous recognition or keyword search from a file. Currently it supports only raw, single-channel, 16-bit PCM data in native byte order.

from pocketsphinx import AudioFile
for phrase in AudioFile("goforward.raw"): print(phrase) # => "go forward ten meters"

An example of a keyword search:

from pocketsphinx import AudioFile

audio = AudioFile("goforward.raw", keyphrase='forward', kws_threshold=1e-20)
for phrase in audio:
    print(phrase.segments(detailed=True)) # => "[('forward', -617, 63, 121)]"

With your model and dictionary:

import os
from pocketsphinx import AudioFile, get_model_path

model_path = get_model_path()

config = {
    'verbose': False,
    'audio_file': 'goforward.raw',
    'hmm': get_model_path('en-us'),
    'lm': get_model_path('en-us.lm.bin'),
    'dict': get_model_path('cmudict-en-us.dict')
}

audio = AudioFile(**config)
for phrase in audio:
    print(phrase)

Convert frame into time coordinates:

from pocketsphinx import AudioFile

# Frames per Second
fps = 100

for phrase in AudioFile(frate=fps):  # frate (default=100)
    print('-' * 28)
    print('| %5s |  %3s  |   %4s   |' % ('start', 'end', 'word'))
    print('-' * 28)
    for s in phrase.seg():
        print('| %4ss | %4ss | %8s |' % (s.start_frame / fps, s.end_frame / fps, s.word))
    print('-' * 28)

# ----------------------------
# | start |  end  |   word   |
# ----------------------------
# |  0.0s | 0.24s | <s>      |
# | 0.25s | 0.45s | <sil>    |
# | 0.46s | 0.63s | go       |
# | 0.64s | 1.16s | forward  |
# | 1.17s | 1.52s | ten      |
# | 1.53s | 2.11s | meters   |
# | 2.12s |  2.6s | </s>     |
# ----------------------------

Authors

PocketSphinx is ultimately based on Sphinx-II which in turn was based on some older systems at Carnegie Mellon University, which were released as free software under a BSD-like license thanks to the efforts of Kevin Lenzo. Much of the decoder in particular was written by Ravishankar Mosur (look for "rkm" in the comments), but various other people contributed as well, see the AUTHORS file for more details.

David Huggins-Daines (the author of this document) is guilty^H^H^H^H^Hresponsible for creating PocketSphinx which added various speed and memory optimizations, fixed-point computation, JSGF support, portability to various platforms, and a somewhat coherent API. He then disappeared for a while.

Nickolay Shmyrev took over maintenance for quite a long time afterwards, and a lot of code was contributed by Alexander Solovets, Vyacheslav Klimkov, and others. The pocketsphinx-python module was originally written by Dmitry Prazdnichnov.

Currently this is maintained by David Huggins-Daines again.

Project details


Download files

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

Source Distribution

pocketsphinx-5.1.0rc2.tar.gz (34.2 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pocketsphinx-5.1.0rc2-cp313-cp313-win_amd64.whl (29.0 MB view details)

Uploaded CPython 3.13Windows x86-64

pocketsphinx-5.1.0rc2-cp313-cp313-musllinux_1_2_x86_64.whl (29.2 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

pocketsphinx-5.1.0rc2-cp313-cp313-musllinux_1_2_aarch64.whl (29.1 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ ARM64

pocketsphinx-5.1.0rc2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (29.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pocketsphinx-5.1.0rc2-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (29.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

pocketsphinx-5.1.0rc2-cp313-cp313-macosx_10_13_universal2.whl (29.5 MB view details)

Uploaded CPython 3.13macOS 10.13+ universal2 (ARM64, x86-64)

pocketsphinx-5.1.0rc2-cp311-cp311-win_amd64.whl (29.0 MB view details)

Uploaded CPython 3.11Windows x86-64

pocketsphinx-5.1.0rc2-cp311-cp311-musllinux_1_2_x86_64.whl (29.2 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

pocketsphinx-5.1.0rc2-cp311-cp311-musllinux_1_2_aarch64.whl (29.1 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ ARM64

pocketsphinx-5.1.0rc2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (29.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pocketsphinx-5.1.0rc2-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (29.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

pocketsphinx-5.1.0rc2-cp311-cp311-macosx_10_9_universal2.whl (29.5 MB view details)

Uploaded CPython 3.11macOS 10.9+ universal2 (ARM64, x86-64)

File details

Details for the file pocketsphinx-5.1.0rc2.tar.gz.

File metadata

  • Download URL: pocketsphinx-5.1.0rc2.tar.gz
  • Upload date:
  • Size: 34.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for pocketsphinx-5.1.0rc2.tar.gz
Algorithm Hash digest
SHA256 2b3767435041e017b4a64b30cfe75713922675199131ccfdf263cc605ee0b3ef
MD5 a1a42de283c21087f6372425e4b9aecf
BLAKE2b-256 7a091fb7cabb3ccd2e32c8d24d5b120c0d0096007677bb287569c272bcc36a82

See more details on using hashes here.

Provenance

The following attestation bundles were made for pocketsphinx-5.1.0rc2.tar.gz:

Publisher: release.yml on cmusphinx/pocketsphinx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pocketsphinx-5.1.0rc2-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for pocketsphinx-5.1.0rc2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 670ccbc517413a45f8486741593f5ad47f561997d206d47e3405a687a15b353b
MD5 cd503cfb68fba5a0bb189e46aaa0a1de
BLAKE2b-256 8e02be93f075ef6178b1d1a127bce19a4cca96abbe21ea55d58a25c7d4d33a05

See more details on using hashes here.

Provenance

The following attestation bundles were made for pocketsphinx-5.1.0rc2-cp313-cp313-win_amd64.whl:

Publisher: release.yml on cmusphinx/pocketsphinx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pocketsphinx-5.1.0rc2-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pocketsphinx-5.1.0rc2-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 6cd4e7bfefb91b8eb1cfee684f95629d2160cb94e1e292e8574e9af296303e19
MD5 11fd55a8946cb47906f3c4114b99dc12
BLAKE2b-256 c2522a752235fe01cfa6ff8dfaa4a3d1b6b509c76115bc647709b99a61233012

See more details on using hashes here.

Provenance

The following attestation bundles were made for pocketsphinx-5.1.0rc2-cp313-cp313-musllinux_1_2_x86_64.whl:

Publisher: release.yml on cmusphinx/pocketsphinx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pocketsphinx-5.1.0rc2-cp313-cp313-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pocketsphinx-5.1.0rc2-cp313-cp313-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 80763a8164839a1bd99826cb5389498e6312207e8f1ba7bd8d3e04a45d805b96
MD5 647416758db1ad1bf52dbc0aafa8aec1
BLAKE2b-256 d3931af922d16601deb5e71bd77b465e47fd37d9c7c026951dc5c86f325d01f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for pocketsphinx-5.1.0rc2-cp313-cp313-musllinux_1_2_aarch64.whl:

Publisher: release.yml on cmusphinx/pocketsphinx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pocketsphinx-5.1.0rc2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pocketsphinx-5.1.0rc2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 cdb08ac8167456c2ef2e5fd3b0cc3022f1a0ce9b190cdae662c0d34bd0a7a8cd
MD5 a21d90ead27f3675ec35657017cca15c
BLAKE2b-256 a61c41377fbf26952b16272d25c190e407ec503576353c2ebd7a299543e5d021

See more details on using hashes here.

Provenance

The following attestation bundles were made for pocketsphinx-5.1.0rc2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on cmusphinx/pocketsphinx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pocketsphinx-5.1.0rc2-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pocketsphinx-5.1.0rc2-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f69a1e27085fd53149cb40e06000fcff0de6e7d03eb64dd2f73a8bbe72798857
MD5 59a547cd697f28054e40774f36ecf3c8
BLAKE2b-256 20cfd167d9d2808f00f8d05326ed487f8d722bb31cf7ab81bd9fc2f0e4a18862

See more details on using hashes here.

Provenance

The following attestation bundles were made for pocketsphinx-5.1.0rc2-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl:

Publisher: release.yml on cmusphinx/pocketsphinx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pocketsphinx-5.1.0rc2-cp313-cp313-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for pocketsphinx-5.1.0rc2-cp313-cp313-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 5bbe730e255b1621dc22495ee985effad09cd0205c678a8e06ac6e7065ac353c
MD5 827a87fc25a143943563f1822e15d1e2
BLAKE2b-256 5ba0a330e3ac8faa57f3be5c9037bdc842b7c5eaf9c167c2fa628f5bfd95d46f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pocketsphinx-5.1.0rc2-cp313-cp313-macosx_10_13_universal2.whl:

Publisher: release.yml on cmusphinx/pocketsphinx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pocketsphinx-5.1.0rc2-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for pocketsphinx-5.1.0rc2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 6ca3dcb46eb66477d8660f431c448d7fb15235b63a5d73ff78e0c7cdb0c97060
MD5 bf5f4ef96bfadfef7554982236d026e5
BLAKE2b-256 64597885647f82e7e342b5d3c823840df6fa92a24eb64d0d288a71aace8e517a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pocketsphinx-5.1.0rc2-cp311-cp311-win_amd64.whl:

Publisher: release.yml on cmusphinx/pocketsphinx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pocketsphinx-5.1.0rc2-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pocketsphinx-5.1.0rc2-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 481cbcb5c3e6e1bf2c7d529e31636bf84d43093c7b62ac525daffc83e37913c9
MD5 4539c18109dcc4b4dc9ae90aca8ab162
BLAKE2b-256 520dad9cb101e83f471a2be358da9b477f200a35c2bb2345f249918b935678fd

See more details on using hashes here.

Provenance

The following attestation bundles were made for pocketsphinx-5.1.0rc2-cp311-cp311-musllinux_1_2_x86_64.whl:

Publisher: release.yml on cmusphinx/pocketsphinx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pocketsphinx-5.1.0rc2-cp311-cp311-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pocketsphinx-5.1.0rc2-cp311-cp311-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 8e893689298842d9029bf1b8a6d2bae170f3026f6d2ab964b2e45a44bebbd7b0
MD5 cc46716abf6741d57cade15b67729614
BLAKE2b-256 27695c130d9e8963421522db72dfd19ab0e6e2900e16577268b1acb58c450057

See more details on using hashes here.

Provenance

The following attestation bundles were made for pocketsphinx-5.1.0rc2-cp311-cp311-musllinux_1_2_aarch64.whl:

Publisher: release.yml on cmusphinx/pocketsphinx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pocketsphinx-5.1.0rc2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pocketsphinx-5.1.0rc2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ae79242a54ee87c79f8355fec302ed13dd93e2afcf532f211b2c0e14ce3a12dd
MD5 976e42b6d6e27c488a56f132b207708a
BLAKE2b-256 b3d3526e1e834ea1f2d4f75f6bba7cfc951235cff5a1ca0eea4f8c85436e2540

See more details on using hashes here.

Provenance

The following attestation bundles were made for pocketsphinx-5.1.0rc2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on cmusphinx/pocketsphinx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pocketsphinx-5.1.0rc2-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pocketsphinx-5.1.0rc2-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f363aa21d8b07aca9542dacff36a1f2765d1d6e23596ac30a9a93a8f6c24b10f
MD5 027f5db4e9f214d34e320a24ab21c98c
BLAKE2b-256 b78ce1742755f0099a727e838c6519134fdf0f87f3e26260fc6c75fc858b3d56

See more details on using hashes here.

Provenance

The following attestation bundles were made for pocketsphinx-5.1.0rc2-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl:

Publisher: release.yml on cmusphinx/pocketsphinx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pocketsphinx-5.1.0rc2-cp311-cp311-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for pocketsphinx-5.1.0rc2-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 f5a26093e2a28bcbda35625ed62f93e74987088382f7da9986a0607ae1208739
MD5 fc699a9578cdf0bec8610f4dbedf7dfa
BLAKE2b-256 5b767c7717cfa2e678f5d78098c126685c33e0ed25436c8a716c2027577f11e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pocketsphinx-5.1.0rc2-cp311-cp311-macosx_10_9_universal2.whl:

Publisher: release.yml on cmusphinx/pocketsphinx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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