[来源关键摘录] 官方仓库提供预训练模型、微调方法及复现实验所需的使用说明。
[正文前段节选] Skip to content
Navigation Menu
Appearance settings
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 20, 2026. It is now read-only.
Repository navigation
FilesExpand file tree
Directory actions
More options
Latest commit
Folders and files
Last commit message
Last commit date
parent directory
unsupervised
libri_labels.py
vq-wav2vec_featurize.py
wav2vec_featurize.py
wav2vec_manifest.py
View all files
wav2vec 2.0 learns speech representations on unlabeled data as described in wav2vec 2.0: A Framework for Self-Supervised Learning of Speech Representations (Baevski et al., 2020).
We learned speech representations in multiple languages as well in Unsupervised Cross-lingual Representation Learning for Speech Recognition (Conneau et al., 2020).
We also combined wav2vec 2.0 with self-training in Self-training and Pre-training are Complementary for Speech Recognition (Xu et al., 2020).
We combined speech data from multiple domains in Robust wav2vec 2.0: Analyzing Domain Shift in Self-Supervised Pre-Training (Hsu, et al., 2021).
We finetuned XLSR-53 on multiple languages to transcribe unseen languages in Simple and Effective Zero-shot Cross-lingual Phoneme Recognition (Xu et al., 2021).
Pre-trained models
Finetuning split
Wav2Vec 2.0 Base
No finetuning
Wav2Vec 2.0 Large
Wav2Vec 2.0 Large (LV-60)*
Wav2Vec 2.0 Large conformer - rel_pos (LV-60)*
Wav2Vec 2.0 Large conformer - rope (LV-60)*
Libri-Light + Librispeech
Wav2Vec 2.0 Large (LV-60) + Self Training *
Wav2Vec 2.0 Large (LV-60 + CV + SWBD + FSH) **
Libri-Light + CommonVoice + Switchboard + Fisher
960 hours Librispeech
300 hours Switchboard
* updated (Oct. 24, 2020)
** updated (Nov. 13, 2021)
We also release multilingual pre-trained wav2vec 2.0 (XLSR) models:
Architecture
MLS, CommonVoice, BABEL
The XLSR model uses the following datasets for multilingual pretraining:
MLS: Multilingual LibriSpeech (8 languages, 50.7k hours): Dutch, English, French, German, Italian, Polish, Portuguese, Spanish
CommonVoice (36 languages, 3.6k hours): Arabic, Basque, Breton, Chinese (CN), Chinese (HK), Chinese (TW), Chuvash, Dhivehi, Dutch, English, Esperanto, Estonian, French, German, Hakh-Chin, Indonesian, Interlingua, Irish, Italian, Japanese, Kabyle, Kinyarwanda, Kyrgyz, Latvian, Mongolian, Persian, Portuguese, Russian, Sakha, Slovenian, Spanish, Swedish, Tamil, Tatar, Turkish, Welsh (see also finetuning splits from this paper).
Babel (17 languages, 1.7k hours): Assamese, Bengali, Cantonese, Cebuano, Georgian, Haitian, Kazakh, Kurmanji, Lao, Pashto, Swahili, Tagalog, Tamil, Tok, Turkish, Vietnamese, Zulu
We also finetuned several models on languages from CommonVoice (version 6.1) and Babel. Please refer to our paper for details about which languages are used.
Pretrained Model
Fintune Dataset
Phonetisaurus
CommonVoice, BABEL
We release 2 models that are finetuned on data from 2 different phonemizers. Although the phonemes are all IPA symbols, there are still subtle differences between the phonemized transcriptions from the 2 phonemizers. Thus, it's better to use the corresponding model, if your data is phonemized by either phonemizer above.
Training a new model with the CLI tools
Given a directory containing wav files to be used for pretraining (we recommend splitting each file into separate file 10 to 30 seconds in length)
Prepare training data manifest
First, install the soundfile library:
pip install soundfile
python examples/wav2vec/wav2vec_manifest.py /path/to/waves --dest /manifest/path --ext $ext --valid-percent $valid
$ext should be set to flac, wav, or whatever format your dataset happens to use that soundfile can read.
$valid should be set to some reasonable percentage (like 0.01) of training data to use for validation.
To use a pre-defined validation set (like dev-other from librispeech), set to it 0 and then overwrite valid.tsv with a
separately pre-processed manifest file.
Train a wav2vec 2.0 base model
This configuration was used for the base model trained on the Librispeech dataset in the wav2vec 2.0 paper
Note that the input is expected to be single channel, sampled at 16 kHz
$ fairseq-hydra-train \
task.data=/path/to/data \
--config-dir /path/to/fairseq-py/examples/wav2vec/config/pretraining \
--config-name wav2vec2_base_librispeech
Note: you can simulate 64 GPUs by using k GPUs and adding command line parameters (before --config-dir)
distributed_training.distributed_world_size=k +optimization.update_freq='[x]' where x = 64/k
Train a wav2vec 2.0 large model
This configuration was used for the large model trained on the Libri-light dataset in the wav2vec 2.0 paper
--config-name wav2vec2_large_librivox
Note: you can simulate 128 GPUs by using k GPUs and adding command line parameters (before --config-dir)
distributed_training.distributed_world_size=k +optimization.update_freq='[x]' where x = 128/k
Train a wav2vec 2.0 model with conformer backbone
To replace the transformer layers in the encoder with the conformer layers, set --layer-type conformer --attn-type espnet --pos-enc-type ${POS_ENC_TYPE}. POS_ENC_TYPE refers to positional encoding to be used in the conformer encoder.
Set it to abs, rope or rel_pos to use the absolute positional encoding, rotary positional encoding or relative positional encoding in the conformer layer respectively.
To train a base model with conformer:
--config-name wav2vec2_conformer_base_librispeech \
--attn-type espnet --pos-enc-type ${POS_ENC_TYPE}
To train a large model with conformer:
--config-name wav2vec2_conformer_large_librivox
Fine-tune a pre-trained model with CTC
Fine-tuning a model requires parallel audio and labels file, as well as a vocabulary file in fairseq format.
A letter vocabulary can be downloaded here.
An example script that generates labels for the Librispeech dataset from the tsv file produced by wav2vec_manifest.py can be used as follows:
$ python libri_labels.py /path/to/tsv --output-dir /output/dir --output-name $split
Fine-tuning on 100h of Librispeech with letter targets:
distributed_training.distributed_port=$PORT \
model.w2v_path=/path/to/model.pt \
--config-dir /path/to/fairseq-py/examples/wav2vec/config/finetuning \
--config-name base_100h
There are other config files in the config/finetuning directory that can be used to fine-tune on other splits.
You can specify the right config via the --config-name parameter.
Note: you can simulate 24 GPUs by using k GPUs and adding command line parameters (before --config-dir)
distributed_training.distributed_world_size=k +optimization.update_freq='[x]' where x = 24/k
Decoding with a language model during training requires flashlight python bindings (previously called wav2letter.
If you want to use a language model, add +criterion.wer_args='[/path/to/kenlm, /path/to/lexicon, 2, -1]' to the command line.
Evaluating a CTC model
Evaluating a CTC model with a language model requires flashlight python bindings (previously called wav2letter to be installed.
Fairseq transformer language model used in the wav2vec 2.0 paper can be obtained from the wav2letter model repository.
Be sure to upper-case the language model vocab after downloading it.
Letter dictionary for pre-trained models can be found here.
Next, run the evaluation command:
$subset=dev_other
python examples/speech_recognition/infer.py /checkpoint/abaevski/data/speech/libri/10h/wav2vec/raw --task audio_finetuning \
--nbest 1 --path /path/to/model --gen-subset $subset --results-path /path/to/save/results/for/sclite --w2l-decoder kenlm \
--lm-model /path/to/kenlm.bin --lm-weight 2 --word-score -1 --sil-weight 0 --criterion ctc --labels ltr --max-tokens 4000000 \
--post-process letter
[...内容已截断,完整版请查看原文或 Wayback 快照]