MehdiHosseiniMoghadam
commited on
Commit
·
af65c77
1
Parent(s):
703791c
Update README.md
Browse files
README.md
CHANGED
@@ -130,7 +130,7 @@ model = Wav2Vec2ForCTC.from_pretrained("MehdiHosseiniMoghadam/wav2vec2-large-xls
|
|
130 |
|
131 |
model.to("cuda")
|
132 |
|
133 |
-
chars_to_ignore_regex = '[
|
134 |
|
135 |
resampler = torchaudio.transforms.Resample(48_000, 16_000)
|
136 |
|
@@ -156,17 +156,17 @@ test_dataset = test_dataset.map(speech_file_to_array_fn)
|
|
156 |
|
157 |
def evaluate(batch):
|
158 |
|
159 |
-
inputs = processor(batch["speech"], sampling_rate=16_000, return_tensors="pt", padding=True)
|
160 |
-
|
161 |
-
with torch.no_grad():
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
pred_ids = torch.argmax(logits, dim=-1)
|
166 |
-
|
167 |
-
batch["pred_strings"] = processor.batch_decode(pred_ids)
|
168 |
-
|
169 |
-
return batch
|
170 |
|
171 |
result = test_dataset.map(evaluate, batched=True, batch_size=8)
|
172 |
|
|
|
130 |
|
131 |
model.to("cuda")
|
132 |
|
133 |
+
chars_to_ignore_regex = '[\\,\\?\\.\\!\\-\\;\\:\\"\\“]'
|
134 |
|
135 |
resampler = torchaudio.transforms.Resample(48_000, 16_000)
|
136 |
|
|
|
156 |
|
157 |
def evaluate(batch):
|
158 |
|
159 |
+
inputs = processor(batch["speech"], sampling_rate=16_000, return_tensors="pt", padding=True)
|
160 |
+
|
161 |
+
with torch.no_grad():
|
162 |
+
|
163 |
+
logits = model(inputs.input_values.to("cuda"), attention_mask=inputs.attention_mask.to("cuda")).logits
|
164 |
+
|
165 |
+
pred_ids = torch.argmax(logits, dim=-1)
|
166 |
+
|
167 |
+
batch["pred_strings"] = processor.batch_decode(pred_ids)
|
168 |
+
|
169 |
+
return batch
|
170 |
|
171 |
result = test_dataset.map(evaluate, batched=True, batch_size=8)
|
172 |
|