Install & Compatibility
Where this runs
tested against v1.1.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
py 3.10
✕ build_error
✓ 84.7s
py 3.11
✕ build_error
✓ 79.2s
py 3.12
✕ build_error
✓ 68.7s
py 3.13
✕ build_error
✓ 64.65s
py 3.9
✕ build_error
✕ timeout
5018MB installed
● package 5018MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
EncoderDecoderASR
✓ from speechbrain.pretrained import EncoderDecoderASR
SpeakerRecognition
✓ from speechbrain.pretrained import SpeakerRecognition
VAD
✓ from speechbrain.pretrained import VAD
✗ from speechbrain.inference.VAD import VAD
While functional, the 'pretrained' module offers a more unified and recommended interface for inference.
BrainDataset
✓ from speechbrain.dataio.dataset.dynamic import BrainDataset
✗ from speechbrain.dataio.dataio import BrainDataset
Moved in version 1.0.0 due to a major refactor of data processing modules.
This quickstart demonstrates how to load a pretrained Automatic Speech Recognition (ASR) model and transcribe a dummy audio input. It highlights the use of `from_hparams` for model loading and includes cleanup for the temporary download directory.
import torchaudio
import torch
import os
import shutil
from speechbrain.pretrained import EncoderDecoderASR
# Ensure a temporary directory for model downloads
savedir = "tmpdir_asr_quickstart"
# Initialize ASR model
try:
asr_model = EncoderDecoderASR.from_hparams(
source="speechbrain/asr-crdnn-rnnlm-librispeech",
savedir=savedir
)
# Create a dummy audio tensor (batch_size, samples)
# SpeechBrain models typically expect single-channel, 16kHz audio.
sample_rate = 16000
duration_seconds = 3
# Generate a random tensor mimicking a short audio clip
dummy_audio = torch.randn(1, sample_rate * duration_seconds)
# Perform ASR
transcription = asr_model.transcribe_batch(dummy_audio)
print(f"Transcription: {transcription}")
except Exception as e:
print(f"An error occurred: {e}")
finally:
# Clean up the downloaded model directory
if os.path.exists(savedir):
shutil.rmtree(savedir, ignore_errors=True)
print(f"Cleaned up temporary directory: {savedir}")
Debug
Known issues
breakingSpeechBrain 1.0.0 introduced significant breaking changes, especially in the training recipes, data pipeline (e.g., `BrainDataset` moved), and distributed training (`run_on_main` was introduced). Many modules were renamed or refactored.fixRefer to the official SpeechBrain 1.0.0 migration guide. Update import paths and adjust training script structures, especially around `Experiment` and `Brain` classes, and data processing. The `from_hparams` method arguments may have changed for custom models.
affects: <1.0.0
gotchaPretrained models downloaded via `from_hparams` create local directories (`savedir`) which can consume significant disk space (multiple GBs per model). These are not automatically cleaned up.fixAlways specify a `savedir` argument to `from_hparams` and manage this directory yourself. For temporary usage, ensure to delete the directory after use (e.g., `shutil.rmtree`). Consider setting a global cache directory or using a shared volume for persistent models.
affects: All
gotchaSpeechBrain models often expect specific audio formats, typically 16kHz sample rate and single-channel (mono) audio. Providing audio with different sample rates or multiple channels without proper resampling/downmixing can lead to errors or poor model performance.fixEnsure your input audio is preprocessed to match the expected sample rate (e.g., 16kHz) and channel count (mono) of the model. Use libraries like `torchaudio.transforms.Resample` or `librosa` for preprocessing.
affects: All
deprecatedOlder, more granular inference modules like `speechbrain.inference.VAD` or `speechbrain.inference.ASR` are still available but the `speechbrain.pretrained` module is the recommended and more unified interface for inference with pretrained models.fixMigrate to using `from speechbrain.pretrained import SomeModel`. The `pretrained` module provides consistent `from_hparams` methods across different tasks and is generally better maintained for inference.
affects: <1.0.0 (and continued in later versions)
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'speechbrain'
The SpeechBrain library is not installed in the current Python environment or the environment is not activated.
fixpip install speechbrain
RuntimeError: CUDA out of memory.
The GPU does not have sufficient memory to process the current batch size, model size, or other concurrent GPU operations.
fixReduce the `batch_size` in your data loaders, decrease the model's complexity, or free up GPU memory by terminating other processes.
ImportError: cannot import name 'ASR' from 'speechbrain.pretrained'
The generic `ASR` interface is not directly importable from `speechbrain.pretrained`; you need to import specific ASR models like `EncoderDecoderASR` or `end_to_end_asr`.
fixfrom speechbrain.pretrained import EncoderDecoderASR
FileNotFoundError: [Errno 2] No such file or directory: '/path/to/your/audio_file.wav'
SpeechBrain attempted to load an audio file or access a directory that does not exist at the specified path.
fixVerify that the path to your audio file or dataset directory is correct and that the file/directory exists and has appropriate read permissions.
Upgrade
Version history
1.1.1latest on PyPI · released Aug 27, 2026
Audit
Dependencies
torchrequiredCore deep learning framework.
torchaudiooptionalCommonly used for audio loading and processing with SpeechBrain models, often implicitly expected by examples.