Titouan commited on
Commit
87def57
1 Parent(s): b6156a9

adding infos

Browse files
Files changed (8) hide show
  1. README.md +150 -0
  2. asr.ckpt +3 -0
  3. config.json +3 -0
  4. example.wav +0 -0
  5. hyperparams.yaml +153 -0
  6. lm.ckpt +3 -0
  7. normalizer.ckpt +3 -0
  8. tokenizer.ckpt +3 -0
README.md ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ thumbnail: null
5
+ tags:
6
+ - automatic-speech-recognition
7
+ - CTC
8
+ - Attention
9
+ - Transformer
10
+ - pytorch
11
+ - speechbrain
12
+ - hf-asr-leaderboard
13
+ license: apache-2.0
14
+ datasets:
15
+ - librispeech
16
+ metrics:
17
+ - wer
18
+ - cer
19
+ model-index:
20
+ - name: Transformer+TransformerLM by SpeechBrain
21
+ results:
22
+ - task:
23
+ name: Automatic Speech Recognition
24
+ type: automatic-speech-recognition
25
+ dataset:
26
+ name: LibriSpeech (clean)
27
+ type: librispeech_asr
28
+ config: clean
29
+ split: test
30
+ args:
31
+ language: en
32
+ metrics:
33
+ - name: Test WER
34
+ type: wer
35
+ value: 2.49
36
+ - task:
37
+ name: Automatic Speech Recognition
38
+ type: automatic-speech-recognition
39
+ dataset:
40
+ name: LibriSpeech (other)
41
+ type: librispeech_asr
42
+ config: other
43
+ split: test
44
+ args:
45
+ language: en
46
+ metrics:
47
+ - name: Test WER
48
+ type: wer
49
+ value: 6.03
50
+ ---
51
+
52
+ <iframe src="https://ghbtns.com/github-btn.html?user=speechbrain&repo=speechbrain&type=star&count=true&size=large&v=2" frameborder="0" scrolling="0" width="170" height="30" title="GitHub"></iframe>
53
+ <br/><br/>
54
+
55
+ # Small conformer (13M parameters) for LibriSpeech (with Transformer LM)
56
+
57
+ This repository provides all the necessary tools to perform automatic speech
58
+ recognition from an end-to-end system pretrained on LibriSpeech (EN) within
59
+ SpeechBrain. For a better experience, we encourage you to learn more about
60
+ [SpeechBrain](https://speechbrain.github.io).
61
+ The performance of the model is the following:
62
+
63
+ | Release | Test clean WER | Test other WER | GPUs |
64
+ |:-------------:|:--------------:|:--------------:|:--------:|
65
+ | 24-03-22 | 2.49 | 6.03 | 1xV100 32GB |
66
+
67
+ ## Pipeline description
68
+
69
+ This ASR system is composed of 3 different but linked blocks:
70
+ - Tokenizer (unigram) that transforms words into subword units and trained with
71
+ the train transcriptions of LibriSpeech.
72
+ - Neural language model (Transformer LM) trained on the full 10M words dataset.
73
+ - Acoustic model made of a small conformer encoder and a joint decoder with CTC +
74
+ transformer. Hence, the decoding also incorporates the CTC probabilities.
75
+
76
+ The system is trained with recordings sampled at 16kHz (single channel).
77
+ The code will automatically normalize your audio (i.e., resampling + mono channel selection) when calling *transcribe_file* if needed.
78
+
79
+ ## Install SpeechBrain
80
+
81
+ First of all, please install SpeechBrain with the following command:
82
+
83
+ ```
84
+ pip install speechbrain
85
+ ```
86
+
87
+ Please notice that we encourage you to read our tutorials and learn more about
88
+ [SpeechBrain](https://speechbrain.github.io).
89
+
90
+ ### Transcribing your own audio files (in English)
91
+
92
+ ```python
93
+ from speechbrain.pretrained import EncoderDecoderASR
94
+
95
+ asr_model = EncoderDecoderASR.from_hparams(source="speechbrain/asr-conformersmall-transformerlm-librispeech", savedir="pretrained_models/asr-conformersmall-transformerlm-librispeech")
96
+ asr_model.transcribe_file("speechbrain/asr-conformersmall-transformerlm-librispeech/example.wav")
97
+
98
+ ```
99
+ ### Inference on GPU
100
+ To perform inference on the GPU, add `run_opts={"device":"cuda"}` when calling the `from_hparams` method.
101
+
102
+ ## Parallel Inference on a Batch
103
+ Please, [see this Colab notebook](https://colab.research.google.com/drive/1hX5ZI9S4jHIjahFCZnhwwQmFoGAi3tmu?usp=sharing) to figure out how to transcribe in parallel a batch of input sentences using a pre-trained model.
104
+
105
+ ### Training
106
+ The model was trained with SpeechBrain (Commit hash: 'f73fcc35').
107
+ To train it from scratch follow these steps:
108
+ 1. Clone SpeechBrain:
109
+ ```bash
110
+ git clone https://github.com/speechbrain/speechbrain/
111
+ ```
112
+ 2. Install it:
113
+ ```bash
114
+ cd speechbrain
115
+ pip install -r requirements.txt
116
+ pip install -e .
117
+ ```
118
+
119
+ 3. Run Training:
120
+ ```bash
121
+ cd recipes/LibriSpeech/ASR/transformer
122
+ python train.py hparams/conformer_small.yaml --data_folder=your_data_folder
123
+ ```
124
+
125
+ You can find our training results (models, logs, etc) [here](https://drive.google.com/drive/folders/1I4qntoodHCcj1JNbDrfwFHYcLyu1S5-l?usp=sharing).
126
+
127
+ ### Limitations
128
+ The SpeechBrain team does not provide any warranty on the performance achieved by this model when used on other datasets.
129
+
130
+ # **About SpeechBrain**
131
+ - Website: https://speechbrain.github.io/
132
+ - Code: https://github.com/speechbrain/speechbrain/
133
+ - HuggingFace: https://huggingface.co/speechbrain/
134
+
135
+
136
+ # **Citing SpeechBrain**
137
+ Please, cite SpeechBrain if you use it for your research or business.
138
+
139
+
140
+ ```bibtex
141
+ @misc{speechbrain,
142
+ title={{SpeechBrain}: A General-Purpose Speech Toolkit},
143
+ author={Mirco Ravanelli and Titouan Parcollet and Peter Plantinga and Aku Rouhe and Samuele Cornell and Loren Lugosch and Cem Subakan and Nauman Dawalatabad and Abdelwahab Heba and Jianyuan Zhong and Ju-Chieh Chou and Sung-Lin Yeh and Szu-Wei Fu and Chien-Feng Liao and Elena Rastorgueva and François Grondin and William Aris and Hwidong Na and Yan Gao and Renato De Mori and Yoshua Bengio},
144
+ year={2021},
145
+ eprint={2106.04624},
146
+ archivePrefix={arXiv},
147
+ primaryClass={eess.AS},
148
+ note={arXiv:2106.04624}
149
+ }
150
+ ```
asr.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:65d1ddbc19403a2477e7256ffc7c5a835aea07a4a6cbfb3a248172ce8ed33d0a
3
+ size 54944967
config.json ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ {
2
+ "speechbrain_interface": "EncoderDecoderASR"
3
+ }
example.wav ADDED
Binary file (104 kB). View file
hyperparams.yaml ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ############################################################################
2
+ # Model: E2E ASR with Transformer
3
+ # Encoder: Conformer Encoder
4
+ # Decoder: Transformer Decoder + (CTC/ATT joint) beamsearch + TransformerLM
5
+ # Tokens: unigram
6
+ # losses: CTC + KLdiv (Label Smoothing loss)
7
+ # Training: Librispeech 960h
8
+ # Authors: Jianyuan Zhong, Titouan Parcollet 2021
9
+ # ############################################################################
10
+
11
+ # Feature parameters
12
+ sample_rate: 16000
13
+ n_fft: 400
14
+ n_mels: 80
15
+
16
+ ####################### Model parameters ###########################
17
+ # Transformer
18
+ d_model: 144
19
+ nhead: 4
20
+ num_encoder_layers: 12
21
+ num_decoder_layers: 4
22
+ d_ffn: 1024
23
+ transformer_dropout: 0.1
24
+ activation: !name:torch.nn.GELU
25
+ output_neurons: 5000
26
+ vocab_size: 5000
27
+
28
+ # Outputs
29
+ blank_index: 0
30
+ label_smoothing: 0.0
31
+ pad_index: 0
32
+ bos_index: 1
33
+ eos_index: 2
34
+
35
+ # Decoding parameters
36
+ min_decode_ratio: 0.0
37
+ max_decode_ratio: 1.0
38
+ valid_search_interval: 10
39
+ valid_beam_size: 10
40
+ test_beam_size: 66
41
+ lm_weight: 0.60
42
+ ctc_weight_decode: 0.40
43
+
44
+ ############################## models ################################
45
+
46
+ CNN: !new:speechbrain.lobes.models.convolution.ConvolutionFrontEnd
47
+ input_shape: (8, 10, 80)
48
+ num_blocks: 2
49
+ num_layers_per_block: 1
50
+ out_channels: (64, 32)
51
+ kernel_sizes: (3, 3)
52
+ strides: (2, 2)
53
+ residuals: (False, False)
54
+
55
+ Transformer: !new:speechbrain.lobes.models.transformer.TransformerASR.TransformerASR
56
+ input_size: 640
57
+ tgt_vocab: !ref <output_neurons>
58
+ d_model: !ref <d_model>
59
+ nhead: !ref <nhead>
60
+ num_encoder_layers: !ref <num_encoder_layers>
61
+ num_decoder_layers: !ref <num_decoder_layers>
62
+ d_ffn: !ref <d_ffn>
63
+ dropout: !ref <transformer_dropout>
64
+ activation: !ref <activation>
65
+ encoder_module: conformer
66
+ attention_type: RelPosMHAXL
67
+ normalize_before: True
68
+ causal: False
69
+
70
+ ctc_lin: !new:speechbrain.nnet.linear.Linear
71
+ input_size: !ref <d_model>
72
+ n_neurons: !ref <output_neurons>
73
+
74
+ seq_lin: !new:speechbrain.nnet.linear.Linear
75
+ input_size: !ref <d_model>
76
+ n_neurons: !ref <output_neurons>
77
+
78
+ decoder: !new:speechbrain.decoders.S2STransformerBeamSearch
79
+ modules: [!ref <Transformer>, !ref <seq_lin>, !ref <ctc_lin>]
80
+ bos_index: !ref <bos_index>
81
+ eos_index: !ref <eos_index>
82
+ blank_index: !ref <blank_index>
83
+ min_decode_ratio: !ref <min_decode_ratio>
84
+ max_decode_ratio: !ref <max_decode_ratio>
85
+ beam_size: !ref <test_beam_size>
86
+ ctc_weight: !ref <ctc_weight_decode>
87
+ lm_weight: !ref <lm_weight>
88
+ lm_modules: !ref <lm_model>
89
+ temperature: 1.15
90
+ temperature_lm: 1.15
91
+ using_eos_threshold: False
92
+ length_normalization: True
93
+
94
+ log_softmax: !new:torch.nn.LogSoftmax
95
+ dim: -1
96
+
97
+ normalizer: !new:speechbrain.processing.features.InputNormalization
98
+ norm_type: global
99
+
100
+ compute_features: !new:speechbrain.lobes.features.Fbank
101
+ sample_rate: !ref <sample_rate>
102
+ n_fft: !ref <n_fft>
103
+ n_mels: !ref <n_mels>
104
+
105
+ # This is the Transformer LM that is used according to the Huggingface repository
106
+ # Visit the HuggingFace model corresponding to the pretrained_lm_tokenizer_path
107
+ # For more details about the model!
108
+ # NB: It has to match the pre-trained TransformerLM!!
109
+ lm_model: !new:speechbrain.lobes.models.transformer.TransformerLM.TransformerLM
110
+ vocab: 5000
111
+ d_model: 768
112
+ nhead: 12
113
+ num_encoder_layers: 12
114
+ num_decoder_layers: 0
115
+ d_ffn: 3072
116
+ dropout: 0.0
117
+ activation: !name:torch.nn.GELU
118
+ normalize_before: False
119
+
120
+ tokenizer: !new:sentencepiece.SentencePieceProcessor
121
+
122
+ Tencoder: !new:speechbrain.lobes.models.transformer.TransformerASR.EncoderWrapper
123
+ transformer: !ref <Transformer>
124
+
125
+ encoder: !new:speechbrain.nnet.containers.LengthsCapableSequential
126
+ input_shape: [null, null, !ref <n_mels>]
127
+ compute_features: !ref <compute_features>
128
+ normalize: !ref <normalizer>
129
+ cnn: !ref <CNN>
130
+ transformer_encoder: !ref <Tencoder>
131
+
132
+ # Models
133
+ asr_model: !new:torch.nn.ModuleList
134
+ - [!ref <CNN>, !ref <Transformer>, !ref <seq_lin>, !ref <ctc_lin>]
135
+
136
+ modules:
137
+ compute_features: !ref <compute_features>
138
+ normalizer: !ref <normalizer>
139
+ pre_transformer: !ref <CNN>
140
+ transformer: !ref <Transformer>
141
+ asr_model: !ref <asr_model>
142
+ lm_model: !ref <lm_model>
143
+ encoder: !ref <encoder>
144
+ decoder: !ref <decoder>
145
+
146
+ # The pretrainer allows a mapping between pretrained files and instances that
147
+ # are declared in the yaml.
148
+ pretrainer: !new:speechbrain.utils.parameter_transfer.Pretrainer
149
+ loadables:
150
+ normalizer: !ref <normalizer>
151
+ asr: !ref <asr_model>
152
+ lm: !ref <lm_model>
153
+ tokenizer: !ref <tokenizer>
lm.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:87f1398c0ed833631e487aedfbda32be4c9618565482f6fad78ca4e8dda03e5b
3
+ size 381074869
normalizer.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8233e6190e6e433ee8391c37c11fa17be67b6408fd1edcf978039fb51afedd60
3
+ size 1703
tokenizer.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3cdc063492725aa2809a5fbb1aa790eda0e58370c810ebb54a8f4c8b2c46ea68
3
+ size 324347