File size: 7,970 Bytes
24997e8
 
0dd6b83
 
f248fdd
 
fbc6b69
f248fdd
fbc6b69
 
 
 
 
 
cc1af93
 
 
 
 
531146d
 
cc1af93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
531146d
 
cc1af93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
013bf1c
fbc6b69
cfaec9e
 
fbc6b69
531146d
cfaec9e
 
 
 
 
b27f041
 
55dfcbe
 
 
f5793d7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fbc6b69
 
3d5346d
 
fbc6b69
 
 
 
 
f248fdd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24997e8
803f441
 
 
 
 
 
896ac08
803f441
 
 
fbc6b69
803f441
 
 
 
013bf1c
4dcd187
803f441
013bf1c
 
 
 
 
 
 
 
 
803f441
94be451
76f844d
803f441
 
fbc6b69
 
 
 
 
 
 
803f441
013bf1c
 
a19084a
fbc6b69
013bf1c
 
 
 
 
01e919d
013bf1c
 
 
 
 
 
 
 
 
 
a19084a
cc1af93
013bf1c
 
 
 
 
 
 
a19084a
013bf1c
 
 
 
 
fbc6b69
 
 
5b6ee15
013bf1c
 
fbc6b69
 
013bf1c
803f441
 
 
013bf1c
fbc6b69
013bf1c
a97af25
 
 
 
013bf1c
803f441
 
 
 
013bf1c
803f441
 
 
 
 
 
 
 
 
 
 
 
 
013bf1c
 
803f441
 
 
1e09b45
803f441
c960644
013bf1c
c960644
013bf1c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
---
license: apache-2.0
pipeline_tag: automatic-speech-recognition
tags:
  - pytorch
  - audio
  - speech
  - automatic-speech-recognition 
  - whisper
  - wav2vec2

model-index:
  - name: whisper_medium_fp16_transformers
    results:
      - task: 
          type: automatic-speech-recognition
          name: Automatic Speech Recognition
        dataset:
          type: librispeech_asr
          name: LibriSpeech (clean)
          config: clean
          split: test
          args:
            language: en
        metrics:
          - type: wer
            value: 0
            name: Test WER
            description: Word Error Rate
          - type: mer
            value: 0
            name: Test MER
            description: Match Error Rate
          - type: wil
            value: 0
            name: Test WIL
            description: Word Information Lost
          - type: wip
            value: 0
            name: Test WIP
            description: Word Information Preserved
          - type: cer
            value: 0
            name: Test CER
            description: Character Error Rate

      - task: 
          type: automatic-speech-recognition
          name: Automatic Speech Recognition
        dataset:
          type: librispeech_asr
          name: LibriSpeech (other)
          config: other
          split: test
          args:
            language: en
        metrics:
          - type: wer
            value: 0
            name: Test WER
            description: Word Error Rate
          - type: mer
            value: 0
            name: Test MER
            description: Match Error Rate
          - type: wil
            value: 0
            name: Test WIL
            description: Word Information Lost
          - type: wip
            value: 0
            name: Test WIP
            description: Word Information Preserved
          - type: cer
            value: 0
            name: Test CER
            description: Character Error Rate
  
      - task: 
          type: automatic-speech-recognition
          name: Automatic Speech Recognition
        dataset:
          type: mozilla-foundation/common_voice_14_0
          name: Common Voice (14.0) (Hindi)
          config: hi
          split: test
          args:
            language: hi
        metrics:
          - type: wer
            value: 54.97
            name: Test WER
            description: Word Error Rate
          - type: mer
            value: 47.86
            name: Test MER
            description: Match Error Rate
          - type: wil
            value: 66.83
            name: Test WIL
            description: Word Information Lost
          - type: wip
            value: 33.16
            name: Test WIP
            description: Word Information Preserved
          - type: cer
            value: 30.23
            name: Test CER
            description: Character Error Rate

widget:
  - example_title: Hinglish Sample
    src: https://huggingface.co/devasheeshG/whisper_medium_fp16_transformers/resolve/main/test.wav
  - example_title: Librispeech sample 1
    src: https://cdn-media.huggingface.co/speech_samples/sample1.flac
  - example_title: Librispeech sample 2
    src: https://cdn-media.huggingface.co/speech_samples/sample2.flac

language:
  - en
  - zh
  - de
  - es
  - ru
  - ko
  - fr
  - ja
  - pt
  - tr
  - pl
  - ca
  - nl
  - ar
  - sv
  - it
  - id
  - hi
  - fi
  - vi
  - he
  - uk
  - el
  - ms
  - cs
  - ro
  - da
  - hu
  - ta
  - 'no'
  - th
  - ur
  - hr
  - bg
  - lt
  - la
  - mi
  - ml
  - cy
  - sk
  - te
  - fa
  - lv
  - bn
  - sr
  - az
  - sl
  - kn
  - et
  - mk
  - br
  - eu
  - is
  - hy
  - ne
  - mn
  - bs
  - kk
  - sq
  - sw
  - gl
  - mr
  - pa
  - si
  - km
  - sn
  - yo
  - so
  - af
  - oc
  - ka
  - be
  - tg
  - sd
  - gu
  - am
  - yi
  - lo
  - uz
  - fo
  - ht
  - ps
  - tk
  - nn
  - mt
  - sa
  - lb
  - my
  - bo
  - tl
  - mg
  - as
  - tt
  - haw
  - ln
  - ha
  - ba
  - jw
  - su
