piotrzelasko commited on
Commit
95a0a46
·
1 Parent(s): 6778fdd

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +267 -1
README.md CHANGED
@@ -1,3 +1,269 @@
1
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  license: cc-by-4.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ language:
2
+ - fa
3
+ library_name: nemo
4
+ datasets:
5
+ - mozilla-foundation/common_voice_15_0
6
+ thumbnail: null
7
+ tags:
8
+ - automatic-speech-recognition
9
+ - speech
10
+ - audio
11
+ - CTC
12
+ - Transducer
13
+ - FastConformer
14
+ - Transformer
15
+ - pytorch
16
+ - NeMo
17
  license: cc-by-4.0
18
+ model-index:
19
+ - name: stt_fa_fastconformer_hybrid_large
20
+ results:
21
+ - task:
22
+ type: Automatic Speech Recognition
23
+ name: automatic-speech-recognition
24
+ dataset:
25
+ name: Mozilla Common Voice Persian 15.0
26
+ type: mozilla-foundation/common_voice_15_0
27
+ config: fa
28
+ split: test (custom)
29
+ args:
30
+ language: fa
31
+ metrics:
32
+ - name: Test (custom) WER CTC
33
+ type: wer
34
+ value: 13.16
35
+ - name: Test (custom) CER CTC
36
+ type: cer
37
+ value: 3.85
38
+ - name: Test (custom) WER RNNT
39
+ type: wer
40
+ value: 15.48
41
+ - name: Test (custom) CER RNNT
42
+ type: cer
43
+ value: 4.63
44
  ---
