aapot commited on
Commit
e1b25ea
1 Parent(s): f652ff2

Update README.md

Browse files

Updated evaluation script to handle different sample rates occurring in the Finnish Common Voice test dataset

Files changed (1) hide show
  1. README.md +4 -4
README.md CHANGED
@@ -23,7 +23,7 @@ model-index:
23
  metrics:
24
  - name: Test WER
25
  type: wer
26
- value: 33.333333
27
  ---
28
 
29
  # Wav2Vec2-Large-XLSR-53-Finnish
@@ -88,14 +88,14 @@ model = Wav2Vec2ForCTC.from_pretrained("aapot/wav2vec2-large-xlsr-53-finnish")
88
  model.to("cuda")
89
 
90
  chars_to_ignore_regex = '[\,\?\.\!\-\;\:\"\“\%\‘\”\�\'\...\…\–\é]'
91
- resampler = torchaudio.transforms.Resample(48_000, 16_000)
92
 
93
  # Preprocessing the datasets.
94
  # We need to read the audio files as arrays
95
  def speech_file_to_array_fn(batch):
96
  batch["sentence"] = re.sub(chars_to_ignore_regex, '', batch["sentence"]).lower()
97
  speech_array, sampling_rate = torchaudio.load(batch["path"])
98
- batch["speech"] = resampler(speech_array).squeeze().numpy()
99
  return batch
100
 
101
  test_dataset = test_dataset.map(speech_file_to_array_fn)
@@ -117,7 +117,7 @@ result = test_dataset.map(evaluate, batched=True, batch_size=8)
117
  print("WER: {:2f}".format(100 * wer.compute(predictions=result["pred_strings"], references=result["sentence"])))
118
  ```
119
 
120
- **Test Result**: 33.333333 %
121
 
122
 
123
  ## Training
 
23
  metrics:
24
  - name: Test WER
25
  type: wer
26
+ value: 32.607866
27
  ---
28
 
29
  # Wav2Vec2-Large-XLSR-53-Finnish
 
88
  model.to("cuda")
89
 
90
  chars_to_ignore_regex = '[\,\?\.\!\-\;\:\"\“\%\‘\”\�\'\...\…\–\é]'
91
+ resampler = lambda sr: torchaudio.transforms.Resample(sr, 16_000)
92
 
93
  # Preprocessing the datasets.
94
  # We need to read the audio files as arrays
95
  def speech_file_to_array_fn(batch):
96
  batch["sentence"] = re.sub(chars_to_ignore_regex, '', batch["sentence"]).lower()
97
  speech_array, sampling_rate = torchaudio.load(batch["path"])
98
+ batch["speech"] = resampler(sampling_rate)(speech_array).squeeze().numpy()
99
  return batch
100
 
101
  test_dataset = test_dataset.map(speech_file_to_array_fn)
 
117
  print("WER: {:2f}".format(100 * wer.compute(predictions=result["pred_strings"], references=result["sentence"])))
118
  ```
119
 
120
+ **Test Result**: 32.607866 %
121
 
122
 
123
  ## Training