Update README.md
Browse files
README.md
CHANGED
@@ -69,7 +69,7 @@ print("Reference:", test_dataset["sentence"][:2])
|
|
69 |
|
70 |
## Evaluation
|
71 |
|
72 |
-
The model can be evaluated as follows on the {language} test data of Common Voice.
|
73 |
|
74 |
|
75 |
```python
|
@@ -79,24 +79,26 @@ from datasets import load_dataset, load_metric
|
|
79 |
from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
|
80 |
import re
|
81 |
|
82 |
-
test_dataset = load_dataset("common_voice", "de", split="test")
|
83 |
wer = load_metric("wer")
|
84 |
|
85 |
-
processor = Wav2Vec2Processor.from_pretrained("de")
|
86 |
-
|
|
|
|
|
87 |
model.to("cuda")
|
88 |
|
89 |
-
chars_to_ignore_regex = '[
|
90 |
resampler = torchaudio.transforms.Resample(48_000, 16_000)
|
91 |
|
92 |
# Preprocessing the datasets.
|
93 |
# We need to read the aduio files as arrays
|
94 |
def speech_file_to_array_fn(batch):
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
|
101 |
test_dataset = test_dataset.map(speech_file_to_array_fn)
|
102 |
|
|
|
69 |
|
70 |
## Evaluation
|
71 |
|
72 |
+
The model can be evaluated as follows on the {language} test data of Common Voice.
|
73 |
|
74 |
|
75 |
```python
|
|
|
79 |
from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
|
80 |
import re
|
81 |
|
82 |
+
test_dataset = load_dataset("common_voice", "de", split="test") [this](https://huggingface.co/languages) site.
|
83 |
wer = load_metric("wer")
|
84 |
|
85 |
+
processor = Wav2Vec2Processor.from_pretrained("de")
|
86 |
+
`elgeish/wav2vec2-large-xlsr-53-arabic`
|
87 |
+
model = Wav2Vec2ForCTC.from_pretrained("de")
|
88 |
+
`elgeish/wav2vec2-large-xlsr-53-arabic`
|
89 |
model.to("cuda")
|
90 |
|
91 |
+
chars_to_ignore_regex = '[\\,\\?\\.\\!\\-\\;\\:\\"\\“]'
|
92 |
resampler = torchaudio.transforms.Resample(48_000, 16_000)
|
93 |
|
94 |
# Preprocessing the datasets.
|
95 |
# We need to read the aduio files as arrays
|
96 |
def speech_file_to_array_fn(batch):
|
97 |
+
\\\\tbatch["sentence"] = re.sub(chars_to_ignore_regex, '', batch["sentence"]).lower()
|
98 |
+
\\\\tbatch["sentence"] = re.sub('\\ß', 'ss', batch["sentence"])
|
99 |
+
\\\\tspeech_array, sampling_rate = torchaudio.load(batch["path"])
|
100 |
+
\\\\tbatch["speech"] = resampler(speech_array).squeeze().numpy()
|
101 |
+
\\\\treturn batch
|
102 |
|
103 |
test_dataset = test_dataset.map(speech_file_to_array_fn)
|
104 |
|