1
---
2
language: [mr,hi]
3
datasets:
4
- openslr
5
- interspeech_2021_asr
6
metrics:
7
- wer
8
tags:
9
- audio
10
- automatic-speech-recognition
11
- speech
12
- xlsr-fine-tuning-week
13
- hindi
14
- marathi
15
license: apache-2.0
16
model-index:
17
- name: XLSR Wav2Vec2 Large 53 Hindi-Marathi by Tanmay Laud
18
  results:
19
  - task: 
20
      name: Speech Recognition
21
      type: automatic-speech-recognition
22
    dataset:
23
      name: OpenSLR hi, OpenSLR mr
24
      type: openslr, interspeech_2021_asr
25
    metrics:
26
       - name: Test WER
27
         type: wer
28
         value: 23.736641
29
---
30
31
# Wav2Vec2-Large-XLSR-53-Hindi-Marathi
32
Fine-tuned facebook/wav2vec2-large-xlsr-53 on Hindi and Marathi using the OpenSLR SLR64 datasets. When using this model, make sure that your speech input is sampled at 16kHz.
33
34
## Installation 
35
```bash
36
pip install git+https://github.com/huggingface/transformers.git datasets librosa torch==1.7.0 torchaudio==0.7.0 jiwer
37
```
38
39
## Eval dataset:
40
```bash
41
wget https://www.openslr.org/resources/103/Marathi_test.zip  -P data/marathi
42
unzip -P "K3[2?do9" data/marathi/Marathi_test.zip -d data/marathi/.
43
tar -xzf data/marathi/Marathi_test.tar.gz -C data/marathi/.
44
wget https://www.openslr.org/resources/103/Hindi_test.zip  -P data/hindi
45
unzip -P "w9I2{3B*" data/hindi/Hindi_test.zip -d data/hindi/.
46
tar -xzf data/hindi/Hindi_test.tar.gz -C data/hindi/.
47
wget  -O test.csv 'https://filebin.net/snrz6bt13usv8w2e/test_large.csv?t=ps3n99ho'
48
#If download does not work, paste this link in browser: https://filebin.net/snrz6bt13usv8w2e/test_large.csv
49
```
50
## Usage
51
 The model can be used directly (without a language model) as follows, assuming you have a dataset with Marathi text and path fields:
