Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Speechbrain Speechbrain Train AISHELL1 Seq2Seq

From Leeroopedia


Knowledge Sources
Domains ASR, Training
Last Updated 2026-02-09 00:00 GMT

Overview

Concrete tool for training a sequence-to-sequence ASR model on the AISHELL-1 dataset provided by the SpeechBrain library.

Description

This recipe defines the ASR class (subclass of sb.Brain) for attention-based sequence-to-sequence speech recognition on Mandarin Chinese. The encoder processes waveform features through a CRDNN, while the decoder uses an embedding layer and RNN with attention. The model is jointly trained with CTC and NLL (negative log-likelihood) losses, with CTC used only during early epochs. Beam search decoding is applied at validation and test stages.

Usage

Use this recipe to train a seq2seq ASR model with CTC+attention on the AISHELL-1 Mandarin Chinese dataset. Requires the corresponding hyperparameter YAML file and data preparation script.

Code Reference

Source Location

Signature

class ASR(sb.Brain):
    def compute_forward(self, batch, stage):
        """Forward computations from the waveform batches to the output probabilities."""
        ...
    def compute_objectives(self, predictions, batch, stage):
        """Computes the loss (CTC+NLL) given predictions and targets."""
        ...

Import

# Run as recipe script
python recipes/AISHELL-1/ASR/seq2seq/train.py hparams/train.yaml --data_folder /path/to/aishell

I/O Contract

Inputs

Name Type Required Description
batch.sig torch.Tensor Yes Input waveform signal
batch.tokens_bos torch.Tensor Yes Target token sequence with BOS prefix
batch.tokens_eos torch.Tensor Yes Target token sequence with EOS suffix
batch.tokens torch.Tensor Yes Target token sequence (for CTC)

Outputs

Name Type Description
p_ctc torch.Tensor CTC log-probabilities (during early training epochs)
p_seq torch.Tensor Seq2seq log-probabilities from attention decoder
wav_lens torch.Tensor Relative waveform lengths
p_tokens list Beam search hypotheses (at validation/test)

Usage Examples

python train.py hparams/train.yaml --data_folder /path/to/AISHELL-1

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment