# Python speech recognition libraries

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

| Library | Monthly downloads | Stars | Last release | License |
| --- | --- | --- | --- | --- |
| [Transformers](#transformers) | 119.8M | 169.2K | Nov 2026 | Apache-2.0 |
| [faster-whisper](#faster-whisper) | 19.8M | 26.8K | Oct 2025 | MIT |
| [SpeechRecognition](#speechrecognition) | 6.6M | 9.0K | Jun 2026 | BSD-3-Clause |
| [openai-whisper](#whisper) | 6.3M | 112.8K | Jun 2025 | MIT |
| [TorchAudio](#torchaudio) | 5.8M | 3.0K | Oct 2026 | BSD-2-Clause |
| [sherpa-onnx](#sherpa-onnx) | 4.2M | 16.0K | Oct 2026 | Apache-2.0 |
| [SpeechBrain](#speechbrain) | 1.6M | 11.9K | Oct 2026 | Apache-2.0 |
| [Vosk](#vosk) | 1.3M | 15.3K | Dec 2022 | Apache-2.0 |

Downloads: PyPI, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

[Transformers](#transformers) has the most monthly downloads in this comparison, at 119.8M, a count that covers every model task in the library.

## Capabilities

| Library | Local decoding | Stateful streaming |
| --- | --- | --- |
| [Transformers](#transformers) | Yes | Yes |
| [faster-whisper](#faster-whisper) | Yes | No |
| [SpeechRecognition](#speechrecognition) | Via plugin | No |
| [openai-whisper](#whisper) | Yes | No |
| [TorchAudio](#torchaudio) | Yes | Yes |
| [sherpa-onnx](#sherpa-onnx) | Yes | Yes |
| [SpeechBrain](#speechbrain) | Yes | Yes |
| [Vosk](#vosk) | Yes | Yes |

## Libraries

### Transformers

[GitHub](https://github.com/huggingface/transformers) · [PyPI](https://pypi.org/project/transformers) · [Docs](https://huggingface.co/docs/transformers/v5.23.0/en/main_classes/pipelines)

Defines machine learning models for text, vision, audio, and multimodal tasks.

- Downloads / mo: 119.8M
- Stars: 169.2K
- Last release: 5.23.0
- License: Apache-2.0
- Capabilities: [From the Transformers docs](https://huggingface.co/docs/transformers/v5.23.0/en/main_classes/pipelines)

```sh
pip install "transformers[torch]"
```

**gradio-app/gradio** (44.1K stars)

[gradio-app/gradio](https://github.com/gradio-app/gradio) 

```python
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

```

[demo/stream_asr/run.py](https://github.com/gradio-app/gradio/blob/ec06278ed72e5eb73494a9d171ca851d553dc82a/demo/stream_asr/run.py#L7-L21) · [More projects using Transformers →](https://dashboard.exa.ai/playground/search?q=transformers%20GitHub%20projects)

**Quickstart**

```python
from transformers import pipeline

transcriber = pipeline("automatic-speech-recognition", model="openai/whisper-base.en", device="cpu")
print(transcriber("audio.wav")["text"])

```

From [automatic_speech_recognition.py](https://github.com/huggingface/transformers/blob/52b080b6416a7897e2af90febeb4dfad22b84d19/src/transformers/pipelines/__init__.py)

### faster-whisper

[GitHub](https://github.com/SYSTRAN/faster-whisper) · [PyPI](https://pypi.org/project/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
- Capabilities: [From the faster-whisper docs](https://github.com/SYSTRAN/faster-whisper)

**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.

**Watch out for**

- **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.

```sh
pip install faster-whisper
```

**jhj0517/Whisper-WebUI** (2.9K stars)

[jhj0517/Whisper-WebUI](https://github.com/jhj0517/Whisper-WebUI) 

```python
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
    )

```

[modules/whisper/faster_whisper_inference.py](https://github.com/jhj0517/Whisper-WebUI/blob/c3bb3b18e959826b28b1192486a8d5b361b6a4e0/modules/whisper/faster_whisper_inference.py#L117-L165) · [More projects using faster-whisper →](https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20faster-whisper%20for%20microphone%20transcription%2C%20offline%20recognition%2C%20model%20switching%20and%20speech-enabled%20interfaces&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
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)

```

From [README.md](https://github.com/SYSTRAN/faster-whisper/blob/master/README.md)

### SpeechRecognition

[GitHub](https://github.com/Uberi/speech_recognition) · [PyPI](https://pypi.org/project/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
- Capabilities: [From the SpeechRecognition docs](https://github.com/Uberi/speech_recognition)

**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.

**Watch out for**

- **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.

```sh
pip install SpeechRecognition
```

**realpython/python-speech-recognition** (250 stars)

[realpython/python-speech-recognition](https://github.com/realpython/python-speech-recognition) 

```python
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

```

[guessing_game.py](https://github.com/realpython/python-speech-recognition/blob/0c07b810808c01144a9611faf84739f24513184e/guessing_game.py#L7-L52) · [More projects using SpeechRecognition →](https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20SpeechRecognition%20for%20microphone%20transcription%2C%20offline%20recognition%2C%20model%20switching%20and%20speech-enabled%20interfaces&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
import speech_recognition as sr

r = sr.Recognizer()
audio = sr.AudioData.from_file("audio.wav")
print(r.recognize_google(audio))

```

From [microphone_recognition.py](https://github.com/Uberi/speech_recognition/blob/3.17.0/examples/audio_transcribe.py)

### openai-whisper

[GitHub](https://github.com/openai/whisper) · [PyPI](https://pypi.org/project/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
- Capabilities: [From the openai-whisper docs](https://github.com/openai/whisper)

**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.

**Watch out for**

- **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.

```sh
pip install openai-whisper
```

**oobabooga/textgen** (47.7K stars)

[oobabooga/textgen](https://github.com/oobabooga/textgen) 

```python
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"]

```

[extensions/whisper_stt/script.py](https://github.com/oobabooga/textgen/blob/c93f8871239550de2ccfe1e95d469aa82616f07e/extensions/whisper_stt/script.py#L39-L53) · [More projects using openai-whisper →](https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20openai-whisper%20for%20microphone%20transcription%2C%20offline%20recognition%2C%20model%20switching%20and%20speech-enabled%20interfaces&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
import whisper

model = whisper.load_model("turbo")
result = model.transcribe("audio.mp3")
print(result["text"])

```

From [README.md](https://github.com/openai/whisper/blob/main/README.md)

### TorchAudio

[GitHub](https://github.com/pytorch/audio) · [PyPI](https://pypi.org/project/torchaudio) · [Docs](https://docs.pytorch.org/audio/2.11.1/)

Processes audio in PyTorch.

- Downloads / mo: 5.8M
- Stars: 3.0K
- Last release: 2.11.1
- License: BSD-2-Clause
- Capabilities: [From the TorchAudio docs](https://docs.pytorch.org/audio/2.11.1/)

```sh
pip install torchaudio
```

**twosixlabs/armory** (194 stars)

[twosixlabs/armory](https://github.com/twosixlabs/armory) 

```python
def forward(self, x, transcript=True):
    if len(x) != 1:
        raise NotImplementedError("batch size should be 1")
    if self.bundle.sample_rate != self.source_sample_rate:
        x = torchaudio.functional.resample(
            x, self.source_sample_rate, self.bundle.sample_rate
        )

    emissions, _ = self.model(x)
    if transcript:
        return self.decoder(emissions)
    else:
        return emissions

```

[armory/baseline_models/pytorch/hubert_asr_large.py](https://github.com/twosixlabs/armory/blob/1131eadc2e3863677fd3e82b1ebb9350ff661a41/armory/baseline_models/pytorch/hubert_asr_large.py#L75-L87) · [More projects using TorchAudio →](https://dashboard.exa.ai/playground/search?q=torchaudio%20GitHub%20projects)

**Quickstart**

```python
import torchaudio

bundle = torchaudio.pipelines.WAV2VEC2_ASR_BASE_960H
model = bundle.get_model()
print(bundle.get_labels())

```

From [impl.py](https://github.com/pytorch/audio/blob/455331b1b3bb4aabfe3228f6f911fc3f11ae93b1/src/torchaudio/pipelines/__init__.py)

### sherpa-onnx

[GitHub](https://github.com/k2-fsa/sherpa-onnx) · [PyPI](https://pypi.org/project/sherpa-onnx) · [Docs](https://k2-fsa.github.io/sherpa/onnx/)

Recognizes speech.

- Downloads / mo: 4.2M
- Stars: 16.0K
- Last release: 2.0.1
- License: Apache-2.0
- Capabilities: [From the sherpa-onnx docs](https://k2-fsa.github.io/sherpa/onnx/)

```sh
pip install sherpa-onnx numpy
```

**Quickstart**

```python
import wave
import numpy as np
import sherpa_onnx

recognizer = sherpa_onnx.OfflineRecognizer.from_nemo_ctc(
    model="model.onnx", tokens="tokens.txt"
)
with wave.open("speech.wav", "rb") as wav:
    assert wav.getnchannels() == 1 and wav.getsampwidth() == 2
    samples = np.frombuffer(wav.readframes(wav.getnframes()), dtype=np.int16).astype(np.float32) / 32768
    sample_rate = wav.getframerate()
stream = recognizer.create_stream()
stream.accept_waveform(sample_rate, samples)
recognizer.decode_stream(stream)
print(stream.result.text)

```

From [offline-decode-files.py](https://github.com/k2-fsa/sherpa-onnx/blob/af2d8d81dbfa61c4cea4c568da78f3982edca005/python-api-examples/offline-decode-files.py) · [Find projects using sherpa-onnx →](https://dashboard.exa.ai/playground/search?q=sherpa-onnx%20GitHub%20projects)

### SpeechBrain

[GitHub](https://github.com/speechbrain/speechbrain) · [PyPI](https://pypi.org/project/speechbrain) · [Docs](https://speechbrain.readthedocs.io/)

Provides an all-in-one speech toolkit in Python and PyTorch.

- Downloads / mo: 1.6M
- Stars: 11.9K
- Last release: 1.1.2
- License: Apache-2.0
- Capabilities: [From the SpeechBrain docs](https://speechbrain.readthedocs.io/)

```sh
pip install speechbrain
```

**speechbrain/benchmarks** (145 stars)

[speechbrain/benchmarks](https://github.com/speechbrain/benchmarks) 

```python
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

```

[benchmarks/DASB/utils/eval.py](https://github.com/speechbrain/benchmarks/blob/413fa853fad7e792be2965fdd09600d33ad3a965/benchmarks/DASB/utils/eval.py#L447-L489) · [More projects using SpeechBrain →](https://dashboard.exa.ai/playground/search?q=speechbrain%20GitHub%20projects)

**Quickstart**

```python
from speechbrain.inference import EncoderDecoderASR

asr_model = EncoderDecoderASR.from_hparams(source="speechbrain/asr-conformer-transformerlm-librispeech", savedir="pretrained_models/asr-transformer-transformerlm-librispeech")
asr_model.transcribe_file("speechbrain/asr-conformer-transformerlm-librispeech/example.wav")

```

From [README.md](https://github.com/speechbrain/speechbrain/blob/develop/README.md)

### Vosk

[GitHub](https://github.com/alphacep/vosk-api) · [PyPI](https://pypi.org/project/vosk) · [Docs](https://alphacephei.com/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
- Capabilities: [From the Vosk docs](https://alphacephei.com/vosk/)

**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.

**Watch out for**

- **Vocabulary changes depend on model.** Choose a dynamic-graph model when runtime vocabulary changes matter.

```sh
pip install vosk
```

**alphacep/vosk-server** (1.3K stars)

[alphacep/vosk-server](https://github.com/alphacep/vosk-server) 

```python
def process_chunk(rec, message):
    if message == '{"eof" : 1}':
        return rec.FinalResult(), True
    if message == '{"reset" : 1}':
        return rec.FinalResult(), False
    elif rec.AcceptWaveform(message):
        return rec.Result(), False
    else:
        return rec.PartialResult(), False

```

[websocket/asr_server.py](https://github.com/alphacep/vosk-server/blob/47998a26f232252f7baaed53dd8ce89d38bbfbce/websocket/asr_server.py#L13-L21) · [More projects using Vosk →](https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20vosk%20for%20microphone%20transcription%2C%20offline%20recognition%2C%20model%20switching%20and%20speech-enabled%20interfaces&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
import wave
from vosk import Model, KaldiRecognizer

model = Model(lang="en-us")
with wave.open("speech.wav", "rb") as wav:
    assert wav.getnchannels() == 1 and wav.getsampwidth() == 2
    recognizer = KaldiRecognizer(model, wav.getframerate())
    recognizer.AcceptWaveform(wav.readframes(wav.getnframes()))
print(recognizer.FinalResult())

```

From [test_simple.py](https://github.com/alphacep/vosk-api/blob/v0.3.45/python/example/test_simple.py)

## FAQ

### Which Python speech recognition library should I use?

[faster-whisper](#faster-whisper) suits local Whisper transcription with batched inference and word timestamps. [Vosk](#vosk) suits offline streaming recognition. [SpeechRecognition](#speechrecognition) suits code that switches between hosted services and offline engines through one interface.

### What is faster-whisper?

[faster-whisper](#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.

### What is SpeechBrain?

[SpeechBrain](#speechbrain) is a PyTorch speech toolkit for pretrained inference and custom speech recognition training.

### Does SpeechRecognition work offline?

Only with a separate offline engine. Engines such as [Vosk](#vosk) must be installed on their own.

### What is sherpa-onnx?

[sherpa-onnx](#sherpa-onnx) is a local ONNX speech toolkit with separate streaming and offline recognizers.

## How this page was built

Data checked Nov 20, 2026.

Reproduce it with the Exa API:

```json
{
  "endpoint": "/search",
  "body": {
    "query": "Best Python speech recognition libraries SpeechRecognition Vosk faster-whisper Whisper code examples",
    "numResults": 5
  }
}
```

Docs: https://exa.ai/docs/reference/search
