Adel-Moumen dwgnr commited on
Commit
a04e4b2
1 Parent(s): fa4ea77

crdnn-model (#1)

Browse files

- add crdnn model (b0587d015154adea8ea6514592c4f891c112289c)
- fix readme metadata (18beeab39287363a30927de57f854ba09caf4f08)
- update readme (a5b3ccf8103a1fe31f1c12072f3492bcd6408bb1)
- add example (b40aa419c018e5abf01d39d82a25dc9caa4b199d)


Co-authored-by: Dominik Wagner <dwgnr@users.noreply.huggingface.co>

Files changed (8) hide show
  1. .gitattributes +3 -0
  2. README.md +129 -1
  3. asr.ckpt +3 -0
  4. config.json +3 -0
  5. example.wav +0 -0
  6. hyperparams.yaml +145 -0
  7. normalizer.ckpt +3 -0
  8. 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,131 @@
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
+ # CRDNN 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 Switchboard (EN) 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 | 9.89 | 16.30 | 13.17 | 16.01 | 25.12 | 20.71 | 1xA100 40GB |
33
+
34
+
35
+ ## Pipeline description
36
+
37
+ This ASR system is composed with 2 different but linked blocks:
38
+ - Tokenizer (unigram) that transforms words into subword units trained on
39
+ the training transcriptions of the Switchboard and Fisher corpus.
40
+ - Acoustic model (CRDNN + CTC/Attention). The CRDNN architecture is made of
41
+ N blocks of convolutional neural networks with normalisation and pooling on the
42
+ frequency domain. Then, a bidirectional LSTM is connected to a final DNN to obtain
43
+ the final acoustic representation that is given to the CTC and attention decoders.
44
+
45
+ The system is trained with recordings sampled at 16kHz (single channel).
46
+ The code will automatically normalize your audio (i.e., resampling + mono channel selection) when calling `transcribe_file` if needed.
47
+
48
+ ## Install SpeechBrain
49
+
50
+ First of all, please install SpeechBrain with the following command:
51
+
52
+ ```
53
+ pip install speechbrain
54
+ ```
55
+
56
+ Note that we encourage you to read our tutorials and learn more about
57
+ [SpeechBrain](https://speechbrain.github.io).
58
+
59
+ ## Transcribing Your Own Audio Files
60
+
61
+ ```python
62
+ from speechbrain.pretrained import EncoderDecoderASR
63
+
64
+ asr_model = EncoderDecoderASR.from_hparams(source="speechbrain/asr-crdnn-switchboard", savedir="pretrained_models/speechbrain/asr-crdnn-switchboard")
65
+ asr_model.transcribe_file('speechbrain/asr-crdnn-switchboard/example.wav')
66
+
67
+ ```
68
+
69
+ ## Inference on GPU
70
+
71
+ To perform inference on the GPU, add `run_opts={"device":"cuda"}` when calling the `from_hparams` method.
72
+
73
+ ## Parallel Inference on a Batch
74
+
75
+ 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.
76
+
77
+ ## Training
78
+
79
+ The model was trained with SpeechBrain (commit hash: `70904d0`).
80
+ To train it from scratch follow these steps:
81
+
82
+ 1. Clone SpeechBrain:
83
+ ```bash
84
+ git clone https://github.com/speechbrain/speechbrain/
85
+ ```
86
+
87
+ 2. Install it:
88
+ ```bash
89
+ cd speechbrain
90
+ pip install -r requirements.txt
91
+ pip install -e .
92
+ ```
93
+
94
+ 3. Run Training:
95
+ ```bash
96
+ cd recipes/Switchboard/ASR/seq2seq
97
+ python train.py hparams/train_BPE_2000.yaml --data_folder=your_data_folder
98
+ ```
99
+
100
+ ## Limitations
101
+
102
+ The SpeechBrain team does not provide any warranty on the performance achieved by this model when used on other datasets.
103
+
104
+ ## Credits
105
+
106
+ This model was trained with resources provided by the [THN Center for AI](https://www.th-nuernberg.de/en/kiz).
107
+
108
+ # About SpeechBrain
109
+
110
+ SpeechBrain is an open-source and all-in-one speech toolkit. It is designed to be simple, extremely flexible, and user-friendly.
111
+ Competitive or state-of-the-art performance is obtained in various domains.
112
+
113
+ - Website: https://speechbrain.github.io/
114
+ - GitHub: https://github.com/speechbrain/speechbrain/
115
+ - HuggingFace: https://huggingface.co/speechbrain/
116
+
117
+ # Citing SpeechBrain
118
+
119
+ Please cite SpeechBrain if you use it for your research or business.
120
+
121
+ ```bibtex
122
+ @misc{speechbrain,
123
+ title={{SpeechBrain}: A General-Purpose Speech Toolkit},
124
+ 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},
125
+ year={2021},
126
+ eprint={2106.04624},
127
+ archivePrefix={arXiv},
128
+ primaryClass={eess.AS},
129
+ note={arXiv:2106.04624}
130
+ }
131
+ ```
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
+ }
example.wav ADDED
Binary file (925 kB). View file
 
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