diego-fustes
commited on
Commit
•
6c06c78
1
Parent(s):
4ffebb7
Update README.md
Browse files
README.md
CHANGED
@@ -54,15 +54,15 @@ resampler = torchaudio.transforms.Resample(48_000, 16_000)
|
|
54 |
# Preprocessing the datasets.
|
55 |
# We need to read the aduio files as arrays
|
56 |
def speech_file_to_array_fn(batch):
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
|
61 |
test_dataset = test_dataset.map(speech_file_to_array_fn)
|
62 |
inputs = processor(test_dataset["speech"][:2], sampling_rate=16_000, return_tensors="pt", padding=True)
|
63 |
|
64 |
with torch.no_grad():
|
65 |
-
|
66 |
|
67 |
predicted_ids = torch.argmax(logits, dim=-1)
|
68 |
|
@@ -95,24 +95,24 @@ resampler = torchaudio.transforms.Resample(48_000, 16_000)
|
|
95 |
# Preprocessing the datasets.
|
96 |
# We need to read the aduio files as arrays
|
97 |
def speech_file_to_array_fn(batch):
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
|
103 |
test_dataset = test_dataset.map(speech_file_to_array_fn)
|
104 |
|
105 |
# Preprocessing the datasets.
|
106 |
# We need to read the aduio files as arrays
|
107 |
def evaluate(batch):
|
108 |
-
|
109 |
|
110 |
-
|
111 |
-
|
112 |
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
|
117 |
result = test_dataset.map(evaluate, batched=True, batch_size=8)
|
118 |
|
@@ -124,6 +124,6 @@ print("WER: {:2f}".format(100 * wer.compute(predictions=result["pred_strings"],
|
|
124 |
|
125 |
## Training
|
126 |
|
127 |
-
The OpenSLR 77 dataset was used for training and validation. The dataset was split as
|
128 |
|
129 |
The script used for training can be found [here](https://github.com/diego-fustes/xlsr-fine-tuning-gl)
|
54 |
# Preprocessing the datasets.
|
55 |
# We need to read the aduio files as arrays
|
56 |
def speech_file_to_array_fn(batch):
|
57 |
+
\tspeech_array, sampling_rate = torchaudio.load(batch["path"])
|
58 |
+
\tbatch["speech"] = resampler(speech_array).squeeze().numpy()
|
59 |
+
\treturn batch
|
60 |
|
61 |
test_dataset = test_dataset.map(speech_file_to_array_fn)
|
62 |
inputs = processor(test_dataset["speech"][:2], sampling_rate=16_000, return_tensors="pt", padding=True)
|
63 |
|
64 |
with torch.no_grad():
|
65 |
+
\tlogits = model(inputs.input_values, attention_mask=inputs.attention_mask).logits
|
66 |
|
67 |
predicted_ids = torch.argmax(logits, dim=-1)
|
68 |
|
95 |
# Preprocessing the datasets.
|
96 |
# We need to read the aduio files as arrays
|
97 |
def speech_file_to_array_fn(batch):
|
98 |
+
\tbatch["sentence"] = re.sub(chars_to_ignore_regex, '', batch["sentence"]).lower()
|
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 |
|
105 |
# Preprocessing the datasets.
|
106 |
# We need to read the aduio files as arrays
|
107 |
def evaluate(batch):
|
108 |
+
\tinputs = processor(batch["speech"], sampling_rate=16_000, return_tensors="pt", padding=True)
|
109 |
|
110 |
+
\twith torch.no_grad():
|
111 |
+
\t\tlogits = model(inputs.input_values.to("cuda"), attention_mask=inputs.attention_mask.to("cuda")).logits
|
112 |
|
113 |
+
\tpred_ids = torch.argmax(logits, dim=-1)
|
114 |
+
\tbatch["pred_strings"] = processor.batch_decode(pred_ids)
|
115 |
+
\treturn batch
|
116 |
|
117 |
result = test_dataset.map(evaluate, batched=True, batch_size=8)
|
118 |
|
124 |
|
125 |
## Training
|
126 |
|
127 |
+
The OpenSLR [SLR77](https://openslr.org/77/) dataset was used for training and validation. The dataset was split as 70% for training, 15% for validation and 15% for testing
|
128 |
|
129 |
The script used for training can be found [here](https://github.com/diego-fustes/xlsr-fine-tuning-gl)
|