ayameRushia
commited on
Commit
•
2671b17
1
Parent(s):
ad40821
Update README.md
Browse files
README.md
CHANGED
@@ -64,18 +64,22 @@ wer = load_metric("wer")
|
|
64 |
processor = Wav2Vec2Processor.from_pretrained("ayameRushia/wav2vec2-large-xlsr-indonesia-demo")
|
65 |
model = Wav2Vec2ForCTC.from_pretrained("ayameRushia/wav2vec2-large-xlsr-indonesia-demo")
|
66 |
model.to("cuda")
|
67 |
-
chars_to_ignore_regex = '[
|
68 |
resampler = torchaudio.transforms.Resample(48_000, 16_000)
|
69 |
# Preprocessing the datasets.
|
70 |
# We need to read the aduio files as arrays
|
|
|
71 |
def speech_file_to_array_fn(batch):
|
72 |
batch["sentence"] = re.sub(chars_to_ignore_regex, '', batch["sentence"]).lower()
|
73 |
speech_array, sampling_rate = torchaudio.load(batch["path"])
|
|
|
74 |
batch["speech"] = resampler(speech_array).squeeze().numpy()
|
75 |
return batch
|
|
|
76 |
test_dataset = test_dataset.map(speech_file_to_array_fn)
|
77 |
# Preprocessing the datasets.
|
78 |
# We need to read the aduio files as arrays
|
|
|
79 |
def evaluate(batch):
|
80 |
inputs = processor(batch["speech"], sampling_rate=16_000, return_tensors="pt", padding=True)
|
81 |
with torch.no_grad():
|
@@ -87,6 +91,6 @@ result = test_dataset.map(evaluate, batched=True, batch_size=8)
|
|
87 |
print("WER: {:2f}".format(100 * wer.compute(predictions=result["pred_strings"], references=result["sentence"])))
|
88 |
```
|
89 |
**Test Result**:
|
90 |
-
WER =
|
91 |
## Training
|
92 |
Training using common voice dataset
|
64 |
processor = Wav2Vec2Processor.from_pretrained("ayameRushia/wav2vec2-large-xlsr-indonesia-demo")
|
65 |
model = Wav2Vec2ForCTC.from_pretrained("ayameRushia/wav2vec2-large-xlsr-indonesia-demo")
|
66 |
model.to("cuda")
|
67 |
+
chars_to_ignore_regex = '[\\,\\?\\.\\!\\-\\;\\:\\"\\“]'
|
68 |
resampler = torchaudio.transforms.Resample(48_000, 16_000)
|
69 |
# Preprocessing the datasets.
|
70 |
# We need to read the aduio files as arrays
|
71 |
+
|
72 |
def speech_file_to_array_fn(batch):
|
73 |
batch["sentence"] = re.sub(chars_to_ignore_regex, '', batch["sentence"]).lower()
|
74 |
speech_array, sampling_rate = torchaudio.load(batch["path"])
|
75 |
+
resampler = torchaudio.transforms.Resample(sampling_rate, 16_000)
|
76 |
batch["speech"] = resampler(speech_array).squeeze().numpy()
|
77 |
return batch
|
78 |
+
|
79 |
test_dataset = test_dataset.map(speech_file_to_array_fn)
|
80 |
# Preprocessing the datasets.
|
81 |
# We need to read the aduio files as arrays
|
82 |
+
|
83 |
def evaluate(batch):
|
84 |
inputs = processor(batch["speech"], sampling_rate=16_000, return_tensors="pt", padding=True)
|
85 |
with torch.no_grad():
|
91 |
print("WER: {:2f}".format(100 * wer.compute(predictions=result["pred_strings"], references=result["sentence"])))
|
92 |
```
|
93 |
**Test Result**:
|
94 |
+
WER = 20.072720 %
|
95 |
## Training
|
96 |
Training using common voice dataset
|