█

AI/TLDR

Buy me a coffee
Buy me a coffee

PocketSphinx

CMU's compact offline speech recogniser, still maintained

Audio, Music & VoiceOpen source
Language
C
License
BSD-style (Carnegie Mellon University)
IN SHORT

What is PocketSphinx?

PocketSphinx is one of Carnegie Mellon University's open-source large-vocabulary, speaker-independent continuous speech recognition engines. It sits in the Audio, Music & Voice category of the Multimodal Generation tools and is open-source, written in C and licensed BSD-style (Carnegie Mellon University). To get started: install the optional example dependencies.

Overview

PocketSphinx is one of Carnegie Mellon University's open-source large-vocabulary, speaker-independent continuous speech recognition engines. The maintainers are candid about what it is: the algorithms and models it implements are old — dating back to the 1970s in some cases — but still useful in many applications because of how compact and efficient they are. Nothing leaves the machine and no GPU is involved, which is exactly why it survives in embedded and offline settings where a neural ASR stack will not fit.

The project builds with CMake and has no dependency on SphinxBase any more; the audio library that never reliably worked on any platform was removed. It ships as a C library with bindings, plus a `pocketsphinx` command-line program that reads single-channel 16-bit PCM audio from standard input or files and recognises speech using its default acoustic and language model. The oddly large version number (5.1.1) is a legacy of the old "5prealpha" release that people were using; the project follows semantic versioning now.

Three commands cover most work. `live` detects speech segments in each input, recognises them and writes line-delimited JSON with start time, duration, probability and text — down to per-word and, with the right flags, per-phone or per-state segments. `single` treats each input as one utterance. `align` force-aligns an audio file to a word sequence you supply, which is what makes PocketSphinx a common choice for generating timings rather than transcripts.

What it does

  • Fully offline, speaker-independent continuous speech recognition with a small footprint and no GPU requirement
  • C library plus a command-line program and Python bindings, built with CMake across Linux and Windows
  • Line-delimited JSON output with start time, duration, probability and text, plus nested word segments
  • Forced alignment (`align`) of audio to a supplied word sequence, optionally down to phone or state level
  • Ships with default acoustic and language models — no training step needed to get a first transcript
  • No SphinxBase dependency, and configuration can be dumped to and loaded from JSON

Getting started

PocketSphinx builds with CMake. You can install just the Python module, or the C library and bindings. Its inputs are single-channel 16-bit PCM, so convert other formats with sox first.

Install the optional example dependencies

Not strictly needed to build and install, but useful for running the example code on Debian-derived systems including Raspberry Pi OS and Ubuntu.

bashbash
sudo apt install \
    ffmpeg \
    libasound2-dev \
    libportaudio2 \
    libportaudiocpp0 \
    libpulse-dev \
    libsox-fmt-all \
    portaudio19-dev \
    sox

Install the Python module in a virtual environment

From the top level of the repository. Replace the path with whichever virtual environment you want to create.

bashbash
python3 -m venv ~/ve_pocketsphinx
. ~/ve_pocketsphinx/bin/activate
pip install .

Or build and install the C library

Standard CMake three-step. Pass `-DCMAKE_INSTALL_PREFIX` on the first command if you do not have access to /usr/local.

bashbash
cmake -S . -B build
cmake --build build
cmake --build build --target install

Transcribe a file

`single` recognises the whole input as one utterance and writes a JSON object. `live` instead segments the stream and emits one JSON line per detected utterance.

bashbash
pocketsphinx single speech.wav

Force-align audio to a known transcript

The first positional argument is the audio; everything after it is concatenated into the text. Normalise that text yourself — remove punctuation and casing. Add `-phone_align yes` or `-state_align yes` for finer granularity.

bashbash
pocketsphinx align goforward.wav "go forward ten meters"

pocketsphinx -phone_align yes align audio.wav "go forward ten meters"

Commands and code are distilled from the project's own documentation — always check the official repo for the latest.

When to use it

  • Reach for it for offline voice control on embedded hardware, where a neural ASR model will not fit in the compute or memory budget
  • Reach for it to force-align audio against a known transcript and get word, phone or state timings
  • Reach for it when audio must never leave the device and a small, auditable C dependency beats a model server
  • Reach for it as a cheap keyword or command recogniser in front of a heavier pipeline

How PocketSphinx compares

PocketSphinx alongside other open-source audio, music & voice tools AI/TLDR tracks, ranked by GitHub stars.

ToolStarsWhat it does
VoiceStudio★ 121kA local-first desktop voice studio that clones and designs voices, dubs video, and handles dictation, running 16 text-to-speech and 11 speech-recognition engines on your own hardware.
Whisper★ 114kOpenAI's speech recognition model that transcribes and translates audio across many languages.
GPT-SoVITS★ 64.3kAn open-source WebUI that clones a voice from a short audio sample and turns text into speech, with zero-shot and few-shot fine-tuning.
Voicebox★ 61.6kLocal-first voice studio that clones a voice from a short sample, generates speech across seven TTS engines and 23 languages, handles system-wide dictation, and speaks for agents over MCP.
VibeVoice★ 57.6kMicrosoft's text-to-speech model for generating long, expressive multi-speaker audio like podcasts.
whisper.cpp★ 55.7kA dependency-free C/C++ port of Whisper built on ggml, running speech recognition on CPU, Metal, CUDA, Vulkan and NPUs from phones to servers.
Coqui TTS★ 46.3kA library of text-to-speech models including the multilingual XTTS voice-cloning model.
PocketSphinx★ 4.4kCMU's compact offline speech recogniser, still maintained