Update README.md
Browse files
README.md
CHANGED
@@ -84,16 +84,16 @@ processor = Wav2Vec2Processor.from_pretrained("mrm8488/wav2vec2-large-xlsr-53-eu
|
|
84 |
model = Wav2Vec2ForCTC.from_pretrained("mrm8488/wav2vec2-large-xlsr-53-euskera")
|
85 |
model.to("cuda")
|
86 |
|
87 |
-
chars_to_ignore_regex = '[
|
88 |
resampler = torchaudio.transforms.Resample(48_000, 16_000)
|
89 |
|
90 |
# Preprocessing the datasets.
|
91 |
# We need to read the aduio files as arrays
|
92 |
def speech_file_to_array_fn(batch):
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
|
98 |
test_dataset = test_dataset.map(speech_file_to_array_fn)
|
99 |
|
|
|
84 |
model = Wav2Vec2ForCTC.from_pretrained("mrm8488/wav2vec2-large-xlsr-53-euskera")
|
85 |
model.to("cuda")
|
86 |
|
87 |
+
chars_to_ignore_regex = '[\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\,\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\?\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\.\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\!\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\-\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\;\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\:\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\“]'
|
88 |
resampler = torchaudio.transforms.Resample(48_000, 16_000)
|
89 |
|
90 |
# Preprocessing the datasets.
|
91 |
# We need to read the aduio files as arrays
|
92 |
def speech_file_to_array_fn(batch):
|
93 |
+
batch["sentence"] = re.sub(chars_to_ignore_regex, '', batch["sentence"]).lower()
|
94 |
+
speech_array, sampling_rate = torchaudio.load(batch["path"])
|
95 |
+
batch["speech"] = resampler(speech_array).squeeze().numpy()
|
96 |
+
return batch
|
97 |
|
98 |
test_dataset = test_dataset.map(speech_file_to_array_fn)
|
99 |
|