45
+
46
+ # NVIDIA FastConformer-Hybrid Large (fa)
47
+
48
+ <style>
49
+ img {
50
+ display: inline;
51
+ }
52
+ </style>
53
+
54
+ | [![Model architecture](https://img.shields.io/badge/Model_Arch-FastConformer--Transducer_CTC-lightgrey#model-badge)](#model-architecture)
55
+ | [![Model size](https://img.shields.io/badge/Params-115M-lightgrey#model-badge)](#model-architecture)
56
+ | [![Language](https://img.shields.io/badge/Language-fa-lightgrey#model-badge)](#datasets)
57
+
58
+
59
+ This model transcribes speech in Persian alphabet.
60
+ It is a "large" version of FastConformer Transducer-CTC (around 115M parameters) model. This is a hybrid model trained on two losses: Transducer (default) and CTC.
61
+ See the [model architecture](#model-architecture) section and [NeMo documentation](https://docs.nvidia.com/deeplearning/nemo/user-guide/docs/en/main/asr/models.html#fast-conformer) for complete architecture details.
62
+
63
+ ## NVIDIA NeMo: Training
64
+
65
+ To train, fine-tune or play with the model you will need to install [NVIDIA NeMo](https://github.com/NVIDIA/NeMo). We recommend you install it after you've installed latest Pytorch version.
66
+ ```
67
+ pip install nemo_toolkit['all']
68
+ ```
69
+
70
+ ## How to Use this Model
71
+
72
+ The model is available for use in the NeMo toolkit [3], and can be used as a pre-trained checkpoint for inference or for fine-tuning on another dataset.
73
+
74
+ ### Automatically instantiate the model
75
+
76
+ ```python
77
+ import nemo.collections.asr as nemo_asr
78
+ asr_model = nemo_asr.models.EncDecHybridRNNTCTCBPEModel.from_pretrained(model_name="nvidia/stt_fa_fastconformer_hybrid_large")
79
+ ```
80
+
81
+ ### Transcribing using Python
82
+ Having instantiated the model, simply do:
83
+ ```
84
+ asr_model.transcribe([path_to_audio_file])
85
+ ```
86
+
87
+ ### Transcribing many audio files
88
+
89
+ Using Transducer mode inference:
90
+ ```shell
91
+ python [NEMO_GIT_FOLDER]/examples/asr/transcribe_speech.py
92
+ pretrained_name="nvidia/stt_fa_fastconformer_hybrid_large"
93
+ audio_dir="<DIRECTORY CONTAINING AUDIO FILES>"
94
+ ```
95
+
96
+ Using CTC mode inference:
97
+ ```shell
98
+ python [NEMO_GIT_FOLDER]/examples/asr/transcribe_speech.py
99
+ pretrained_name="nvidia/stt_fa_fastconformer_hybrid_large"
100
+ audio_dir="<DIRECTORY CONTAINING AUDIO FILES>"
101
+ decoder_type="ctc"
102
+ ```
103
+
104
+ ### Input
105
+
106
+ This model accepts 16000 Hz Mono-channel Audio (wav files) as input.
107
+
108
+ ### Output
109
+
110
+ This model provides transcribed speech as a string for a given audio sample.
111
+
112
+ ## Model Architecture
113
+
114
+ FastConformer [1] is an optimized version of the Conformer model with 8x depthwise-separable convolutional downsampling. The model is trained in a multitask setup with joint Transducer and CTC decoder loss. You may find more information on the details of FastConformer here: [Fast-Conformer Model](https://docs.nvidia.com/deeplearning/nemo/user-guide/docs/en/main/asr/models.html#fast-conformer) and about Hybrid Transducer-CTC training here: [Hybrid Transducer-CTC](https://docs.nvidia.com/deeplearning/nemo/user-guide/docs/en/main/asr/models.html#hybrid-transducer-ctc).
115
+
116
+ ## Training
117
+
118
+ The NeMo toolkit [3] was used for training the models for over several hundred epochs. These model are trained with this [example script](https://github.com/NVIDIA/NeMo/blob/main/examples/asr/speech_to_text_finetune.py) and this [base config](https://github.com/NVIDIA/NeMo/blob/main/examples/asr/conf/asr_finetune/speech_to_text_finetune.yaml).
119
+
120
+ The tokenizers for these models were built using the text transcripts of the train set with this [script](https://github.com/NVIDIA/NeMo/blob/main/scripts/tokenizers/process_asr_text_tokenizer.py).
121
+
122
+ This model was initialized with the weights of [English FastConformer Hybrid (Transducer and CTC) Large P&C model](https://catalog.ngc.nvidia.com/orgs/nvidia/teams/nemo/models/stt_en_fastconformer_hybrid_large_pc) and fine-tuned to Persian data.
123
+
124
+ ### Datasets
125
+
126
+ This model was trained on Mozilla CommonVoice Persian Corpus 15.0.
127
+
128
+ In order to leverage the entire validated data portion, the standard train/dev/test splits were discarded and replaced with custom splits. The custom splits may be reproduced by:
129
+ - grouping utterances with identical transcript and sorting utterances (ascendingly) by the (transcript occupancy, transcript) pairs;
130
+ - selecting the first 10540 utterances for the test set (to maintain the original size);
131
+ - selecting the second 10540 utterances for the dev set;
132
+ - selecting the remaining data for the training set.
133
+ -
134
+ The transcripts were additionally normalized according to the following script (empty results were discarded):
135
+
136
+ ```python
137
+ import unicodedata
138
+ import string
139
+
140
+ SKIP = set(
141
+ list(string.ascii_letters)
142
+ + [
143
+ "=", # occurs only 2x in utterance (transl.): "twenty = xx"
144
+ "ā", # occurs only 4x together with "š"
145
+ "š",
146
+ # Arabic letters
147
+ "ة", # TEH MARBUTA
148
+ ]
149
+ )
150
+
151
+ DISCARD = [
152
+ # "(laughter)" in Farsi
153
+ "(خنده)",
154
+ # ASCII
155
+ "!",
156
+ '"',
157
+ "#",
158
+ "&",
159
+ "'",
160
+ "(",
161
+ ")",
162
+ ",",
163
+ "-",
164
+ ".",
165
+ ":",
166
+ ";",
167
+ # Unicode punctuation?
168
+ "–",
169
+ "“",
170
+ "”",
171
+ "…",
172
+ "؟",
173
+ "،",
174
+ "؛",
175
+ "ـ",
176
+ # Unicode whitespace?
177
+ "ً",
178
+ "ٌ",
179
+ "َ",
180
+ "ُ",
181
+ "ِ",
182
+ "ّ",
183
+ "ْ",
184
+ "ٔ",
185
+ # Other
186
+ "«",
187
+ "»",
188
+ ]
189
+
190
+ REPLACEMENTS = {
191
+ "أ": "ا",
192
+ "ۀ": "ە",
193
+ "ك": "ک",
194
+ "ي": "ی",
195
+ "ى": "ی",
196
+ "ﯽ": "ی",
197
+ "ﻮ": "و",
198
+ "ے": "ی",
199
+ "ﺒ": "ب",
200
+ "ﻢ": "ﻡ",
201
+ "٬": " ",
202
+ "ە": "ه",
203
+ }
204
+
205
+
206
+ def maybe_normalize(text: str) -> str | None:
207
+
208
+ # Skip selected with banned characters
209
+ if set(text) & SKIP:
210
+ return None # skip this
211
+
212
+ # Remove hashtags - they are not being read in Farsi CV
213
+ text = " ".join(w for w in text.split() if not w.startswith("#"))
214
+
215
+ # Replace selected characters with others
216
+ for lhs, rhs in REPLACEMENTS.items():
217
+ text = text.replace(lhs, rhs)
218
+
219
+ # Replace selected characters with empty strings
220
+ for tok in DISCARD:
221
+ text = text.replace(tok, "")
222
+
223
+ # Unify the symbols that have the same meaning but different Unicode representation.
224
+ text = unicodedata.normalize("NFKC", text)
225
+
226
+ # Remove hamza's that were not merged with any letter by NFKC.
227
+ text = text.replace("ء", "")
228
+
229
+ # Remove double whitespace etc.
230
+ return " ".join(t for t in text.split() if t)
231
+ ```
232
+
233
+ ## Performance
234
+
235
+ The performance of Automatic Speech Recognition models is measuring using Character Error Rate (CER) and Word Error Rate (WER).
236
+
237
+ The model obtains the following scores on our custom dev and test splits of Mozilla CommonVoice Persian 15.0:
238
+
239
+ | Model | %WER/CER dev | %WER/CER test |
240
+ |-----------|--------------|---------------|
241
+ | RNNT head | 15.44 / 3.89 | 15.48 / 4.63 |
242
+ | CTC head | 13.18 / 3.38 | 13.16 / 3.85 |
243
+
244
+ ## Limitations
245
+
246
+ Since this model was trained on publicly available speech datasets, the performance of this model might degrade for speech which includes technical terms, or vernacular that the model has not been trained on. The model might also perform worse for accented speech.
247
+
248
+ ## NVIDIA Riva: Deployment
249
+
250
+ [NVIDIA Riva](https://developer.nvidia.com/riva), is an accelerated speech AI SDK deployable on-prem, in all clouds, multi-cloud, hybrid, on edge, and embedded.
251
+ Additionally, Riva provides:
252
+
253
+ * World-class out-of-the-box accuracy for the most common languages with model checkpoints trained on proprietary data with hundreds of thousands of GPU-compute hours
254
+ * Best in class accuracy with run-time word boosting (e.g., brand and product names) and customization of acoustic model, language model, and inverse text normalization
255
+ * Streaming speech recognition, Kubernetes compatible scaling, and enterprise-grade support
256
+
257
+ Although this model isn’t supported yet by Riva, the [list of supported models is here](https://huggingface.co/models?other=Riva).
258
+ Check out [Riva live demo](https://developer.nvidia.com/riva#demos).
259
+
260
+ ## References
261
+ [1] [Fast Conformer with Linearly Scalable Attention for Efficient Speech Recognition](https://arxiv.org/abs/2305.05084)
262
+
263
+ [2] [Google Sentencepiece Tokenizer](https://github.com/google/sentencepiece)
264
+
265
+ [3] [NVIDIA NeMo Toolkit](https://github.com/NVIDIA/NeMo)
266
+
267
+ ## Licence
268
+
269
+ License to use this model is covered by the [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/). By downloading the public and release version of the model, you accept the terms and conditions of the [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/) license.