Basic Installation
Install with pip
The easiest way to install SpeechRecognition is using pip:This installs the core library, which works with online APIs like Google Speech Recognition without any additional dependencies.
System Requirements
- Python 3.9+ is required
- FLAC encoder is bundled for Windows (x86/x86-64), macOS (Intel), and Linux (x86/x86-64)
- For other platforms, install FLAC manually (see Platform-Specific Setup)
Optional Dependencies
The library supports multiple recognition engines, each with its own dependencies. Install only what you need:Microphone Support
Required for capturing audio from your microphone:PyAudio 0.2.11 or later is required. Earlier versions have known memory management issues when recording from microphones.
Offline Recognition Engines
PocketSphinx (CMU Sphinx)
For offline speech recognition:Vosk API
For offline recognition with Vosk:Download language models
Vosk requires language models. Download from alphacephei.com/vosk/models and place in your project’s
model directory.Whisper (Local)
For offline recognition with OpenAI’s Whisper:openai-whisper and soundfile for processing audio locally.
Faster Whisper
For optimized Whisper performance:Cloud APIs
Google Cloud Speech-to-Text
Prerequisites: Set up local authentication credentials for your Google account. Follow the Google Cloud Speech-to-Text setup guide.
OpenAI Whisper API
Groq Whisper API
Platform-Specific Setup
macOS
FLAC encoder is bundled for Intel Macs running OS X 10.6+. For Apple Silicon or if you need a custom build:Linux
FLAC is bundled for x86 and x86-64 architectures. For other architectures:Raspberry Pi
The Raspberry Pi doesn’t have built-in audio input. You’ll need:- A USB sound card or USB microphone
- To specify the device index when creating a
Microphoneinstance
Installation from Source
To install from the source distribution:Download source
Download the source distribution from PyPI.
Troubleshooting
AttributeError: Could not find PyAudio
AttributeError: Could not find PyAudio
You need to install PyAudio for microphone support:If that fails on Linux, install system dependencies first:
IOError: No Default Input Device Available
IOError: No Default Input Device Available
Your system doesn’t have a default microphone configured. Either:
- Set a default microphone in your OS settings, or
- Specify a device index explicitly:
Microphone(device_index=0)
Selecting a Specific Microphone
Selecting a Specific Microphone
List available microphones with this code:Then use the index with
Microphone:ChildProcessError: Could not find FLAC converter (macOS)
ChildProcessError: Could not find FLAC converter (macOS)
Installing FLAC directly from source code doesn’t update the search path correctly. Use Homebrew instead:
ALSA Warnings on Linux
ALSA Warnings on Linux
Warnings like “bt_audio_service_open: Connection refused” or “Unknown PCM” are common on Linux and can usually be safely ignored. They occur when:
- Bluetooth audio device configured but not connected (safe to ignore if not using Bluetooth)
- ALSA trying to connect to JACK server (safe to ignore)
/usr/share/alsa/alsa.conf.PyInstaller Compilation Issues
PyInstaller Compilation Issues
SpeechRecognition is supported out of the box in PyInstaller 3.0+. If you encounter issues:
Next Steps
Quickstart Guide
Get started with your first speech recognition application
API Reference
Explore the full API documentation