Overview
SpeechRecognition is a long-running Python library that gives you a single interface for turning audio into text, whichever engine is behind it. You write the capture and recognition code once, then choose — or switch — between offline and hosted backends without restructuring your program.
The offline options are CMU Sphinx, the Vosk API, OpenAI Whisper running locally, Tensorflow and Snowboy hotword detection. The online options include Google Speech Recognition and Google Cloud Speech, Microsoft Azure Speech, IBM Speech to Text, Wit.ai, Houndify, the OpenAI transcription API, Groq's Whisper API and Cohere Transcribe. That spread is the point: prototype against a free hosted endpoint, then move to a local Whisper or Vosk model when privacy, cost or latency demands it.
It also handles the unglamorous part — microphone capture and audio-file loading — which is why it remains a common first dependency for voice projects. It is maintained by Anthony Zhang (Uberi), requires Python 3.10 or newer, and is released under the 3-clause BSD licence.
What it does
- One recognition API across many backends, so swapping engines is a call change rather than a rewrite
- Offline engines: CMU Sphinx, Vosk, local OpenAI Whisper, Tensorflow, and Snowboy hotword detection
- Online engines: Google Speech Recognition, Google Cloud Speech, Azure Speech, IBM Speech to Text, Wit.ai, Houndify, OpenAI, Groq Whisper and Cohere Transcribe
- Built-in microphone capture as well as audio-file input
- Permissive 3-clause BSD licence, suitable for commercial use
- Ships runnable examples, including microphone_recognition.py and audio_transcribe.py
Getting started
Install from PyPI and run the built-in module to confirm your microphone and defaults work before writing any code. Python 3.10+ is required.
Install the package
pip install SpeechRecognitionCheck the install against your microphone
The package is runnable as a module — the fastest way to confirm audio capture works on your machine.
python -m speech_recognitionWork from the bundled examples
The examples/ directory in the repository holds the canonical starting points: microphone_recognition.py for live capture and audio_transcribe.py for transcribing a file. Pick the recognizer method matching the engine you want, and add that engine's credentials or model as needed.
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 when prototyping a voice feature and you do not yet know which recognition engine you will ship with
- Reach for it to move an existing prototype from a hosted API to local Whisper or Vosk without rewriting the audio layer
- Reach for it for batch transcription of recorded audio files in a Python pipeline
- Reach for it when you need microphone capture handled for you rather than dealing with PortAudio directly
How SpeechRecognition compares
SpeechRecognition alongside other open-source audio, music & voice tools AI/TLDR tracks, ranked by GitHub stars.
| Tool | Stars | What it does |
|---|---|---|
| Whisper | ★ 109k | OpenAI's speech recognition model that transcribes and translates audio across many languages. |
| GPT-SoVITS | ★ 61.8k | An 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. |
| VibeVoice | ★ 54.3k | Microsoft's text-to-speech model for generating long, expressive multi-speaker audio like podcasts. |
| Voicebox | ★ 54.3k | Local-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. |
| whisper.cpp | ★ 53.7k | A 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 | ★ 46k | A library of text-to-speech models including the multilingual XTTS voice-cloning model. |
| ChatTTS | ★ 39.8k | ChatTTS is an open-source text-to-speech model tuned for dialogue, with multi-speaker support and fine-grained control over laughter, pauses, and prosody. |
| SpeechRecognition | ★ 9k | One Python API in front of a dozen speech-to-text engines |