52
53
54
55
```python
56
import torch
57
import torchaudio
58
import librosa
59
from datasets import load_dataset
60
from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
61
62
from datasets import load_metric, Dataset
63
from transformers import Wav2Vec2Processor, Wav2Vec2ForCTC
64
65
wer = load_metric("wer")
66
processor = Wav2Vec2Processor.from_pretrained('tanmaylaud/wav2vec2-large-xlsr-hindi-marathi')
67
model = Wav2Vec2ForCTC.from_pretrained('tanmaylaud/wav2vec2-large-xlsr-hindi-marathi').to("cuda")
68
69
# Preprocessing the datasets.
70
# We need to read the audio files as arrays
71
def speech_file_to_array_fn(batch):
72
    batch["sentence"] = re.sub(chars_to_ignore_regex, '', batch["sentence"])
73
    speech_array, sampling_rate = torchaudio.load(batch["path"])
74
    batch["speech"] = speech_array[0].numpy()
75
    batch["sampling_rate"] = sampling_rate
76
    batch["target_text"] = batch["sentence"]
77
    batch["speech"] = librosa.resample(np.asarray(batch["speech"]), sampling_rate, 16_000)
78
    batch["sampling_rate"] = 16_000
79
    return batch
80
81
test_data= test_data.map(speech_file_to_array_fn)
82
inputs = processor(test_data["speech"][:2], sampling_rate=16_000, return_tensors="pt", padding=True)
83
84
with torch.no_grad():
85
    logits = model(inputs.input_values, attention_mask=inputs.attention_mask).logits
86
87
predicted_ids = torch.argmax(logits, dim=-1)
88
89
print("Prediction:", processor.batch_decode(predicted_ids))
90
print("Reference:", test_data["text"][:2])
91
```
92
93
94
95
# Code For Evaluation on OpenSLR (Hindi + Marathi : https://filebin.net/snrz6bt13usv8w2e/test_large.csv)
96
```python
97
import torchaudio
98
import torch
99
import librosa
100
import numpy as np
101
import re
102
103
test = Dataset.from_csv('test.csv')
104
105
106
chars_to_ignore_regex = '[\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\,\\\\\\\\\\\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\�\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\।]'
107
108
# Preprocessing the datasets.
109
# We need to read the audio files as arrays
110
def speech_file_to_array_fn(batch):
111
    batch["sentence"] = re.sub(chars_to_ignore_regex, '', batch["sentence"])
112
    speech_array, sampling_rate = torchaudio.load(batch["path"])
113
    batch["speech"] = speech_array[0].numpy()
114
    batch["sampling_rate"] = sampling_rate
115
    batch["target_text"] = batch["sentence"]
116
    batch["speech"] = librosa.resample(np.asarray(batch["speech"]), sampling_rate, 16_000)
117
    batch["sampling_rate"] = 16_000
118
    return batch
119
120
test= test.map(speech_file_to_array_fn)
121
122
# Preprocessing the datasets.
123
# We need to read the audio files as arrays
124
def evaluate(batch):
125
    inputs = processor(batch["speech"], sampling_rate=16_000, return_tensors="pt", padding=True)
126
    with torch.no_grad():
127
        logits = model(inputs.input_values.to("cuda"), attention_mask=inputs.attention_mask.to("cuda")).logits
128
        pred_ids = torch.argmax(logits, dim=-1)
129
        # we do not want to group tokens when computing the metrics
130
        batch["pred_strings"] = processor.batch_decode(pred_ids)
131
        return batch
132
133
test = test.map(evaluate, batched=True, batch_size=32)
134
print("WER: {:2f}".format(100 * wer.compute(predictions=test["pred_strings"], references=test["sentence"])))
135
```
136
137
138
139
#### Code for Evaluation on Common Voice Hindi (Common voice does not have Marathi yet)
140
```python
141
import torchaudio
142
import torch
143
import librosa
144
import numpy as np
145
import re
146
from datasets import load_metric, load_dataset, Dataset
147
from transformers import Wav2Vec2Processor, Wav2Vec2ForCTC
148
149
wer = load_metric("wer")
150
processor = Wav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\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\”\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\�\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\।]'
154
155
# Preprocessing the datasets.
156
# We need to read the audio files as arrays
157
def speech_file_to_array_fn(batch):
158
    batch["sentence"] = re.sub(chars_to_ignore_regex, '', batch["sentence"])
159
    speech_array, sampling_rate = torchaudio.load(batch["path"])
160
    batch["speech"] = speech_array[0].numpy()
161
    batch["sampling_rate"] = sampling_rate
162
    batch["target_text"] = batch["sentence"]
163
    batch["speech"] = librosa.resample(np.asarray(batch["speech"]), sampling_rate, 16_000)
164
    batch["sampling_rate"] = 16_000
165
    return batch
166
  
167
#Run prediction on batch  
168
def evaluate(batch):
169
    inputs = processor(batch["speech"], sampling_rate=16_000, return_tensors="pt", padding=True)
170
    with torch.no_grad():
171
        logits = model(inputs.input_values.to("cuda"), attention_mask=inputs.attention_mask.to("cuda")).logits
172
        pred_ids = torch.argmax(logits, dim=-1)
173
        # we do not want to group tokens when computing the metrics
174
        batch["pred_strings"] = processor.batch_decode(pred_ids)
175
        return batch
176
177
178
test_data = load_dataset("common_voice", "hi", split="test")
179
test_data = test_data.map(speech_file_to_array_fn)
180
test_data = test_data.map(evaluate, batched=True, batch_size=32)
181
print("WER: {:2f}".format(100 * wer.compute(predictions=test_data["pred_strings"],
182
                                            references=test_data["sentence"])))
183
```
184
185
Link to eval notebook : https://colab.research.google.com/drive/1nZRTgKfxCD9cvy90wikTHkg2il3zgcqW#scrollTo=cXWFbhb0d7DT
186
187
WER :  23.736641% (OpenSLR Hindi+Marathi Test set : https://filebin.net/snrz6bt13usv8w2e/test_large.csv)
188
189
190
WER: 44.083527% (Common Voice Hindi Test Split)