# SpeechBrain

> A PyTorch toolkit that covers the whole conversational-AI speech stack

- Category: Multimodal Generation / Audio, Music & Voice
- Language: Python
- Licence: Apache-2.0
- Repository: https://github.com/speechbrain/speechbrain
- Website: https://speechbrain.github.io/
- Canonical page: https://ai-tldr.dev/tools/speechbrain/

## In short

SpeechBrain is an open-source PyTorch toolkit for conversational AI — the speech and text technologies behind assistants, chatbots and voice interfaces. It sits in the Audio, Music & Voice category of the Multimodal Generation tools and is open-source, written in Python and licensed Apache-2.0. To get started: install from PyPI.

## Overview

SpeechBrain is an open-source PyTorch toolkit for conversational AI — the speech and text technologies behind assistants, chatbots and voice interfaces. Rather than specialising in one task, it is deliberately holistic: speech recognition, speaker recognition, speech enhancement, speech separation, language modelling and dialogue all live in the same codebase with a consistent structure, so pipelines that combine several of them are built from one set of parts.

The toolkit's centre of gravity is its recipes. The repository ships over 200 competitive training recipes across more than 40 datasets and 20 speech and text tasks, each one a Python training script plus a YAML file holding the hyperparameters. Training from scratch and fine-tuning are both first-class: pretrained backbones such as Whisper, wav2vec 2.0, WavLM and HuBERT can be plugged in and fine-tuned, and training logs and checkpoints for the official recipes are published for replication.

For inference you do not have to train anything. Over 100 pretrained models are hosted on Hugging Face under the SpeechBrain organisation, each with a small interface class — transcribing a file with a pretrained ASR model is three lines of Python. That combination of ready models and open recipes is why the project is widely used as both a research baseline and a teaching tool, and its scope has since widened beyond audio to include EEG through the companion benchmarks repository.

It is documentation-heavy by design: more than 30 tutorials sit alongside an API reference, and classes and functions carry runnable examples. The project is Apache-2.0 licensed and developed in the open, with the default branch being `develop`.

## What it does

- One toolkit across speech recognition, speaker recognition, enhancement, separation, language modelling and dialogue
- 200+ training recipes over 40+ datasets and 20 speech and text tasks, each a train.py plus a YAML hyperparameter file
- Fine-tuning support for pretrained backbones including Whisper, wav2vec 2.0, WavLM, HuBERT, GPT-2 and Llama-family models
- 100+ pretrained models on Hugging Face with simple inference interfaces — transcription in three lines of Python
- A consistent code structure across tasks, so components can be recombined into multi-stage pipelines
- 30+ tutorials plus API documentation with runnable examples, and published logs/checkpoints for replicability

## Getting started

Install from PyPI for inference and ordinary use, or from a clone in editable mode if you intend to modify the toolkit or run its recipes.

1. Install from PyPI

   Then import the package in your code.

```bash
pip install speechbrain
```

2. Or install from a clone (for experiments)

   Recommended if you want to change the toolkit; the --editable flag means your edits take effect immediately.

```bash
git clone https://github.com/speechbrain/speechbrain.git
cd speechbrain
pip install -r requirements.txt
pip install --editable .
```

3. Transcribe a file with a pretrained model

   Pretrained models are pulled from the SpeechBrain organisation on Hugging Face and cached locally.

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

4. Train with a recipe

   Pick the dataset and task under recipes/, then run its script against the YAML hyperparameters. Results land in the output_folder set in the YAML.

```bash
cd recipes/<dataset>/<task>/
python experiment.py params.yaml
```

5. Verify the installation

   The test suite and doctests confirm the environment is sound.

```bash
pytest tests
pytest --doctest-modules speechbrain
```

## When to use it

- Reach for it when you need a research baseline you can reproduce — a published recipe, logs and checkpoints for the task you are comparing against
- Fine-tune a pretrained backbone such as Whisper or WavLM on your own audio without writing the training loop
- Build a multi-stage speech pipeline (enhancement, separation, then recognition) out of components that share one structure
- Use it as a teaching toolkit: the tutorials and runnable examples are aimed at people learning speech processing
