Speech recognition
Speech Recognition in Python: Libraries Compared
SpeechRecognition is the quickest start, but its default Google engine runs on a generic key that Google can revoke. For accurate recognition on your own computer, use faster-whisper or Hugging Face transformers, Vosk for small devices, or NVIDIA NeMo for Parakeet.
Updated October 17, 202611 min read30 cited facts, each traced to its source
4.1times faster
On the faster-whisper project's CPU benchmark with the small model, faster-whisper with int8 precision took about 4.1 times less time than openai/whisper in fp32 precision.
How it is calculated
6.32percent average WER
On the Open ASR Leaderboard's English short-form tests, NVIDIA Parakeet TDT 0.6B v3 had an average word error rate of 6.32 percent, with an RTFx of 3,330.
Hugging Face and collaborators, arXiv, 2025
300MB of memory at runtime
Vosk says a small model is around 50 MB on disk and needs about 300 MB of memory while it runs.
Alpha Cephei, 2026
The quickest way to make Python recognize speech is the SpeechRecognition package, but it mostly calls other engines, and its default engine is a Google endpoint you should not build a product on. For recognition that runs on your own computer, faster-whisper and Hugging Face transformers run OpenAI's Whisper models, and NVIDIA NeMo runs the Parakeet models. Vosk is the lightest choice for small devices. Cloud SDKs from Google, Microsoft and OpenAI take a few lines each, and they bill by the amount of audio you send. This guide compares the options on accuracy, offline use, streaming, languages and license, with code you can run. For the pipeline behind them, read how speech recognition works. For the terms used here, see automatic speech recognition, and for the wider subject, our overview of speech recognition.
Python speech libraries are either wrappers that call engines or engines that recognize speech themselves
Some Python packages are wrappers. They give you one interface and pass the audio to an engine underneath. Others are engines, the code that turns sound into words. A third group is cloud SDKs, which send audio to a company's servers and return text. Knowing which group a package belongs to tells you whether it works offline, what it costs, and whose accuracy you are actually getting.
The SpeechRecognition package is the clearest wrapper. It lists Vosk and OpenAI's Whisper among the engines it can call, alongside the Google endpoint 1. The engines are where the accuracy comes from, so the model you choose matters more than the package around it. Whisper, for example, was trained on 680,000 hours of multilingual and multitask audio 2.
The table near the end compares the options on five measures: offline use, streaming, languages, license and hardware.
SpeechRecognition is the easiest start, but its default Google engine runs on a generic key that Google can revoke
Use SpeechRecognition when you want working code in a few minutes. Install it with pip install SpeechRecognition, then call recognize_google. It needs no setup, because the package ships a generic key that works out of the box. Its docstring says the key should generally be used only for personal or testing purposes 3. The same docstring adds that Google may revoke the key at any time 4, so a script can stop working without any change to your own code.
Failures arrive as exceptions. The docstring says the recognizer raises a RequestError when the recognition operation fails, when the key is not valid, or when there is no internet connection 5. If you see a network error message in a browser instead, the question on speech recognition network errors covers that case.
import speech_recognition as sr
recognizer = sr.Recognizer()
with sr.AudioFile("speech.wav") as source:
audio = recognizer.record(source)
try:
print(recognizer.recognize_google(audio, language="en-US"))
except sr.UnknownValueError:
print("The speech was not understood")
except sr.RequestError as error:
print(f"The Google request failed: {error}")
Three limits apply before you ship. The default key belongs to the package, not to you, so Google can revoke it at any time. Microphone input needs a second package, PyAudio 6. The package itself is permissively licensed, since its license allows redistribution with or without modification 7, so the risk lies in the endpoint, not in the code. For a tool that must keep working, swap the Google call for an engine that runs on your machine or for a cloud SDK you pay for.
faster-whisper and Hugging Face transformers give the best offline accuracy
Whisper is the model most Python projects reach for first, and two packages run it well on your own machine.
faster-whisper reimplements Whisper for speed. Install it with pip install faster-whisper, as the project's README shows. In the project's own CPU benchmark, with the small model, it took 102 seconds with int8 precision 8. openai/whisper took 418 seconds in fp32 precision 9. That works out to about 4.1 times less time for the same recording 10. The ratio comes from one benchmark run by the project itself, so treat it as a guide to the size of the gap, not a promise.
from faster_whisper import WhisperModel
model = WhisperModel("small", device="cpu", compute_type="int8")
segments, info = model.transcribe("speech.wav", beam_size=5)
print(f"Detected language: {info.language}")
for segment in segments:
print(f" [{segment.start:.2f}s -> {segment.end:.2f}s] {segment.text}")
For a fuller setup, including GPU use, see how to run Whisper locally.
Hugging Face transformers is the general route. Its pipeline function takes a task name and a model name, so changing one string changes the engine. That makes it useful when you want to compare several models on the same audio.
from transformers import pipeline
asr = pipeline(task="automatic-speech-recognition", model="openai/whisper-large-v3")
print(asr("speech.wav") ["text"])
The same call also loads NVIDIA's Parakeet checkpoint, which the next section covers.
Whisper's accuracy depends on the language. OpenAI says performance varies widely by language 11, so test the language you need before you commit.
Whisper can invent sentences that are not in the audio. A 2024 study of recordings from speakers with and without aphasia found that roughly 1 percent of Whisper transcriptions contained entire hallucinated phrases or sentences that did not exist in the audio 12. That study tested a 2023 version of Whisper, so newer versions may behave differently. Read the output of every recording by hand, and trim long silences before you transcribe.
A separate 2024 study by Kuhn and colleagues, on English university lecture recordings, put Whisper large-v2 at a 2.9 percent average word error rate 13. In that study's batch mode, Google's service averaged 20.1 percent on the same recordings 14. A single study on one set of recordings is not a verdict, but it is a warning against trusting a default engine without testing it.
Vosk is still the lightest option for small devices and streaming commands
Choose Vosk when the device is small. Alpha Cephei says it works offline even on lightweight devices such as the Raspberry Pi, Android and iOS 15. A small Vosk model typically needs about 300 MB of memory while it runs 16.
The trade is accuracy. The 1.8 GB English model had a word error rate of 5.69 percent on the LibriSpeech test-clean set 17, a bigger model than the one that fits in 300 MB, so measure the model you actually ship. Vosk covers more than 20 languages and dialects 18 and its code is licensed under Apache 2.0 19. For live use, Vosk offers a streaming API, and the real-time speech recognition guide explains what streaming changes.
import json
import wave
from vosk import Model, KaldiRecognizer
model = Model(lang="en-us")
wf = wave.open("speech.wav", "rb")
rec = KaldiRecognizer(model, wf.getframerate())
while True:
data = wf.readframes(4000)
if len(data) == 0:
break
rec.AcceptWaveform(data)
print(json.loads(rec.FinalResult()) ["text"])
The Vosk example script expects a WAV file in mono PCM and prints a message when the file is not.
NVIDIA NeMo runs the Parakeet and Canary models
NVIDIA NeMo is the toolkit that loads the Parakeet models. Running Parakeet in Python means installing NeMo after a recent PyTorch 20. Parakeet TDT 0.6B v3 covers 25 European languages 21, and NVIDIA says its models are designed and optimized for NVIDIA GPU-accelerated systems 22, so expect the best speed on a machine with an NVIDIA GPU.
import nemo.collections.asr as nemo_asr
asr_model = nemo_asr.models.ASRModel.from_pretrained(model_name="nvidia/parakeet-tdt-0.6b-v3")
output = asr_model.transcribe( ["speech.wav"])
print(output [0].text)
On the Open ASR Leaderboard's English short-form tests, Parakeet TDT 0.6B v3 averaged a 6.32 percent word error rate 23. Those are averages over the leaderboard's own test sets. NVIDIA's model card warns that accuracy varies with the language and the characteristics of the input audio 24, so your recordings matter more than the average.
Canary models need a license check before you ship. Canary 1B is licensed CC-BY-NC-4.0, which does not allow commercial use 25. Read the model card for every checkpoint you use, because a model's license is separate from the code that loads it.
Cloud SDKs take a few lines each, and their pricing is metered by audio length
Cloud SDKs trade offline use for scale and for models you do not have to host. Google, Microsoft and OpenAI publish Python clients, and the two examples below show the shape of a call to each. Amazon Transcribe is another option with its own SDK.
As of October 2026, Google's list price for dynamic batch recognition on standard models starts at $0.003 per minute 26, and its Speech-to-Text service supports over 125 languages 27. Check each provider's pricing page before you budget, because prices change.
from openai import OpenAI
client = OpenAI()
with open("speech.wav", "rb") as audio_file:
transcript = client.audio.transcriptions.create(model="gpt-4o-transcribe", file=audio_file)
print(transcript.text)
import os
import azure.cognitiveservices.speech as speechsdk
speech_config = speechsdk.SpeechConfig(subscription=os.environ ["SPEECH_KEY"], endpoint=os.environ ["ENDPOINT"])
speech_config.speech_recognition_language = "en-US"
audio_config = speechsdk.audio.AudioConfig(filename="speech.wav")
recognizer = speechsdk.SpeechRecognizer(speech_config=speech_config, audio_config=audio_config)
print(recognizer.recognize_once_async().get().text)
Microsoft's Python quickstart gives the install command and the credentials setup. If you only need one transcript and no code, our free audio-to-text tool runs in the browser, and how to transcribe audio to text covers the options.
Capturing microphone audio is a separate step, and most models expect 16 kHz mono
Recognition engines take audio, not microphones. You capture the sound yourself and pass a file. Dictation and large-vocabulary recognition principally use a sampling rate of at least 16 kHz, especially in noisy places 28, so record at 16 kHz mono. The code below does that with the python-sounddevice package and saves a WAV file with Python's standard wave module.
import wave
import sounddevice as sd
SAMPLE_RATE = 16000
audio = sd.rec(5 * SAMPLE_RATE, samplerate=SAMPLE_RATE, channels=1, dtype="int16")
sd.wait()
with wave.open("speech.wav", "wb") as wav:
wav.setnchannels(1)
wav.setsampwidth(2)
wav.setframerate(SAMPLE_RATE)
wav.writeframes(audio.tobytes())
A comparison table: offline use, streaming, languages, license and hardware
The table places each option on the five measures that usually decide the choice. Read across a row for one option, or down a column to compare them.
| Option | Runs offline | Streaming | Languages | License | Hardware |
|---|---|---|---|---|---|
| SpeechRecognition with its Google engine | No, needs internet 5 | Works on a finished recording | Depends on the engine | BSD-style 7 | Any computer |
| faster-whisper (Whisper models) | Yes | Not covered here | Varies by language 11 | MIT 29 | Runs on a CPU 8 |
| Hugging Face transformers (Whisper or Parakeet) | Yes, after the model downloads | Not covered here | Depends on the model | Depends on the model | Depends on the model |
| NVIDIA NeMo (Parakeet v3) | Yes | Not covered here | 25 European languages 21 | Canary 1B is non-commercial 25 | Built for NVIDIA GPUs 22 |
| Vosk | Yes 15 | Streaming API | More than 20 18 | Apache 2.0 19 | About 300 MB at runtime 16 |
| Google Cloud Speech-to-Text | No, cloud service | Not covered here | More than 125 27 | Paid per minute 26 | None on your side |
| OpenAI transcription API | No, cloud service | Not covered here | Whisper's list, see the Whisper row | Paid service | None on your side |
The offline options differ most in what they need from the machine. Vosk runs on small devices, faster-whisper runs on an ordinary CPU, and the NeMo models are built for an NVIDIA GPU. The cloud options need no hardware, but they send your audio to a provider.
Choose by device, language and license before you compare accuracy
Most projects can narrow the field to one or two options before any testing, because three constraints rule out most of the table. Work through them in this order.
- Does the audio have to stay on the device? If yes, cross out the cloud rows. That leaves faster-whisper, Hugging Face transformers, NeMo and Vosk, and the SpeechRecognition package only if you point it at an offline engine instead of Google.
- What is the device? A phone, a Raspberry Pi or another small board points to Vosk, because its small models fit in a few hundred megabytes. A desktop or server with an NVIDIA GPU makes NeMo and the larger Whisper models practical. A laptop CPU suits faster-whisper with a small model.
- Which languages do you need? Check the language first, because accuracy varies by language 11. Compare each option's language list against yours before you test anything. If all your languages are European, Parakeet v3 is worth testing.
- Can you ship the license? Code licenses and model licenses are separate. The Canary 1B restriction shows why you read the model card as well as the package license.
Once one or two options pass these checks, measure them on your own audio, as the next section explains. Install the chosen package in a clean virtual environment first, so that a model download or a GPU library does not change the rest of your project.
Measure your accuracy with a WER library before you ship
Benchmarks test on their own audio, not yours. NVIDIA's card says accuracy varies with language and the characteristics of the input audio 24, which is why your clips matter more than a leaderboard. The word error rate counts the words a recognizer substituted, deleted or inserted against a reference transcript. The jiwer package computes it from the minimum edit distance between the two texts 30.
from jiwer import wer
reference = "turn on the lights in the kitchen"
hypothesis = "turn on the light in the kitchen"
print(f"WER: {wer(reference, hypothesis):.1%}")
Write reference transcripts by hand for a few dozen of your own clips, then run every candidate on the same clips. Keep the clips noisy, accented and short where your users are, and note which engine fails on which clip. The number you get is the one to trust, because it measures the audio you will actually ship.
If you need dictation rather than code, Yap, which we make, is an on-device dictation app for Mac and Windows; see the download page. If you are building recognition into an app, the questions on React and React Native and on Unity and Unreal cover those platforms. For the same accuracy question in other settings, see speech recognition accuracy and speech recognition benchmarks.
Evidence
Every number on this page, with where it comes from. Open a fact to see the exact words in its source.
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
Questions about this
- How do you add speech recognition to a React or React Native app?In a React web app, use the browser's Web Speech API, directly or through a hook such as react-speech-recognition, and expect it to work mainly in Chrome. In a React Native app, use a native library such as expo-speech-recognition, and create a development build first if your Expo project has no native folders.
- How do you add speech recognition to a Unity or Unreal game?Unity has a built-in dictation class, DictationRecognizer, but it works only on Windows 10 and only when the user allows dictation. For Unreal Engine 5 and Godot, our searches found no built-in recognizer, so you add a third-party plugin and check its license and platforms before you ship.
- Why does speech recognition show a network or not-allowed error?A **network** error means the network communication that speech recognition needs failed, so the request never finished. A **not-allowed** error means the browser blocked speech input for security, privacy or user preference reasons, and a refused microphone permission is one common cause. MDN lists Firefox's support for speech recognition only as preview, so a page there cannot rely on the feature.
More in Speech recognition
- Speech Recognition: What It Is and How Well It WorksThe overview of this topic
- How Speech Recognition Works, From Sound to Text
- What Is Whisper AI? OpenAI's Speech Model Explained
- Speech-to-Text APIs Compared: Price, Accuracy, Speed
- Word Error Rate (WER): How to Calculate and Read It
- How Accurate Is Speech Recognition? The Real Numbers
- Speech Recognition Models: How Neural ASR Works
- Open-Source Speech Recognition: The Best Models
- How to Run Whisper Locally on Your Own Computer
- Speech Recognition Benchmarks and Leaderboards
- Real-Time Speech Recognition: Streaming and Latency
- On-Device vs Cloud Speech Recognition: The Tradeoffs
- History of Speech Recognition: From Audrey to Whisper
Referenced by
- Speech Recognition: What It Is and How Well It WorksTopic
- Open-Source Speech Recognition: The Best ModelsGuide
- How to Run Whisper Locally on Your Own ComputerGuide
- How do you add speech recognition to a React or React Native app?Question
- How do you add speech recognition to a Unity or Unreal game?Question
- How do you calculate word error rate in Python?Question
- What is Kaldi speech recognition?Question
- Why does speech recognition show a network or not-allowed error?Question