Use this file to discover Exa products, pricing, evaluations, comparisons, use cases, agent interfaces, and technical documentation before exploring further.
Python speech recognition libraries turn recorded or live audio into text. Many run a trained model such as Whisper on the local machine rather than sending audio to a hosted service. These libraries let voice agents, meeting tools, and captioning apps act on what people say.
Popularity
Transformers has the most monthly downloads in this comparison, at 119.8M, a count that covers every model task in the library.
def transcribe(stream, new_chunk):
sr, y = new_chunk
# Convert to mono if stereo if y.ndim > 1:
y = y.mean(axis=1)
y = y.astype(np.float32)
y /= np.max(np.abs(y))
if stream is not None:
stream = np.concatenate([stream, y])
else:
stream = y
return stream, transcriber({"sampling_rate": sr, "raw": stream})["text"] # type: ignore
faster-whisper
Runs Whisper speech recognition through CTranslate2, with batched inference and optional word timestamps.
Downloads / mo
19.8M
Stars
26.8K
Last release
1.2.1
License
MIT
Strengths
Transcribes audio in batches.BatchedInferencePipeline adds batched transcription around a WhisperModel.
Decodes files through bundled FFmpeg.PyAV supplies FFmpeg libraries without a separate system FFmpeg installation.
Limitations
Segments are generated lazily.Iterate over segments to run transcription and collect the results.
GPU setup needs matching libraries.Current GPU releases require matching CUDA and cuDNN libraries.
from faster_whisper import WhisperModel
model = WhisperModel("tiny", device="cpu", compute_type="int8")
segments, info = model.transcribe("audio.mp3")
for segment in segments:
print(segment.text)
def update_model(self,
model_size: str,
compute_type: str,
progress: gr.Progress = gr.Progress()
):
"""
Update current model setting
Parameters
---------- model_size: str
Size of whisper model. If you enter the huggingface repo id, it will try to download the model
automatically from huggingface.
compute_type: str
Compute type for transcription.
see more info : https://opennmt.net/CTranslate2/quantization.html
progress: gr.Progress
Indicator to show progress directly in gradio.
"""
progress(0, desc="Initializing Model..")
model_size_dirname = model_size.replace("/", "--") if "/" in model_size else model_size
if model_size not in self.model_paths and model_size_dirname not in self.model_paths:
print(f"Model is not detected. Trying to download \"{model_size}\" from huggingface to "
f"\"{os.path.join(self.model_dir, model_size_dirname)} ...")
huggingface_hub.snapshot_download(
model_size,
local_dir=os.path.join(self.model_dir, model_size_dirname),
)
self.model_paths = self.get_model_paths()
gr.Info(f"Model is downloaded with the name \"{model_size_dirname}\"")
self.current_model_size = self.model_paths[model_size_dirname]
local_files_only = False
hf_prefix = "models--Systran--faster-whisper-"
official_model_path = os.path.join(self.model_dir, hf_prefix+model_size)
if ((os.path.isdir(self.current_model_size) and os.path.exists(self.current_model_size)) or
(model_size in faster_whisper.available_models() and os.path.exists(official_model_path))):
local_files_only = True
self.current_compute_type = compute_type
self.model = faster_whisper.WhisperModel(
device=self.device,
model_size_or_path=self.current_model_size,
download_root=self.model_dir,
compute_type=self.current_compute_type,
local_files_only=local_files_only
)
SpeechRecognition
Provides one Python interface to multiple online recognition services and optional offline speech engines.
Downloads / mo
6.6M
Stars
9.0K
Last release
3.17.0
License
BSD-3-Clause
Strengths
Switches between recognition engines.Choose online services or local engines through the same recognizer interface.
Reads existing audio recordings.Load recorded audio files before passing them to a recognizer.
Limitations
Microphone capture needs PyAudio.Install microphone dependencies separately before recording speech.
Offline engines need separate installs.Install the selected local engine before using its recognizer.
def recognize_speech_from_mic(recognizer, microphone):
"""Transcribe speech from recorded from `microphone`.
Returns a dictionary with three keys:
"success": a boolean indicating whether or not the API request was
successful
"error": `None` if no error occured, otherwise a string containing
an error message if the API could not be reached or
speech was unrecognizable
"transcription": `None` if speech could not be transcribed,
otherwise a string containing the transcribed text
"""
# check that recognizer and microphone arguments are appropriate type if not isinstance(recognizer, sr.Recognizer):
raise TypeError("`recognizer` must be `Recognizer` instance")
if not isinstance(microphone, sr.Microphone):
raise TypeError("`microphone` must be `Microphone` instance")
# adjust the recognizer sensitivity to ambient noise and record audio # from the microphone with microphone as source:
recognizer.adjust_for_ambient_noise(source)
audio = recognizer.listen(source)
# set up the response object response = {
"success": True,
"error": None,
"transcription": None
}
# try recognizing the speech in the recording # if a RequestError or UnknownValueError exception is caught, # update the response object accordingly try:
response["transcription"] = recognizer.recognize_google(audio)
except sr.RequestError:
# API was unreachable or unresponsive response["success"] = False
response["error"] = "API unavailable"
except sr.UnknownValueError:
# speech was unintelligible response["error"] = "Unable to recognize speech"
return response
openai-whisper
Provides local multilingual speech recognition, language identification, and speech-to-English translation with Whisper models.
Downloads / mo
6.3M
Stars
112.8K
Last release
20250625
License
MIT
Strengths
Recognizes speech across languages.Use multilingual models for transcription, translation, and language identification.
Exposes lower-level decoding functions.Use detect_language and decode to control the decoding workflow.
Limitations
Audio loading needs system FFmpeg.Install the FFmpeg command-line tool alongside the Python package.
Turbo skips translation into English.Select a multilingual model trained for speech translation instead.
def do_stt(audio, whisper_language):
# use pydub to convert sample_rate and sample_width for whisper input dubaudio = AudioSegment.from_file(io.BytesIO(audio))
dubaudio = dubaudio.set_channels(1)
dubaudio = dubaudio.set_frame_rate(16000)
dubaudio = dubaudio.set_sample_width(2)
# same method to get the array as openai whisper repo used from wav file audio_np = np.frombuffer(dubaudio.raw_data, np.int16).flatten().astype(np.float32) / 32768.0
if len(whisper_language) == 0:
result = WHISPERMODEL.transcribe(audio=audio_np)
else:
result = WHISPERMODEL.transcribe(audio=audio_np, language=whisper_language)
return result["text"]
def transcribe_batch_with_details(self, wavs, wav_lens):
"""Transcribes the input audio into a sequence of words
The waveforms should already be in the model's desired format.
You can call:
``normalized = EncoderDecoderASR.normalizer(signal, sample_rate)``
to get a correctly converted signal in most cases.
Arguments
--------- predicted_words : list
The raw ASR predictions, fully decoded
best_scores : list
The best scores (from beam search)
best_log_probs : list
The best predicted log-probabilities (from beam search)
Returns
------- predicted_words : list
The predictions
best_scores : torch.Tensor
The best scores (from beam search)
best_log_probs : torch.Tensor
The best log-probabilities
"""
with torch.no_grad():
wav_lens = wav_lens.to(self.device)
encoder_out = self.asr.encode_batch(wavs, wav_lens)
(
hyps,
best_lens,
best_scores,
best_log_probs,
) = self.asr.mods.decoder(encoder_out, wav_lens)
predicted_words = [
self.asr.tokenizer.decode_ids(token_seq) for token_seq in hyps
]
return predicted_words, best_scores, best_log_probs
Vosk
Runs offline speech recognition with per-language models and a streaming recognition interface.
Downloads / mo
1.3M
Stars
15.3K
Last release
0.3.45
License
Apache-2.0
Strengths
Processes speech as audio arrives.Use its streaming API for continuous transcription.
Adapts vocabulary with supported models.Choose a dynamic-vocabulary model to restrict recognized phrases.
Limitations
Vocabulary changes depend on model.Choose a dynamic-graph model when runtime vocabulary changes matter.
faster-whisper suits local Whisper transcription with batched inference and word timestamps. Vosk suits offline streaming recognition. SpeechRecognition suits code that switches between hosted services and offline engines through one interface.
faster-whisper runs Whisper speech recognition on a separate inference engine, with batched inference and optional word timestamps. Its segments are a generator. Transcription starts when the code iterates over them.
SpeechBrain is a PyTorch speech toolkit for pretrained inference and custom speech recognition training.
Only with a separate offline engine. Engines such as Vosk must be installed on their own.
sherpa-onnx is a local ONNX speech toolkit with separate streaming and offline recognizers.
For coding agents
Found your speech recognition library? Help your agent use it.
Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.