PocketSphinx
raw JSON → 5.0.4 verified Fri May 01 auth: no python
Official Python bindings for PocketSphinx, a lightweight speech recognition engine. Current version 5.0.4. Release cadence is irregular; updates coincide with upstream changes.
pip install pocketsphinx Common errors
error AttributeError: module 'pocketsphinx' has no attribute 'Decoder' ↓
cause Incorrect import path. The module is not a package with submodules; `import pocketsphinx` gives the module directly.
fix
Use
from pocketsphinx import Decoder or import pocketsphinx; decoder = pocketsphinx.Decoder(). error pocketsphinx.pocketsphinx.Decoder not found ↓
cause Old API path. v5 removed the nested package.
fix
Use
from pocketsphinx import Decoder. Warnings
breaking In v5, the module is imported as 'import pocketsphinx' (no 'pocketsphinx.pocketsphinx'). Older examples use 'from pocketsphinx.pocketsphinx import Decoder' which no longer works. ↓
fix Replace 'from pocketsphinx.pocketsphinx import Decoder' with 'from pocketsphinx import Decoder'.
deprecated The 'LiveSpeech' class is deprecated in favor of using Decoder directly. It may be removed in future versions. ↓
fix Use Decoder with appropriate configuration instead of LiveSpeech.
gotcha pocketsphinx requires audio in 16-bit mono PCM format at 16000 Hz. Providing audio in other formats will silently fail or produce garbage results. ↓
fix Resample and convert audio before passing to Decoder. Use libraries like pydub or scipy for conversion.
Imports
- pocketsphinx
import pocketsphinx - Decoder wrong
from pocketsphinx import LiveSpeechcorrectfrom pocketsphinx import Decoder
Quickstart
import pocketsphinx
decoder = pocketsphinx.Decoder()
decoder.start_utt('test')
decoder.process_raw(b'Some audio data', False, False)
decoder.end_utt()
print(decoder.hypothesis())