chrisjay commited on
Commit
eef64a9
·
1 Parent(s): f6c0eb1

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +9 -7
README.md CHANGED
@@ -20,11 +20,13 @@ model-index:
20
  - task:
21
  name: Speech Recognition
22
  type: automatic-speech-recognition
 
23
  dataset:
24
  name: fon
25
  type: fon_dataset
26
  args: fon
27
- metrics:
 
28
  - name: Test WER
29
  type: wer
30
  value: 14.97
@@ -137,7 +139,7 @@ for root, dirs, files in os.walk(test_path):
137
  test_dataset= load_dataset("json", data_files=[os.path.join(root,i) for i in files],split="train")
138
 
139
  #Remove unnecessary chars
140
- chars_to_ignore_regex = '[\\\\\\\\,\\\\\\\\?\\\\\\\\.\\\\\\\\!\\\\\\\\-\\\\\\\\;\\\\\\\\:\\\\\\\\"\\\\\\\\“\\\\\\\\%\\\\\\\\‘\\\\\\\\”\\\\\\\\�]'
141
  def remove_special_characters(batch):
142
  batch["sentence"] = re.sub(chars_to_ignore_regex, '', batch["sentence"]).lower() + " "
143
  return batch
@@ -153,15 +155,15 @@ model = Wav2Vec2ForCTC.from_pretrained("chrisjay/wav2vec2-large-xlsr-53-fon")
153
  # Preprocessing the datasets.
154
  # We need to read the audio files as arrays
155
  def speech_file_to_array_fn(batch):
156
- \\\\tspeech_array, sampling_rate = torchaudio.load(batch["path"])
157
- \\\\tbatch["speech"]=speech_array.squeeze().numpy()
158
- \\\\treturn batch
159
 
160
  test_dataset = test_dataset.map(speech_file_to_array_fn)
161
  inputs = processor(test_dataset["speech"][:2], sampling_rate=16_000, return_tensors="pt", padding=True)
162
 
163
  with torch.no_grad():
164
- \\\\tlogits = model(inputs.input_values, attention_mask=inputs.attention_mask).logits
165
 
166
  predicted_ids = torch.argmax(logits, dim=-1)
167
 
@@ -184,7 +186,7 @@ import re
184
  for root, dirs, files in os.walk(test_path):
185
  test_dataset = load_dataset("json", data_files=[os.path.join(root,i) for i in files],split="train")
186
 
187
- chars_to_ignore_regex = '[\\\\\\\\,\\\\\\\\?\\\\\\\\.\\\\\\\\!\\\\\\\\-\\\\\\\\;\\\\\\\\:\\\\\\\\"\\\\\\\\“\\\\\\\\%\\\\\\\\‘\\\\\\\\”\\\\\\\\�]'
188
  def remove_special_characters(batch):
189
  batch["sentence"] = re.sub(chars_to_ignore_regex, '', batch["sentence"]).lower() + " "
190
  return batch
 
20
  - task:
21
  name: Speech Recognition
22
  type: automatic-speech-recognition
23
+
24
  dataset:
25
  name: fon
26
  type: fon_dataset
27
  args: fon
28
+
29
+ metrics:
30
  - name: Test WER
31
  type: wer
32
  value: 14.97
 
139
  test_dataset= load_dataset("json", data_files=[os.path.join(root,i) for i in files],split="train")
140
 
141
  #Remove unnecessary chars
142
+ chars_to_ignore_regex = '[\\\\\\\\\\\\\\\\,\\\\\\\\\\\\\\\\?\\\\\\\\\\\\\\\\.\\\\\\\\\\\\\\\\!\\\\\\\\\\\\\\\\-\\\\\\\\\\\\\\\\;\\\\\\\\\\\\\\\\:\\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\“\\\\\\\\\\\\\\\\%\\\\\\\\\\\\\\\\‘\\\\\\\\\\\\\\\\”\\\\\\\\\\\\\\\\�]'
143
  def remove_special_characters(batch):
144
  batch["sentence"] = re.sub(chars_to_ignore_regex, '', batch["sentence"]).lower() + " "
145
  return batch
 
155
  # Preprocessing the datasets.
156
  # We need to read the audio files as arrays
157
  def speech_file_to_array_fn(batch):
158
+ \\\\\\\\tspeech_array, sampling_rate = torchaudio.load(batch["path"])
159
+ \\\\\\\\tbatch["speech"]=speech_array.squeeze().numpy()
160
+ \\\\\\\\treturn batch
161
 
162
  test_dataset = test_dataset.map(speech_file_to_array_fn)
163
  inputs = processor(test_dataset["speech"][:2], sampling_rate=16_000, return_tensors="pt", padding=True)
164
 
165
  with torch.no_grad():
166
+ \\\\\\\\tlogits = model(inputs.input_values, attention_mask=inputs.attention_mask).logits
167
 
168
  predicted_ids = torch.argmax(logits, dim=-1)
169
 
 
186
  for root, dirs, files in os.walk(test_path):
187
  test_dataset = load_dataset("json", data_files=[os.path.join(root,i) for i in files],split="train")
188
 
189
+ chars_to_ignore_regex = '[\\\\\\\\\\\\\\\\,\\\\\\\\\\\\\\\\?\\\\\\\\\\\\\\\\.\\\\\\\\\\\\\\\\!\\\\\\\\\\\\\\\\-\\\\\\\\\\\\\\\\;\\\\\\\\\\\\\\\\:\\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\“\\\\\\\\\\\\\\\\%\\\\\\\\\\\\\\\\‘\\\\\\\\\\\\\\\\”\\\\\\\\\\\\\\\\�]'
190
  def remove_special_characters(batch):
191
  batch["sentence"] = re.sub(chars_to_ignore_regex, '', batch["sentence"]).lower() + " "
192
  return batch