ctl commited on
Commit
0fb42e9
·
1 Parent(s): 8cc63c8

Update evaluation script

Browse files
Files changed (1) hide show
  1. README.md +7 -7
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
- speech_array, sampling_rate = torchaudio.load(batch["path"])
58
- batch["speech"] = resampler(speech_array).squeeze().numpy()
59
- return 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
- logits = model(inputs.input_values, attention_mask=inputs.attention_mask).logits
66
 
67
  predicted_ids = torch.argmax(logits, dim=-1)
68
 
@@ -90,7 +90,7 @@ import argparse
90
  lang_id = "zh-HK"
91
  model_id = "ctl/wav2vec2-large-xlsr-cantonese"
92
 
93
- chars_to_ignore_regex = '[\,\?\.\!\-\;\:"\“\%\‘\”\�\.\⋯\!\-\:\–\。\》\,\)\,\?\;\~\~\…\︰\,\(\」\‧\《\﹔\、\—\/\,\「\﹖\·\']'
94
 
95
  test_dataset = load_dataset("common_voice", f"{lang_id}", split="test")
96
  cer = load_metric("./cer")
@@ -135,7 +135,7 @@ Adapting code from [wer](https://github.com/huggingface/datasets/blob/master/met
135
  @datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION, _KWARGS_DESCRIPTION)
136
  class CER(datasets.Metric):
137
  def _info(self):
138
- ...
139
 
140
  def _compute(self, predictions, references):
141
  preds = [char for seq in predictions for char in list(seq)]
@@ -144,7 +144,7 @@ class CER(datasets.Metric):
144
  ```
145
 
146
 
147
- **Test Result**: 15.36 %
148
 
149
 
150
  ## Training
 
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
 
 
90
  lang_id = "zh-HK"
91
  model_id = "ctl/wav2vec2-large-xlsr-cantonese"
92
 
93
+ chars_to_ignore_regex = '[\\,\\?\\.\\!\\-\\;\\:"\\“\\%\\‘\\”\\�\\.\\⋯\\!\\-\\:\\–\\。\\》\\,\\)\\,\\?\\;\\~\\~\\…\\︰\\,\\(\\」\\‧\\《\\﹔\\、\\—\\/\\,\\「\\﹖\\·\\']'
94
 
95
  test_dataset = load_dataset("common_voice", f"{lang_id}", split="test")
96
  cer = load_metric("./cer")
 
135
  @datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION, _KWARGS_DESCRIPTION)
136
  class CER(datasets.Metric):
137
  def _info(self):
138
+ \t...
139
 
140
  def _compute(self, predictions, references):
141
  preds = [char for seq in predictions for char in list(seq)]
 
144
  ```
145
 
146
 
147
+ **Test Result**: 15.51 %
148
 
149
 
150
  ## Training