dwgnr commited on
Commit
b0587d0
1 Parent(s): fa4ea77

add crdnn model

Browse files
Files changed (7) hide show
  1. .gitattributes +3 -0
  2. README.md +119 -2
  3. asr.ckpt +3 -0
  4. config.json +3 -0
  5. hyperparams.yaml +145 -0
  6. normalizer.ckpt +3 -0
  7. tokenizer.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
+ normalizer.ckpt filter=lfs diff=lfs merge=lfs -text
35
+ tokenizer.ckpt filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,3 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ nguage: "en"
2
+ thumbnail:
3
+ tags:
4
+ - automatic-speech-recognition
5
+ - CTC
6
+ - Attention
7
+ - pytorch
8
+ - speechbrain
9
+ license: "apache-2.0"
10
+ datasets:
11
+ - switchboard
12
+ metrics:
13
+ - wer
14
+ - ser
15
  ---
16
+
17
+ <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>
18
+ <br/><br/>
19
+
20
+ # CRDNN with CTC/Attention trained on Switchboard
21
+
22
+ This repository provides all the necessary tools to perform automatic speech
23
+ recognition from an end-to-end system pretrained on Switchboard (EN) within
24
+ SpeechBrain. For a better experience we encourage you to learn more about
25
+ [SpeechBrain](https://speechbrain.github.io).
26
+ The performance of the model is the following:
27
+
28
+ | Release | Swbd SER | Callhome SER | Eval2000 SER | Swbd WER | Callhome WER | Eval2000 WER | GPUs |
29
+ |:--------:|:--------:|:------------:|:------------:|:--------:|:------------:|:------------:|:-----------:|
30
+ | 17-09-22 | 61.93 | 65.89 | 64.44 | 16.01 | 25.12 | 20.71 | 1xA100 40GB |
31
+
32
+
33
+ ## Pipeline description
34
+
35
+ This ASR system is composed with 2 different but linked blocks:
36
+ - Tokenizer (unigram) that transforms words into subword units and trained with
37
+ the train transcriptions of Switchboard.
38
+ - Acoustic model (CRDNN + CTC/Attention). The CRDNN architecture is made of
39
+ N blocks of convolutional neural networks with normalisation and pooling on the
40
+ frequency domain. Then, a bidirectional LSTM is connected to a final DNN to obtain
41
+ the final acoustic representation that is given to the CTC and attention decoders.
42
+
43
+ The system is trained with recordings sampled at 16kHz (single channel).
44
+ The code will automatically normalize your audio (i.e., resampling + mono channel selection) when calling *transcribe_file* if needed.
45
+
46
+ ## Install SpeechBrain
47
+
48
+ First of all, please install SpeechBrain with the following command:
49
+
50
+ ```
51
+ pip install speechbrain
52
+ ```
53
+
54
+ Please notice that we encourage you to read our tutorials and learn more about
55
+ [SpeechBrain](https://speechbrain.github.io).
56
+
57
+ ### Transcribing your own audio files (in English)
58
+
59
+ ```python
60
+ from speechbrain.pretrained import EncoderDecoderASR
61
+
62
+ asr_model = EncoderDecoderASR.from_hparams(source="speechbrain/asr-crdnn-switchboard", savedir="pretrained_models/speechbrain/asr-crdnn-switchboard")
63
+ asr_model.transcribe_file('path/to/your/audiofile')
64
+
65
+ ```
66
+
67
+ ### Inference on GPU
68
+ To perform inference on the GPU, add `run_opts={"device":"cuda"}` when calling the `from_hparams` method.
69
+
70
+ ## Parallel Inference on a Batch
71
+ 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.
72
+
73
+
74
+
75
+ ### Training
76
+ The model was trained with SpeechBrain (Commit hash: '2abd9f01').
77
+ To train it from scratch follow these steps:
78
+ 1. Clone SpeechBrain:
79
+ ```bash
80
+ git clone https://github.com/speechbrain/speechbrain/
81
+ ```
82
+ 2. Install it:
83
+ ```bash
84
+ cd speechbrain
85
+ pip install -r requirements.txt
86
+ pip install -e .
87
+ ```
88
+
89
+ 3. Run Training:
90
+ ```bash
91
+ cd recipes/Switchboard/ASR/seq2seq/
92
+ python train.py hparams/train_BPE_1000.yaml --data_folder=your_data_folder
93
+ ```
94
+
95
+ You can find our training results (models, logs, etc) [here](https://drive.google.com/drive/folders/1SAndjcThdkO-YQF8kvwPOXlQ6LMT71vt?usp=sharing).
96
+
97
+ ### Limitations
98
+ The SpeechBrain team does not provide any warranty on the performance achieved by this model when used on other datasets.
99
+
100
+
101
+ # **About SpeechBrain**
102
+ - Website: https://speechbrain.github.io/
103
+ - Code: https://github.com/speechbrain/speechbrain/
104
+ - HuggingFace: https://huggingface.co/speechbrain/
105
+
106
+
107
+ # **Citing SpeechBrain**
108
+ Please, cite SpeechBrain if you use it for your research or business.
109
+
110
+ ```bibtex
111
+ @misc{speechbrain,
112
+ title={{SpeechBrain}: A General-Purpose Speech Toolkit},
113
+ 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},
114
+ year={2021},
115
+ eprint={2106.04624},
116
+ archivePrefix={arXiv},
117
+ primaryClass={eess.AS},
118
+ note={arXiv:2106.04624}
119
+ }
120
+ ```
asr.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:693dd171d58f2c1ddc477b957dd4c696530b6d4f0de1b96691578967973f782f
3
+ size 486220553
config.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "speechbrain_interface": "EncoderDecoderASR"
3
+ }
hyperparams.yaml ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ############################################################################
2
+ # Model: E2E ASR with attention-based ASR
3
+ # Encoder: CRDNN model
4
+ # Decoder: GRU + beamsearch
5
+ # Tokens: BPE with unigram
6
+ # Losses: CTC + NLL
7
+ # Training: Switchboard
8
+ # Authors: Ju-Chieh Chou, Mirco Ravanelli, Abdel Heba, Peter Plantinga,
9
+ # Samuele Cornell 2020, Dominik Wagner 2022
10
+ # ############################################################################
11
+
12
+ # Feature parameters
13
+ sample_rate: 16000
14
+ n_fft: 400
15
+ n_mels: 40
16
+
17
+ # Model parameters
18
+ activation: !name:torch.nn.LeakyReLU
19
+ dropout: 0.15
20
+ cnn_blocks: 2
21
+ cnn_channels: (128, 256)
22
+ inter_layer_pooling_size: (2, 2)
23
+ cnn_kernelsize: (3, 3)
24
+ time_pooling_size: 4
25
+ rnn_class: !name:speechbrain.nnet.RNN.LSTM
26
+ rnn_layers: 4
27
+ rnn_neurons: 1024
28
+ rnn_bidirectional: True
29
+ dnn_blocks: 2
30
+ dnn_neurons: 512
31
+ emb_size: 128
32
+ dec_neurons: 1024
33
+ output_neurons: 2000 # Number of tokens used for tokenizer
34
+ blank_index: 0
35
+ bos_index: 1
36
+ eos_index: 2
37
+
38
+ # Decoding parameters
39
+ min_decode_ratio: 0.0
40
+ max_decode_ratio: 1.0
41
+ valid_beam_size: 60
42
+ test_beam_size: 80
43
+ eos_threshold: 1.5
44
+ using_max_attn_shift: True
45
+ max_attn_shift: 240
46
+ ctc_weight_decode: 0.3
47
+ coverage_penalty: 1.8
48
+ temperature: 1.25
49
+
50
+ normalizer: !new:speechbrain.processing.features.InputNormalization
51
+ norm_type: global
52
+
53
+ compute_features: !new:speechbrain.lobes.features.Fbank
54
+ sample_rate: !ref <sample_rate>
55
+ n_fft: !ref <n_fft>
56
+ n_mels: !ref <n_mels>
57
+
58
+ enc: !new:speechbrain.lobes.models.CRDNN.CRDNN
59
+ input_shape: [null, null, !ref <n_mels>]
60
+ activation: !ref <activation>
61
+ dropout: !ref <dropout>
62
+ cnn_blocks: !ref <cnn_blocks>
63
+ cnn_channels: !ref <cnn_channels>
64
+ cnn_kernelsize: !ref <cnn_kernelsize>
65
+ inter_layer_pooling_size: !ref <inter_layer_pooling_size>
66
+ time_pooling: True
67
+ using_2d_pooling: False
68
+ time_pooling_size: !ref <time_pooling_size>
69
+ rnn_class: !ref <rnn_class>
70
+ rnn_layers: !ref <rnn_layers>
71
+ rnn_neurons: !ref <rnn_neurons>
72
+ rnn_bidirectional: !ref <rnn_bidirectional>
73
+ rnn_re_init: True
74
+ dnn_blocks: !ref <dnn_blocks>
75
+ dnn_neurons: !ref <dnn_neurons>
76
+ use_rnnp: False
77
+
78
+ emb: !new:speechbrain.nnet.embedding.Embedding
79
+ num_embeddings: !ref <output_neurons>
80
+ embedding_dim: !ref <emb_size>
81
+
82
+ dec: !new:speechbrain.nnet.RNN.AttentionalRNNDecoder
83
+ enc_dim: !ref <dnn_neurons>
84
+ input_size: !ref <emb_size>
85
+ rnn_type: gru
86
+ attn_type: location
87
+ hidden_size: !ref <dec_neurons>
88
+ attn_dim: 1024
89
+ num_layers: 1
90
+ scaling: 1.0
91
+ channels: 10
92
+ kernel_size: 100
93
+ re_init: True
94
+ dropout: !ref <dropout>
95
+
96
+ ctc_lin: !new:speechbrain.nnet.linear.Linear
97
+ input_size: !ref <dnn_neurons>
98
+ n_neurons: !ref <output_neurons>
99
+
100
+ seq_lin: !new:speechbrain.nnet.linear.Linear
101
+ input_size: !ref <dec_neurons>
102
+ n_neurons: !ref <output_neurons>
103
+
104
+ log_softmax: !new:speechbrain.nnet.activations.Softmax
105
+ apply_log: True
106
+
107
+ tokenizer: !new:sentencepiece.SentencePieceProcessor
108
+
109
+ asr_model: !new:torch.nn.ModuleList
110
+ - [!ref <enc>, !ref <emb>, !ref <dec>, !ref <ctc_lin>, !ref <seq_lin>]
111
+
112
+ encoder: !new:speechbrain.nnet.containers.LengthsCapableSequential
113
+ input_shape: [null, null, !ref <n_mels>]
114
+ compute_features: !ref <compute_features>
115
+ normalize: !ref <normalizer>
116
+ model: !ref <enc>
117
+
118
+ decoder: !new:speechbrain.decoders.S2SRNNBeamSearcher
119
+ embedding: !ref <emb>
120
+ decoder: !ref <dec>
121
+ linear: !ref <seq_lin>
122
+ ctc_linear: !ref <ctc_lin>
123
+ bos_index: !ref <bos_index>
124
+ eos_index: !ref <eos_index>
125
+ blank_index: !ref <blank_index>
126
+ min_decode_ratio: !ref <min_decode_ratio>
127
+ max_decode_ratio: !ref <max_decode_ratio>
128
+ beam_size: !ref <test_beam_size>
129
+ eos_threshold: !ref <eos_threshold>
130
+ using_max_attn_shift: !ref <using_max_attn_shift>
131
+ max_attn_shift: !ref <max_attn_shift>
132
+ coverage_penalty: !ref <coverage_penalty>
133
+ ctc_weight: !ref <ctc_weight_decode>
134
+ temperature: !ref <temperature>
135
+
136
+ modules:
137
+ normalizer: !ref <normalizer>
138
+ encoder: !ref <encoder>
139
+ decoder: !ref <decoder>
140
+
141
+ pretrainer: !new:speechbrain.utils.parameter_transfer.Pretrainer
142
+ loadables:
143
+ normalizer: !ref <normalizer>
144
+ asr: !ref <asr_model>
145
+ tokenizer: !ref <tokenizer>
normalizer.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5023bda59574203adc674d85efd143c263a5bf5739c1cdac39751345d1a377af
3
+ size 1383
tokenizer.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:25f80ce1b720439d9ebc46a6d3aa399bc2018eaf001084f6f63dc4b7e35f25d0
3
+ size 270824