Files changed (9) hide show
  1. .gitattributes +3 -0
  2. README.md +123 -0
  3. asr.ckpt +3 -0
  4. config.json +76 -0
  5. example.wav +0 -0
  6. hyperparams.yaml +88 -0
  7. preprocessor_config.json +8 -0
  8. tokenizer.ckpt +3 -0
  9. wav2vec2.ckpt +3 -0
.gitattributes CHANGED
@@ -30,3 +30,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
30
  *.zip filter=lfs diff=lfs merge=lfs -text
31
  *.zst filter=lfs diff=lfs merge=lfs -text
32
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
30
  *.zip filter=lfs diff=lfs merge=lfs -text
31
  *.zst filter=lfs diff=lfs merge=lfs -text
32
  *tfevents* filter=lfs diff=lfs merge=lfs -text
33
+ asr.ckpt filter=lfs diff=lfs merge=lfs -text
34
+ tokenizer.ckpt filter=lfs diff=lfs merge=lfs -text
35
+ wav2vec2.ckpt filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,3 +1,126 @@
1
  ---
 
 
 
 
 
 
 
 
 
2
  license: apache-2.0
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language:
3
+ - en
4
+ thumbnail: null
5
+ tags:
6
+ - automatic-speech-recognition
7
+ - CTC
8
+ - Attention
9
+ - pytorch
10
+ - speechbrain
11
  license: apache-2.0
12
+ datasets:
13
+ - switchboard
14
+ metrics:
15
+ - wer
16
+ - cer
17
+
18
  ---
