sangeet2020 commited on
Commit
6872cdd
1 Parent(s): 51b5940

First commit

Browse files
Files changed (8) hide show
  1. README.md +133 -0
  2. asr.ckpt +3 -0
  3. config.json +69 -0
  4. example-de.wav +0 -0
  5. hyperparams.yaml +89 -0
  6. preprocessor_config.json +8 -0
  7. tokenizer.ckpt +3 -0
  8. wav2vec2.ckpt +3 -0
README.md ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - de
4
+ thumbnail: null
5
+ pipeline_tag: automatic-speech-recognition
6
+ tags:
7
+ - CTC
8
+ - pytorch
9
+ - speechbrain
10
+ - Transformer
11
+ license: apache-2.0
12
+ datasets:
13
+ - commonvoice
14
+ metrics:
15
+ - wer
16
+ - cer
17
+ model-index:
18
+ - name: asr-wav2vec2-commonvoice-de
19
+ results:
20
+ - task:
21
+ name: Automatic Speech Recognition
22
+ type: automatic-speech-recognition
23
+ dataset:
24
+ name: CommonVoice Corpus 10.0/ (German)
25
+ type: mozilla-foundation/common_voice_10_1
26
+ config: de
27
+ split: test
28
+ args:
29
+ language: de
30
+ metrics:
31
+ - name: Test WER
32
+ type: wer
33
+ value: '9.54'
34
+ ---
35
+
36
+ <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>
37
+ <br/><br/>
38
+
39
+ # wav2vec 2.0 with CTC trained on CommonVoice German (No LM)
40
+
41
+ This repository provides all the necessary tools to perform automatic speech
42
+ recognition from an end-to-end system pretrained on CommonVoice (German Language) within
43
+ SpeechBrain. For a better experience, we encourage you to learn more about
44
+ [SpeechBrain](https://speechbrain.github.io).
45
+
46
+ The performance of the model is the following:
47
+
48
+ | Release | Test CER | Test WER | GPUs |
49
+ |:-------------:|:--------------:|:--------------:| :--------:|
50
+ | 16-08-22 | 2.40 | 9.54 | 1xRTXA6000 48GB |
51
+
52
+ ## Pipeline description
53
+
54
+ This ASR system is composed of 2 different but linked blocks:
55
+ - Tokenizer (char) that transforms words into chars and trained with
56
+ the train transcriptions (train.tsv) of CommonVoice (DE).
57
+ - Acoustic model (wav2vec2.0 + CTC). A pretrained wav2vec 2.0 model ([wav2vec2-large-xlsr-53-german](https://huggingface.co/facebook/wav2vec2-large-xlsr-53-german)) is combined with two DNN layers and finetuned on CommonVoice DE.
58
+ The obtained final acoustic representation is given to the CTC decoder.
59
+
60
+ The system is trained with recordings sampled at 16kHz (single channel).
61
+ The code will automatically normalize your audio (i.e., resampling + mono channel selection) when calling *transcribe_file* if needed.
62
+
63
+ ## Install SpeechBrain
64
+
65
+ First of all, please install tranformers and SpeechBrain with the following command:
66
+
67
+ ```
68
+ pip install speechbrain transformers
69
+ ```
70
+
71
+ Please notice that we encourage you to read our tutorials and learn more about
72
+ [SpeechBrain](https://speechbrain.github.io).
73
+
74
+ ### Transcribing your own audio files (in German)
75
+
76
+ ```python
77
+ from speechbrain.pretrained import EncoderASR
78
+
79
+ asr_model = EncoderASR.from_hparams(source="speechbrain/asr-wav2vec2-commonvoice-de", savedir="pretrained_models/asr-wav2vec2-commonvoice-de")
80
+ asr_model.transcribe_file("speechbrain/asr-wav2vec2-commonvoice-de/example-de.wav")
81
+
82
+ ```
83
+ ### Inference on GPU
84
+ To perform inference on the GPU, add `run_opts={"device":"cuda"}` when calling the `from_hparams` method.
85
+
86
+ ## Parallel Inference on a Batch
87
+ 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.
88
+
89
+ ### Training
90
+ The model was trained with SpeechBrain.
91
+ To train it from scratch follow these steps:
92
+ 1. Clone SpeechBrain:
93
+ ```bash
94
+ git clone https://github.com/speechbrain/speechbrain/
95
+ ```
96
+ 2. Install it:
97
+ ```bash
98
+ cd speechbrain
99
+ pip install -r requirements.txt
100
+ pip install -e .
101
+ ```
102
+
103
+ 3. Run Training:
104
+ ```bash
105
+ cd recipes/CommonVoice/ASR/seq2seq
106
+ python train.py hparams/train_de_with_wav2vec.yaml --data_folder=your_data_folder
107
+ ```
108
+
109
+ You can find our training results (models, logs, etc) [here](https://drive.google.com/drive/folders/19G2Zm8896QSVDqVfs7PS_W86-K0-5xeC?usp=sharing).
110
+
111
+ ### Limitations
112
+ The SpeechBrain team does not provide any warranty on the performance achieved by this model when used on other datasets.
113
+
114
+
115
+ # **About SpeechBrain**
116
+ - Website: https://speechbrain.github.io/
117
+ - Code: https://github.com/speechbrain/speechbrain/
118
+ - HuggingFace: https://huggingface.co/speechbrain/
119
+
120
+
121
+ # **Citing SpeechBrain**
122
+ Please, cite SpeechBrain if you use it for your research or business.
123
+
124
+ ```bibtex
125
+ @misc{speechbrain,
126
+ title={{SpeechBrain}: A General-Purpose Speech Toolkit},
127
+ 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},
128
+ year={2021},
129
+ eprint={2106.04624},
130
+ archivePrefix={arXiv},
131
+ primaryClass={eess.AS},
132
+ note={arXiv:2106.04624}
133
+ }
asr.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fadf9697a2649270257f2f610758c3cb6616475f8bf6b0142e3275188acd911d
3
+ size 12782432
config.json ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "speechbrain_interface": "EncoderASR",
3
+ "activation_dropout": 0.1,
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.1,
47
+ "gradient_checkpointing": false,
48
+ "hidden_act": "gelu",
49
+ "hidden_dropout": 0.1,
50
+ "hidden_dropout_prob": 0.1,
51
+ "hidden_size": 1024,
52
+ "initializer_range": 0.02,
53
+ "intermediate_size": 4096,
54
+ "layer_norm_eps": 1e-05,
55
+ "layerdrop": 0.1,
56
+ "mask_feature_length": 10,
57
+ "mask_feature_prob": 0.0,
58
+ "mask_time_length": 10,
59
+ "mask_time_prob": 0.05,
60
+ "model_type": "wav2vec2",
61
+ "num_attention_heads": 16,
62
+ "num_conv_pos_embedding_groups": 16,
63
+ "num_conv_pos_embeddings": 128,
64
+ "num_feat_extract_layers": 7,
65
+ "num_hidden_layers": 24,
66
+ "pad_token_id": 0,
67
+ "transformers_version": "4.21.1",
68
+ "vocab_size": 32
69
+ }
example-de.wav ADDED
Binary file (195 kB). View file
hyperparams.yaml ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Generated 2022-08-12 from:
2
+ # /netscratch/sagar/thesis/speechbrain/recipes/CommonVoice_de/ASR/CTC/hparams/train_with_wav2vec.yaml
3
+ # yamllint disable
4
+ # ################################
5
+ # Model: wav2vec2 + DNN + CTC
6
+ # Augmentation: SpecAugment
7
+ # Authors: Sung-Lin Yeh 2021
8
+ # ################################
9
+
10
+ # BPE parameters
11
+ token_type: char # ["unigram", "bpe", "char"]
12
+ character_coverage: 1.0
13
+
14
+ # Model parameters
15
+ # activation: !name:torch.nn.LeakyReLU
16
+ dnn_neurons: 1024
17
+ wav2vec_output_dim: 1024
18
+ dropout: 0.15
19
+
20
+ wav2vec2_hub: facebook/wav2vec2-large-xlsr-53-german
21
+
22
+ # Outputs
23
+ output_neurons: 32 # BPE size, index(blank/eos/bos) = 0
24
+
25
+ # Decoding parameters
26
+ # Be sure that the bos and eos index match with the BPEs ones
27
+ blank_index: 0
28
+ bos_index: 1
29
+ eos_index: 2
30
+
31
+ enc: !new:speechbrain.nnet.containers.Sequential
32
+ input_shape: [null, null, !ref <wav2vec_output_dim>]
33
+ linear1: !name:speechbrain.nnet.linear.Linear
34
+ n_neurons: !ref <dnn_neurons>
35
+ bias: True
36
+ bn1: !name:speechbrain.nnet.normalization.BatchNorm1d
37
+ activation: !new:torch.nn.LeakyReLU
38
+ drop: !new:torch.nn.Dropout
39
+ p: !ref <dropout>
40
+ linear2: !name:speechbrain.nnet.linear.Linear
41
+ n_neurons: !ref <dnn_neurons>
42
+ bias: True
43
+ bn2: !name:speechbrain.nnet.normalization.BatchNorm1d
44
+ activation2: !new:torch.nn.LeakyReLU
45
+ drop2: !new:torch.nn.Dropout
46
+ p: !ref <dropout>
47
+ linear3: !name:speechbrain.nnet.linear.Linear
48
+ n_neurons: !ref <dnn_neurons>
49
+ bias: True
50
+ bn3: !name:speechbrain.nnet.normalization.BatchNorm1d
51
+ activation3: !new:torch.nn.LeakyReLU
52
+
53
+ wav2vec2: !new:speechbrain.lobes.models.huggingface_wav2vec.HuggingFaceWav2Vec2
54
+ source: !ref <wav2vec2_hub>
55
+ output_norm: True
56
+ freeze: True
57
+ save_path: wav2vec2_checkpoint
58
+
59
+ ctc_lin: !new:speechbrain.nnet.linear.Linear
60
+ input_size: !ref <dnn_neurons>
61
+ n_neurons: !ref <output_neurons>
62
+
63
+ log_softmax: !new:speechbrain.nnet.activations.Softmax
64
+ apply_log: True
65
+
66
+ ctc_cost: !name:speechbrain.nnet.losses.ctc_loss
67
+ blank_index: !ref <blank_index>
68
+
69
+ asr_model: !new:torch.nn.ModuleList
70
+ - [!ref <enc>, !ref <ctc_lin>]
71
+
72
+ tokenizer: !new:sentencepiece.SentencePieceProcessor
73
+
74
+ encoder: !new:speechbrain.nnet.containers.LengthsCapableSequential
75
+ wav2vec2: !ref <wav2vec2>
76
+ enc: !ref <enc>
77
+ ctc_lin: !ref <ctc_lin>
78
+
79
+ modules:
80
+ encoder: !ref <encoder>
81
+
82
+ decoding_function: !name:speechbrain.decoders.ctc_greedy_decode
83
+ blank_id: !ref <blank_index>
84
+
85
+ pretrainer: !new:speechbrain.utils.parameter_transfer.Pretrainer
86
+ loadables:
87
+ wav2vec2: !ref <wav2vec2>
88
+ asr: !ref <asr_model>
89
+ tokenizer: !ref <tokenizer>
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:2d85e983ece7ac0d037a4e91f4de1ab5447472bd8039d1842f0e1a0e3c499e1b
3
+ size 238063
wav2vec2.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d2135a525a4a1dd4fc8f71ec5cfb21d9026b5ccdf546ec96c02e6a8dd8ac67a9
3
+ size 1261923125