SpeechBrain is constantly evolving. New features, tutorials, and documentation will appear over time. SpeechBrain can be installed via PyPI to rapidly use the standard library. Moreover, a local installation can be used to run experiments and modify/customize the toolkit and its recipes.
SpeechBrain supports both CPU and GPU computation. For most recipes, however, a GPU is necessary during training. Please note that CUDA must be properly installed to use GPUs.
We support PyTorch 1.9+ and Python 3.8.1-3.12 (newer Python versions than advertised may work if supported by PyTorch). We recommend you upgrade to at least 3.9+ as support for 3.8 will be removed eventually.
Once you have created your Python environment (see instructions below) you can simply type:
pip install speechbrain
Depending on your OS, audio loading may require the install of optional torchaudio dependencies to work. If it does not work out-of-the box for you, please visit audio troubleshooting.
Then you can then access SpeechBrain with:
import speechbrain as sb
Once you have created your Python environment (see instructions below) you can simply type:
git clone https://github.com/speechbrain/speechbrain.git
cd speechbrain
pip install -r requirements.txt
pip install --editable .
Then you can access SpeechBrain with:
import speechbrain as sb
Any modification made to the speechbrain package will be automatically interpreted as we installed it with the --editable flag.
Please, run the following script from the main folder to make sure your installation is working:
pytest tests
If you have a GPU, you can run the tests with pytest tests --device='cuda'
You can run doctests with:
tests/.run-doctests.sh
If you're trying to run a specific recipe, first follow the "Install locally" instructions above.
Next, install any recipe-specific dependencies (if any) by executing:
cd recipes/<dataset>/<task>/
pip install -r extra_requirements.txtAny recipe-specific instructions should be clearly spelled out in the associated README.md.
SpeechBrain supports Linux-based distributions and macOS. A solution for windows users can be found in this GitHub issue.
A good practice is to have different python environments for your different tools and toolkits, so they do not interfere with each other. This can be done either with Anaconda or venv.
Anaconda can be installed by simply following this tutorial. In practice, it is a matter of downloading the installation script and executing it.
Once Conda is installed, you can create a new environment with:
conda create --name speechbrain python=3.11
Then, activate it with:
conda activate speechbrain
Now, you can install all the needed packages!
More information on managing environments with Anaconda can be found in the documentation.
venv is even simpler. To create your environment:
python3 -m venv /path/to/new/virtual/speechbrain
And to activate it:
source /path/to/new/virtual/speechbrain/bin/activate
Now, you can install all the needed packages!
As SpeechBrain only relies on PyTorch, its GPU usage is also linked to it. Hence,
if PyTorch sees your GPUs, SpeechBrain will. Many functions can be called from the torch package to verify that your GPUs are detected:
import torch
torch.cuda.is_available()
torch.cuda.current_device()
torch.cuda.device(0)
torch.cuda.device_count()
torch.cuda.get_device_name(0)