Update README.md
Browse filesChanged evaluation script resampler to librosa which was used in the model training. This improves the WER score a little bit.
README.md
CHANGED
@@ -23,7 +23,7 @@ model-index:
|
|
23 |
metrics:
|
24 |
- name: Test WER
|
25 |
type: wer
|
26 |
-
value: 32.
|
27 |
---
|
28 |
|
29 |
# Wav2Vec2-Large-XLSR-53-Finnish
|
@@ -74,6 +74,7 @@ The model can be evaluated as follows on the Finnish test data of Common Voice.
|
|
74 |
|
75 |
|
76 |
```python
|
|
|
77 |
import torch
|
78 |
import torchaudio
|
79 |
from datasets import load_dataset, load_metric
|
@@ -88,14 +89,14 @@ model = Wav2Vec2ForCTC.from_pretrained("aapot/wav2vec2-large-xlsr-53-finnish")
|
|
88 |
model.to("cuda")
|
89 |
|
90 |
chars_to_ignore_regex = '[\,\?\.\!\-\;\:\"\“\%\‘\”\�\'\...\…\–\é]'
|
91 |
-
resampler = lambda sr:
|
92 |
|
93 |
# Preprocessing the datasets.
|
94 |
# We need to read the audio files as arrays
|
95 |
def speech_file_to_array_fn(batch):
|
96 |
batch["sentence"] = re.sub(chars_to_ignore_regex, '', batch["sentence"]).lower()
|
97 |
speech_array, sampling_rate = torchaudio.load(batch["path"])
|
98 |
-
batch["speech"] = resampler(sampling_rate)(speech_array).squeeze()
|
99 |
return batch
|
100 |
|
101 |
test_dataset = test_dataset.map(speech_file_to_array_fn)
|
@@ -117,7 +118,7 @@ result = test_dataset.map(evaluate, batched=True, batch_size=8)
|
|
117 |
print("WER: {:2f}".format(100 * wer.compute(predictions=result["pred_strings"], references=result["sentence"])))
|
118 |
```
|
119 |
|
120 |
-
**Test Result**: 32.
|
121 |
|
122 |
|
123 |
## Training
|
|
|
23 |
metrics:
|
24 |
- name: Test WER
|
25 |
type: wer
|
26 |
+
value: 32.378771
|
27 |
---
|
28 |
|
29 |
# Wav2Vec2-Large-XLSR-53-Finnish
|
|
|
74 |
|
75 |
|
76 |
```python
|
77 |
+
import librosa
|
78 |
import torch
|
79 |
import torchaudio
|
80 |
from datasets import load_dataset, load_metric
|
|
|
89 |
model.to("cuda")
|
90 |
|
91 |
chars_to_ignore_regex = '[\,\?\.\!\-\;\:\"\“\%\‘\”\�\'\...\…\–\é]'
|
92 |
+
resampler = lambda sr: lambda y: librosa.resample(y.numpy().squeeze(), sr, 16_000)
|
93 |
|
94 |
# Preprocessing the datasets.
|
95 |
# We need to read the audio files as arrays
|
96 |
def speech_file_to_array_fn(batch):
|
97 |
batch["sentence"] = re.sub(chars_to_ignore_regex, '', batch["sentence"]).lower()
|
98 |
speech_array, sampling_rate = torchaudio.load(batch["path"])
|
99 |
+
batch["speech"] = resampler(sampling_rate)(speech_array).squeeze()
|
100 |
return batch
|
101 |
|
102 |
test_dataset = test_dataset.map(speech_file_to_array_fn)
|
|
|
118 |
print("WER: {:2f}".format(100 * wer.compute(predictions=result["pred_strings"], references=result["sentence"])))
|
119 |
```
|
120 |
|
121 |
+
**Test Result**: 32.378771 %
|
122 |
|
123 |
|
124 |
## Training
|