gchhablani
commited on
Commit
•
0f21b66
1
Parent(s):
c66bf50
Update README.md
Browse files
README.md
CHANGED
@@ -85,7 +85,7 @@ processor = Wav2Vec2Processor.from_pretrained("gchhablani/wav2vec2-large-xlsr-mr
|
|
85 |
model = Wav2Vec2ForCTC.from_pretrained("gchhablani/wav2vec2-large-xlsr-mr")
|
86 |
model.to("cuda")
|
87 |
|
88 |
-
chars_to_ignore_regex = '[
|
89 |
resampler = torchaudio.transforms.Resample(48_000, 16_000)
|
90 |
|
91 |
# Preprocessing the datasets.
|
@@ -102,13 +102,12 @@ test_dataset = test_dataset.map(speech_file_to_array_fn)
|
|
102 |
# We need to read the aduio files as arrays
|
103 |
def evaluate(batch):
|
104 |
inputs = processor(batch["speech"], sampling_rate=16_000, return_tensors="pt", padding=True)
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
batch
|
111 |
-
return batch
|
112 |
|
113 |
result = test_dataset.map(evaluate, batched=True, batch_size=8)
|
114 |
|
85 |
model = Wav2Vec2ForCTC.from_pretrained("gchhablani/wav2vec2-large-xlsr-mr")
|
86 |
model.to("cuda")
|
87 |
|
88 |
+
chars_to_ignore_regex = '[\\,\\?\\.\\!\\-\\;\\:\\"\\“\\%\\‘\\”\\�\\–\\…]'
|
89 |
resampler = torchaudio.transforms.Resample(48_000, 16_000)
|
90 |
|
91 |
# Preprocessing the datasets.
|
102 |
# We need to read the aduio files as arrays
|
103 |
def evaluate(batch):
|
104 |
inputs = processor(batch["speech"], sampling_rate=16_000, return_tensors="pt", padding=True)
|
105 |
+
with torch.no_grad():
|
106 |
+
logits = model(inputs.input_values.to("cuda"),
|
107 |
+
attention_mask=inputs.attention_mask.to("cuda")).logits
|
108 |
+
pred_ids = torch.argmax(logits, dim=-1)
|
109 |
+
batch["pred_strings"] = processor.batch_decode(pred_ids)
|
110 |
+
return batch
|
|
|
111 |
|
112 |
result = test_dataset.map(evaluate, batched=True, batch_size=8)
|
113 |
|