s2t-small-librispeech-asr is a Speech to Text Transformer (S2T) model trained for automatic speech recognition (ASR). The S2T model was proposed in this paper and released in this repository
S2T is an end-to-end sequence-to-sequence transformer model. It is trained with standard autoregressive cross-entropy loss and generates the transcripts autoregressively.
As this a standard sequence to sequence transformer model, you can use the generate method to generate the transcripts by passing the speech features to the model.
Note: The Speech2TextProcessor object uses torchaudio to extract the filter bank features. Make sure to install the torchaudio package before running this example.
Note: The feature extractor depends on torchaudio and the tokenizer depends on sentencepiece so be sure to install those packages before running the examples.
You could either install those as extra speech dependancies with pip install transformers"[speech, sentencepiece]" or install the packages seperatly with pip install torchaudio sentencepiece.
The speech data is pre-processed by extracting Kaldi-compliant 80-channel log mel-filter bank features automatically from WAV/FLAC audio files via PyKaldi or torchaudio. Further utterance-level CMVN (cepstral mean and variance normalization) is applied to each example.
The texts are lowercased and tokenized using SentencePiece and a vocabulary size of 10,000.
The model is trained with standard autoregressive cross-entropy loss and using SpecAugment. The encoder receives speech features, and the decoder generates the transcripts autoregressively.
@inproceedings{wang2020fairseqs2t,
title = {fairseq S2T: Fast Speech-to-Text Modeling with fairseq},
author = {Changhan Wang and Yun Tang and Xutai Ma and Anne Wu and Dmytro Okhonko and Juan Pino},
booktitle = {Proceedings of the 2020 Conference of the Asian Chapter of the Association for Computational Linguistics (AACL): System Demonstrations},
year = {2020},
}
Files
12 files · 366 MBWeights 118 MB (safetensors). Sizes and sha256 from the signed manifest.
transformersSpeech recognition with the transformers pipeline.
import os
os.environ["HF_ENDPOINT"] = "https://freeweights.allternit.com"
from transformers import pipeline
asr = pipeline("automatic-speech-recognition", model="facebook/s2t-small-librispeech-asr", revision="256e91a603c013ae09aa1e4c09cfc3f8acdf8d19")
print(asr("audio.wav")["text"])