19
+
20
+ <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>
21
+ <br/><br/>
22
+
23
+ # wav2vec 2.0 with CTC/Attention trained on Switchboard (No LM)
24
+
25
+ This repository provides all the necessary tools to perform automatic speech recognition from an end-to-end system pretrained on the Switchboard (EN) corpus within SpeechBrain.
26
+ For a better experience, we encourage you to learn more about [SpeechBrain](https://speechbrain.github.io).
27
+
28
+ The performance of the model is the following:
29
+
30
+ | Release | Swbd CER | Callhome CER | Eval2000 CER | Swbd WER | Callhome WER | Eval2000 WER | GPUs |
31
+ |:--------:|:--------:|:------------:|:------------:|:--------:|:------------:|:------------:|:-----------:|
32
+ | 17-09-22 | 5.24 | 9.69 | 7.44 | 8 .76 | 14.67 | 11.78 | 4xA100 40GB |
33
+
34
+ ## Pipeline Description
35
+
36
+ This ASR system is composed of 2 different but linked blocks:
37
+ - Tokenizer (unigram) that transforms words into subword units trained on the Switchboard training transcriptions and the Fisher corpus.
38
+ - Acoustic model (wav2vec2.0 + CTC). A pretrained wav2vec 2.0 model ([facebook/wav2vec2-large-lv60](https://huggingface.co/facebook/wav2vec2-large-lv60)) is combined with a feature encoder consisting of three DNN layers and finetuned on Switchboard. The obtained final acoustic representation is given to a greedy CTC decoder.
39
+
40
+ The system is trained with recordings sampled at 16kHz (single channel).
41
+ The code will automatically normalize your audio (i.e., resampling + mono channel selection) when calling `transcribe_file` if needed.
42
+
43
+ ## Install SpeechBrain
44
+
45
+ First of all, please install tranformers and SpeechBrain with the following command:
46
+
47
+ ```
48
+ pip install speechbrain transformers
49
+ ```
50
+
51
+ Please notice that we encourage you to read our tutorials and learn more about
52
+ [SpeechBrain](https://speechbrain.github.io).
53
+
54
+ ## Transcribing Your Own Audio Files
55
+
56
+ ```python
57
+ from speechbrain.pretrained import EncoderASR
58
+
59
+ asr_model = EncoderASR.from_hparams(source="speechbrain/asr-wav2vec2-switchboard", savedir="pretrained_models/asr-wav2vec2-switchboard")
60
+ asr_model.transcribe_file('speechbrain/asr-wav2vec2-switchboard/example.wav')
61
+
62
+ ```
63
+
64
+ ## Inference on GPU
65
+
66
+ To perform inference on the GPU, add `run_opts={"device":"cuda"}` when calling the `from_hparams` method.
67
+
68
+ ## Training
69
+
70
+ The model was trained with SpeechBrain (commit hash: `70904d0`).
71
+ To train it from scratch follow these steps:
72
+
73
+ 1. Clone SpeechBrain:
74
+ ```bash
75
+ git clone https://github.com/speechbrain/speechbrain/
76
+ ```
77
+
78
+ 2. Install it:
79
+ ```bash
80
+ cd speechbrain
81
+ pip install -r requirements.txt
82
+ pip install -e .
83
+ ```
84
+
85
+ 3. Run Training:
86
+ ```bash
87
+ cd recipes/Switchboard/ASR/CTC
88
+ python train_with_wav2vec.py hparams/train_with_wav2vec.yaml --data_folder=your_data_folder
89
+ ```
90
+
91
+ ## Limitations
92
+
93
+ The SpeechBrain team does not provide any warranty on the performance achieved by this model when used on other datasets.
94
+
95
+ ## Credits
96
+
97
+ This model was trained with resources provided by the [THN Center for AI](https://www.th-nuernberg.de/en/kiz).
98
+
99
+ # About SpeechBrain
100
+
101
+ SpeechBrain is an open-source and all-in-one speech toolkit. It is designed to be simple, extremely flexible, and user-friendly.
102
+ Competitive or state-of-the-art performance is obtained in various domains.
103
+
104
+ - Website: https://speechbrain.github.io/
105
+ - GitHub: https://github.com/speechbrain/speechbrain/
106
+ - HuggingFace: https://huggingface.co/speechbrain/
107
+
108
+ # Citing SpeechBrain
109
+
110
+ Please cite SpeechBrain if you use it for your research or business.
111
+
112
+ ```bibtex
113
+ @misc{speechbrain,
114
+ title={{SpeechBrain}: A General-Purpose Speech Toolkit},
115
+ 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},
116
+ year={2021},
117
+ eprint={2106.04624},
118
+ archivePrefix={arXiv},
119
+ primaryClass={eess.AS},
120
+ note={arXiv:2106.04624}
121
+ }
122
+ ```
123
+
124
+
125
+
126
+
asr.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:91d3f9494dd14d52e67de937f7aeec89f1fb6f3376827d4f66a3ae45dfc03166
3
+ size 16751264
config.json ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "speechbrain_interface": "EncoderASR",
3
+ "activation_dropout": 0.0,
4
+ "apply_spec_augment": true,
5
+ "architectures": [
6
+ "Wav2Vec2Model"
7
+ ],
8
+ "attention_dropout": 0.1,
9
+ "bos_token_id": 1,
10
+ "conv_bias": true,
11
+ "conv_dim": [
12
+ 512,
13
+ 512,
14
+ 512,
15
+ 512,
16
+ 512,
17
+ 512,
18
+ 512
19
+ ],
20
+ "conv_kernel": [
21
+ 10,
22
+ 3,
23
+ 3,
24
+ 3,
25
+ 3,
26
+ 2,
27
+ 2
28
+ ],
29
+ "conv_stride": [
30
+ 5,
31
+ 2,
32
+ 2,
33
+ 2,
34
+ 2,
35
+ 2,
36
+ 2
37
+ ],
38
+ "ctc_loss_reduction": "sum",
39
+ "ctc_zero_infinity": false,
40
+ "do_stable_layer_norm": true,
41
+ "eos_token_id": 2,
42
+ "feat_extract_activation": "gelu",
43
+ "feat_extract_dropout": 0.0,
44
+ "feat_extract_norm": "layer",
45
+ "feat_proj_dropout": 0.1,
46
+ "final_dropout": 0.0,
47
+ "gradient_checkpointing": false,
48
+ "hidden_act": "gelu",
49
+ "hidden_dropout": 0.1,
50
+ "hidden_size": 1024,
51
+ "initializer_range": 0.02,
52
+ "intermediate_size": 4096,
53
+ "layer_norm_eps": 1e-05,
54
+ "layerdrop": 0.1,
55
+ "mask_channel_length": 10,
56
+ "mask_channel_min_space": 1,
57
+ "mask_channel_other": 0.0,
58
+ "mask_channel_prob": 0.0,
59
+ "mask_channel_selection": "static",
60
+ "mask_feature_length": 10,
61
+ "mask_feature_prob": 0.0,
62
+ "mask_time_length": 10,
63
+ "mask_time_min_space": 1,
64
+ "mask_time_other": 0.0,
65
+ "mask_time_prob": 0.075,
66
+ "mask_time_selection": "static",
67
+ "model_type": "wav2vec2",
68
+ "num_attention_heads": 16,
69
+ "num_conv_pos_embedding_groups": 16,
70
+ "num_conv_pos_embeddings": 128,
71
+ "num_feat_extract_layers": 7,
72
+ "num_hidden_layers": 24,
73
+ "pad_token_id": 0,
74
+ "transformers_version": "4.5.1",
75
+ "vocab_size": 32
76
+ }
example.wav ADDED
Binary file (925 kB). View file
hyperparams.yaml ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ################################
2
+ # Model: wav2vec2 + DNN + CTC
3
+ # Augmentation: SpecAugment
4
+ # Authors: Titouan Parcollet 2021, Dominik Wagner 2022
5
+ # ################################
6
+
7
+ wav2vec2_hub: facebook/wav2vec2-large-lv60
8
+ sample_rate: 16000
9
+
10
+ # BPE parameters
11
+ token_type: unigram # ["unigram", "bpe", "char"]
12
+ character_coverage: 1.0
13
+
14
+ # Model parameters
15
+ wav2vec_output_dim: 1024
16
+ dnn_neurons: 1024
17
+ freeze_wav2vec: False
18
+ dropout: 0.15
19
+
20
+ # Outputs
21
+ output_neurons: 1000 # BPE size, index(blank/eos/bos) = 0
22
+
23
+ # Decoding parameters
24
+ # Be sure that the bos and eos index match with the BPEs ones
25
+ blank_index: 0
26
+ bos_index: 1
27
+ eos_index: 2
28
+
29
+ enc: !new:speechbrain.nnet.containers.Sequential
30
+ input_shape: [null, null, !ref <wav2vec_output_dim>]
31
+ linear1: !name:speechbrain.nnet.linear.Linear
32
+ n_neurons: !ref <dnn_neurons>
33
+ bias: True
34
+ bn1: !name:speechbrain.nnet.normalization.BatchNorm1d
35
+ activation: !new:torch.nn.LeakyReLU
36
+ drop: !new:torch.nn.Dropout
37
+ p: !ref <dropout>
38
+ linear2: !name:speechbrain.nnet.linear.Linear
39
+ n_neurons: !ref <dnn_neurons>
40
+ bias: True
41
+ bn2: !name:speechbrain.nnet.normalization.BatchNorm1d
42
+ activation2: !new:torch.nn.LeakyReLU
43
+ drop2: !new:torch.nn.Dropout
44
+ p: !ref <dropout>
45
+ linear3: !name:speechbrain.nnet.linear.Linear
46
+ n_neurons: !ref <dnn_neurons>
47
+ bias: True
48
+ bn3: !name:speechbrain.nnet.normalization.BatchNorm1d
49
+ activation3: !new:torch.nn.LeakyReLU
50
+
51
+ wav2vec2: !new:speechbrain.lobes.models.huggingface_wav2vec.HuggingFaceWav2Vec2
52
+ source: !ref <wav2vec2_hub>
53
+ output_norm: True
54
+ freeze: !ref <freeze_wav2vec>
55
+ save_path: wav2vec2_checkpoint
56
+
57
+ ctc_lin: !new:speechbrain.nnet.linear.Linear
58
+ input_size: !ref <dnn_neurons>
59
+ n_neurons: !ref <output_neurons>
60
+
61
+ log_softmax: !new:speechbrain.nnet.activations.Softmax
62
+ apply_log: True
63
+
64
+ ctc_cost: !name:speechbrain.nnet.losses.ctc_loss
65
+ blank_index: !ref <blank_index>
66
+
67
+ asr_model: !new:torch.nn.ModuleList
68
+ - [!ref <enc>, !ref <ctc_lin>]
69
+
70
+ tokenizer: !new:sentencepiece.SentencePieceProcessor
71
+
72
+ encoder: !new:speechbrain.nnet.containers.LengthsCapableSequential
73
+ wav2vec2: !ref <wav2vec2>
74
+ enc: !ref <enc>
75
+ ctc_lin: !ref <ctc_lin>
76
+
77
+ modules:
78
+ encoder: !ref <encoder>
79
+
80
+ decoding_function: !name:speechbrain.decoders.ctc_greedy_decode
81
+ blank_id: !ref <blank_index>
82
+
83
+ pretrainer: !new:speechbrain.utils.parameter_transfer.Pretrainer
84
+ loadables:
85
+ wav2vec2: !ref <wav2vec2>
86
+ asr: !ref <asr_model>
87
+ tokenizer: !ref <tokenizer>
88
+
preprocessor_config.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "do_normalize": true,
3
+ "feature_size": 1,
4
+ "padding_side": "right",
5
+ "padding_value": 0.0,
6
+ "return_attention_mask": true,
7
+ "sampling_rate": 16000
8
+ }
tokenizer.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:17667ee5f627ce940fb671258a9340e12875fa9b02476061112df250bee538f4
3
+ size 253486
wav2vec2.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:06f7c5b9cb72a46f606315c49232b5bb4a7d055196c843a95445c74402fa1794
3
+ size 1261923125