Skip to main content

Official Python bindings for PocketSphinx

Project description

PocketSphinx 5.0.3

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.0.3.tar.gz (34.1 MB view details)

Uploaded Source

Built Distributions

pocketsphinx-5.0.3-pp310-pypy310_pp73-win_amd64.whl (29.1 MB view details)

Uploaded PyPy Windows x86-64

pocketsphinx-5.0.3-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (29.2 MB view details)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

pocketsphinx-5.0.3-pp310-pypy310_pp73-macosx_10_9_x86_64.whl (29.1 MB view details)

Uploaded PyPy macOS 10.9+ x86-64

pocketsphinx-5.0.3-cp312-cp312-win_amd64.whl (29.1 MB view details)

Uploaded CPython 3.12 Windows x86-64

pocketsphinx-5.0.3-cp312-cp312-musllinux_1_1_x86_64.whl (29.2 MB view details)

Uploaded CPython 3.12 musllinux: musl 1.1+ x86-64

pocketsphinx-5.0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (29.2 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

pocketsphinx-5.0.3-cp312-cp312-macosx_10_9_universal2.whl (29.6 MB view details)

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

pocketsphinx-5.0.3-cp311-cp311-win_amd64.whl (29.1 MB view details)

Uploaded CPython 3.11 Windows x86-64

pocketsphinx-5.0.3-cp311-cp311-musllinux_1_1_x86_64.whl (29.2 MB view details)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

pocketsphinx-5.0.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (29.2 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pocketsphinx-5.0.3-cp311-cp311-macosx_10_9_universal2.whl (29.6 MB view details)

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

pocketsphinx-5.0.3-cp310-cp310-win_amd64.whl (29.1 MB view details)

Uploaded CPython 3.10 Windows x86-64

pocketsphinx-5.0.3-cp310-cp310-musllinux_1_1_x86_64.whl (29.2 MB view details)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

pocketsphinx-5.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (29.2 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pocketsphinx-5.0.3-cp310-cp310-macosx_10_9_universal2.whl (29.6 MB view details)

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

pocketsphinx-5.0.3-cp38-cp38-win_amd64.whl (29.1 MB view details)

Uploaded CPython 3.8 Windows x86-64

pocketsphinx-5.0.3-cp38-cp38-musllinux_1_1_x86_64.whl (29.2 MB view details)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

pocketsphinx-5.0.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (29.2 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pocketsphinx-5.0.3-cp38-cp38-macosx_10_9_universal2.whl (29.6 MB view details)

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

File details

Details for the file pocketsphinx-5.0.3.tar.gz.

File metadata

  • Download URL: pocketsphinx-5.0.3.tar.gz
  • Upload date:
  • Size: 34.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for pocketsphinx-5.0.3.tar.gz
Algorithm Hash digest
SHA256 27f4de0ca2d2bce391ce87eaab84fe6f0bc059b306fd1702d5fe6549b66e1586
MD5 a6c68727e84bf1fc2901aa22962d9f57
BLAKE2b-256 dbd88147df2687a14eb87bfc0e8c2eb921bc4c29d2c6568e1bb08fdd2e2d1471

See more details on using hashes here.

File details

Details for the file pocketsphinx-5.0.3-pp310-pypy310_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for pocketsphinx-5.0.3-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 f6b4ef1c1fa0ac19650143b5d8045bbf2dffadffea2390306daba090f323b13d
MD5 9adc55950d5608e74c2295dc57a04f61
BLAKE2b-256 8f47a8c899cd825ea41ae1392c7a8ebecd4897322ba5aec25200eb399f238e5e

See more details on using hashes here.

File details

Details for the file pocketsphinx-5.0.3-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pocketsphinx-5.0.3-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5474311a36d2a8b52b8ae2d9ced4da2eae4e6ef60010268983b1ba6a2c5eae9d
MD5 fe19fcca00def3ee3d35f42e4e2c7d72
BLAKE2b-256 92745135f7433ab3967532ce9aeabcdd28d91150bb2801224f45a2563e3ad3ff

See more details on using hashes here.

File details

Details for the file pocketsphinx-5.0.3-pp310-pypy310_pp73-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pocketsphinx-5.0.3-pp310-pypy310_pp73-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 392ec249b59c30f9fe3d18bf64c2f2b516ebfe8c5d6009423ca3a04acf8aee6e
MD5 398dd34f3d16d15685a39bb1ec7701a6
BLAKE2b-256 121abffea9cd0ef8532b5e9119e61825e25e2bbab37c0da3fab196c56780e0ef

See more details on using hashes here.

File details

Details for the file pocketsphinx-5.0.3-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pocketsphinx-5.0.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c3db250ca75d4c0e248915d0bc7d9fd51827b3989f4def3e44efaa177858cc79
MD5 9cf7c660bfe239348b1e4bb8ccb29cd6
BLAKE2b-256 18f2ba108f8a8181267939c9e65c43399abf968da0c746c031eb34e701ac1091

See more details on using hashes here.

File details

Details for the file pocketsphinx-5.0.3-cp312-cp312-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for pocketsphinx-5.0.3-cp312-cp312-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 edfae56aaa606d57f01fb79bb081d8e9e40660cd7673a44aa66ad774e43be6e9
MD5 c8a90d1b91c6bef5ee0289e922b40d80
BLAKE2b-256 c47e95b5c13174b17a9e8c9b9d34c9a9d2b443f2bd23957a7f9d06e22f5d864c

See more details on using hashes here.

File details

Details for the file pocketsphinx-5.0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pocketsphinx-5.0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9e25199d0b221bcef20c965cf06a9bf73abbee8502854a981bea8acd4500fc54
MD5 9e482a4db717c34a56324ac15e01f8e6
BLAKE2b-256 5c4d01e27059d82f31ccbbe109984b6ebab1c37c42e1e0124bcef70a44fa31a5

See more details on using hashes here.

File details

Details for the file pocketsphinx-5.0.3-cp312-cp312-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for pocketsphinx-5.0.3-cp312-cp312-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 59a42e5d62a2bca2ff9578d0647cadb15af55fc60d5229239f1244e014684b6b
MD5 b5f26228eee288d0b00807f38f1b11ef
BLAKE2b-256 be9c47051f5dad827ded56d61d89f20cc14c8e72fcbac869511d46b2fd1f46db

See more details on using hashes here.

File details

Details for the file pocketsphinx-5.0.3-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for pocketsphinx-5.0.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 32b1dcceb36aebeea0d38634619c70f4881f5fa721ebb9105a24048a00dbef5f
MD5 0db4db6e82a613bb38105d7bb31fdb4a
BLAKE2b-256 12c0525628542371625d05314efe4ecdadfba51d783b21bc2af2357ac24dc2ce

See more details on using hashes here.

File details

Details for the file pocketsphinx-5.0.3-cp311-cp311-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for pocketsphinx-5.0.3-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 9f76487907381b7d12b8fa93f9fed06b6b28e40c41383cb7ed880d1d0c4a1bfb
MD5 ee316bd64e4acd1fe0efd0bc79ba350b
BLAKE2b-256 6d89fdc56381250dd1c5fa0dd101416d58a972a153a41f35d6d32760febb046f

See more details on using hashes here.

File details

Details for the file pocketsphinx-5.0.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pocketsphinx-5.0.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f91bf9f6b26181ac8b8e3e856bf996cdd4908fb70db0c2dab03ed0af13f6178b
MD5 856f9f6886b77ce52f2f82f7f090e151
BLAKE2b-256 d4b025140c353ee44833c9b34ac58295ec38a14a5aa58dbfd9892ef4a48d647d

See more details on using hashes here.

File details

Details for the file pocketsphinx-5.0.3-cp311-cp311-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for pocketsphinx-5.0.3-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 2cd9ac5204e85c1465af410928bba25dfbd31a26b999cda3285b29a5eb06254c
MD5 31b8c31ada541fc2b4e1e1799394eed6
BLAKE2b-256 a580dc18686f49389f97270b0ba9022ca53417f352e3b2426761fb8e2d56ab5a

See more details on using hashes here.

File details

Details for the file pocketsphinx-5.0.3-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for pocketsphinx-5.0.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 2c80082bf04a83a4e6cc252fd2ee0cd826d4b90f843038e2187e719a9a8e9dd0
MD5 8d7283b66344c43ab9ae6d87e406accf
BLAKE2b-256 ebbcf31673ccd67ba5a11f053469e58cfd0e08944b2d970fb6019c2f854ee05c

See more details on using hashes here.

File details

Details for the file pocketsphinx-5.0.3-cp310-cp310-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for pocketsphinx-5.0.3-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 208d78d2b0939b07d8851d0fba9b0b7656f9f3176a441a061410adff918548b9
MD5 8a743cb4e930c470bf2d92199d5e4697
BLAKE2b-256 9b7c0fdaed06391a8a4b9669349598a8ec54e52619c81992db9c4254d014f9a3

See more details on using hashes here.

File details

Details for the file pocketsphinx-5.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pocketsphinx-5.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f1a3203dc05d5bc7c5c90748039cc1681296988f5eb318a89f9e585d35f3f765
MD5 1e055751012b20bd4c50e1882db422d9
BLAKE2b-256 e5cf8a246a0cad84cad978127aba248336640713c7e36257170acc0b53301f74

See more details on using hashes here.

File details

Details for the file pocketsphinx-5.0.3-cp310-cp310-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for pocketsphinx-5.0.3-cp310-cp310-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 76c4cb1e70ab76c40e6af8081e6a73f5fd26d7e19709783043c0dcdb39e243a1
MD5 cec29545da8e12329a5bf3867856358b
BLAKE2b-256 b9c02c6fd78b719447f4aea0fef3e0a2898e2556ea2f902dde9b0ee2541d0bce

See more details on using hashes here.

File details

Details for the file pocketsphinx-5.0.3-cp38-cp38-win_amd64.whl.

File metadata

File hashes

Hashes for pocketsphinx-5.0.3-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 19f06c4cff0472e05b5d79651b6875c3f601ee48d1b880ad3ac5635258565d99
MD5 1be09269bab11018b05cf0f6940b59c7
BLAKE2b-256 a63972d34390a07a9be0a5e14c129ea08d173ea616795bb9fb4409ed7d8c55e1

See more details on using hashes here.

File details

Details for the file pocketsphinx-5.0.3-cp38-cp38-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for pocketsphinx-5.0.3-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 0c4906883d7bf2afdf38f1a192090d830f6c016e7b9670fc4720af86cfe1a2f6
MD5 5d22392d93d79e8fa3285fb23c8b40bd
BLAKE2b-256 c7bf94611e6274426ae3b2e07a70068fe3e6645a3cd92163e72911766a6c152d

See more details on using hashes here.

File details

Details for the file pocketsphinx-5.0.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pocketsphinx-5.0.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e1072d84c66440e30fd405bbe64c27c247716990e34f14f34297b492a49bcebd
MD5 bf79f30c2a9d7c1ddf4c57c76e7603f4
BLAKE2b-256 3af28406b21f34424ac6fac03cc484fb2c1727df2afd6b99bbe3fed373f84a38

See more details on using hashes here.

File details

Details for the file pocketsphinx-5.0.3-cp38-cp38-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for pocketsphinx-5.0.3-cp38-cp38-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 2599e8f9cf9807b5a8ecc57fb5b3a156c1fb2f6ac1d16c31334486215161b9a9
MD5 679488a870837ad2ff5f06e2f7ec0bb4
BLAKE2b-256 a300c5bfee1d419301c3683a283ce98645a639bca122f5d8a7f2705cf188503b

See more details on using hashes here.

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