---
## Versions:

- CUDA: 12.1
- cuDNN Version: 8.9.2.26_1.0-1_amd64

* tensorflow Version: 2.12.0
* torch Version: 2.1.0.dev20230606+cu12135
* transformers Version: 4.30.2
* accelerate Version: 0.20.3

## Model Benchmarks:

- RAM: 2.8 GB (Original_Model: 5.5GB)
- VRAM: 1812 MB (Original_Model: 6GB)
- test.wav: 23 s (Multilingual Speech i.e. English+Hindi)

  - **Time in seconds for Processing by each device**

  | Device Name       | float32 (Original) | float16 | CudaCores | TensorCores |
  | ----------------- | ------------------ | ------- | --------- | ----------- |
  | 3060              | 1.7                | 1.1     | 3,584     | 112         |
  | 1660 Super        | OOM                | 3.3     | 1,408     | N/A         |
  | Collab (Tesla T4) | 2.8                | 2.2     | 2,560     | 320         |
  | Collab (CPU)      | 35                 | N/A     | N/A       | N/A         |
  | M1 (CPU)          | -                  | -       | -         | -           |
  | M1 (GPU -> 'mps') | -                  | -       | -         | -           |


  - **NOTE: TensorCores are efficient in mixed-precision calculations**
  - **CPU -> torch.float16 not supported on CPU (AMD Ryzen 5 3600 or Collab CPU)**
- Punchuation: True

## Model Error Benchmarks:

- **WER: Word Error Rate**
- **MER: Match Error Rate**
- **WIL: Word Information Lost**
- **WIP: Word Information Preserved**
- **CER: Character Error Rate**

### Hindi to Hindi (test.tsv) [Common Voice 14.0](https://commonvoice.mozilla.org/en/datasets)

**Test done on RTX 3060 on 2557 Samples**

|                         | WER   | MER   | WIL   | WIP   | CER   |
| ----------------------- | ----- | ----- | ----- | ----- | ----- |
| Original_Model (54 min) | 52.02 | 47.86 | 66.82 | 33.17 | 23.76 |
| This_Model (38 min)     | 54.97 | 47.86 | 66.83 | 33.16 | 30.23 |

### Hindi to English (test.csv) [Custom Dataset](https://huggingface.co/datasets/devasheeshG/common_voices_14_0_hi2en_hi2hi)

**Test done on RTX 3060 on 1000 Samples**

|                         | WER | MER | WIL | WIP | CER |
| ----------------------- | --- | --- | --- | --- | --- |
| Original_Model (30 min) | -   | -   | -   | -   | -   |
| This_Model (20 min)     | -   | -   | -   | -   | -   |

### English ([LibriSpeech](https://huggingface.co/datasets/librispeech_asr) -> test-clean)

**Test done on RTX 3060 on __ Samples**

|                | WER | MER | WIL | WIP | CER |
| -------------- | --- | --- | --- | --- | --- |
| Original_Model | -   | -   | -   | -   | -   |
| This_Model     | -   | -   | -   | -   | -   |

### English ([LibriSpeech](https://huggingface.co/datasets/librispeech_asr) -> test-other)

**Test done on RTX 3060 on __ Samples**

|                | WER | MER | WIL | WIP | CER |
| -------------- | --- | --- | --- | --- | --- |
| Original_Model | -   | -   | -   | -   | -   |
| This_Model     | -   | -   | -   | -   | -   |

- **'jiwer' library is used for calculations**

## Code for conversion:

- ### [Will be soon Uploaded on Github](https://github.com/devasheeshG)

## Usage

A file ``__init__.py`` is contained inside this repo which contains all the code to use this model.

Firstly, clone this repo and place all the files inside a folder.

### Make sure you have git-lfs installed (https://git-lfs.com)

```bash
git lfs install
git clone https://huggingface.co/devasheeshG/whisper_medium_fp16_transformers
```

**Please try in jupyter notebook**

```python
# Import the Model
from whisper_medium_fp16_transformers import Model, load_audio, pad_or_trim
```

```python
# Initilise the model
model = Model(
            model_name_or_path='whisper_medium_fp16_transformers',
            cuda_visible_device="0", 
            device='cuda',
      )
```

```python
# Load Audio
audio = load_audio('whisper_medium_fp16_transformers/test.wav')
audio = pad_or_trim(audio)
```

```python
# Transcribe (First transcription takes time)
model.transcribe(audio)
```

## Credits

It is fp16 version of ``openai/whisper-medium``