Update README.md
Browse files
README.md
CHANGED
@@ -6,7 +6,6 @@ tags:
|
|
6 |
- audio
|
7 |
- automatic-speech-recognition
|
8 |
- speech
|
9 |
-
- xlsr-fine-tuning-week
|
10 |
license: apache-2.0
|
11 |
model-index:
|
12 |
- name: XLSR Wav2Vec2 Egyptian by Zaid Alyafeai and Othmane Rifki
|
@@ -40,13 +39,13 @@ resampler = torchaudio.transforms.Resample(48_000, 16_000)
|
|
40 |
# Preprocessing the datasets.
|
41 |
# We need to read the aduio files as arrays
|
42 |
def speech_file_to_array_fn(batch):
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
test_dataset = test_dataset.map(speech_file_to_array_fn)
|
47 |
inputs = processor(test_dataset["speech"][:2], sampling_rate=16_000, return_tensors="pt", padding=True)
|
48 |
with torch.no_grad():
|
49 |
-
|
50 |
predicted_ids = torch.argmax(logits, dim=-1)
|
51 |
print("Prediction:", processor.batch_decode(predicted_ids))
|
52 |
print("Reference:", test_dataset["sentence"][:2])
|
|
|
6 |
- audio
|
7 |
- automatic-speech-recognition
|
8 |
- speech
|
|
|
9 |
license: apache-2.0
|
10 |
model-index:
|
11 |
- name: XLSR Wav2Vec2 Egyptian by Zaid Alyafeai and Othmane Rifki
|
|
|
39 |
# Preprocessing the datasets.
|
40 |
# We need to read the aduio files as arrays
|
41 |
def speech_file_to_array_fn(batch):
|
42 |
+
\\tspeech_array, sampling_rate = torchaudio.load(batch["path"])
|
43 |
+
\\tbatch["speech"] = resampler(speech_array).squeeze().numpy()
|
44 |
+
\\treturn batch
|
45 |
test_dataset = test_dataset.map(speech_file_to_array_fn)
|
46 |
inputs = processor(test_dataset["speech"][:2], sampling_rate=16_000, return_tensors="pt", padding=True)
|
47 |
with torch.no_grad():
|
48 |
+
\\tlogits = model(inputs.input_values, attention_mask=inputs.attention_mask).logits
|
49 |
predicted_ids = torch.argmax(logits, dim=-1)
|
50 |
print("Prediction:", processor.batch_decode(predicted_ids))
|
51 |
print("Reference:", test_dataset["sentence"][:2])
|