Implementation:Speechbrain Speechbrain Train CommonLanguage LangId
| Knowledge Sources | |
|---|---|
| Domains | ASR, Training |
| Last Updated | 2026-02-09 00:00 GMT |
Overview
Concrete tool for training a language identification system on the CommonLanguage dataset provided by the SpeechBrain library.
Description
This recipe defines the LID class (subclass of sb.Brain) for spoken language identification. The pipeline includes a prepare_features method that handles waveform augmentation, feature extraction, and normalization. The compute_forward method passes features through an embedding model (e.g., ECAPA-TDNN) and a classifier to produce language class probabilities. NLL loss is used for training, and error rate statistics are tracked during evaluation.
Usage
Use this recipe to train a language identification model using the ECAPA-TDNN architecture on the CommonLanguage dataset. Requires the corresponding hyperparameter YAML file and data preparation script.
Code Reference
Source Location
- Repository: SpeechBrain
- File: recipes/CommonLanguage/lang_id/train.py
Signature
class LID(sb.Brain):
def prepare_features(self, wavs, stage):
"""Prepare the features for computation, including augmentation."""
...
def compute_forward(self, batch, stage):
"""Runs all the computation of that transforms the input into the
output probabilities over the N classes."""
...
def compute_objectives(self, inputs, batch, stage):
"""Computes the loss given the predicted and targeted outputs."""
...
Import
# Run as recipe script
python recipes/CommonLanguage/lang_id/train.py hparams/train_ecapa_tdnn.yaml --data_folder /path/to/CommonLanguage
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| batch.sig | torch.Tensor | Yes | Input waveform signal |
| batch.language_encoded | torch.Tensor | Yes | Encoded language label |
Outputs
| Name | Type | Description |
|---|---|---|
| outputs | torch.Tensor | Class posterior probabilities over N language classes |
| lens | torch.Tensor | Relative signal lengths |
Usage Examples
python train.py hparams/train_ecapa_tdnn.yaml --data_folder /path/to/CommonLanguage