chrisjay commited on
Commit
761edb9
·
1 Parent(s): 9469e8b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +10 -6
README.md CHANGED
@@ -2,14 +2,18 @@ language: fon
2
 
3
  datasets:
4
  - [Fon Dataset](https://github.com/laleye/pyFongbe/tree/master/data)
 
5
  metrics:
6
  - wer
 
7
  tags:
8
  - audio
9
  - automatic-speech-recognition
10
  - speech
11
  - xlsr-fine-tuning-week
 
12
  license: apache-2.0
 
13
  model-index:
14
  - name: Fon XLSR Wav2Vec2 Large 53
15
  results:
@@ -131,7 +135,7 @@ for root, dirs, files in os.walk(test_path):
131
  test_dataset= load_dataset("json", data_files=[os.path.join(root,i) for i in files],split="train")
132
 
133
  #Remove unnecessary chars
134
- chars_to_ignore_regex = '[\\,\\?\\.\\!\\-\\;\\:\\"\\“\\%\\‘\\”\\�]'
135
  def remove_special_characters(batch):
136
  batch["sentence"] = re.sub(chars_to_ignore_regex, '', batch["sentence"]).lower() + " "
137
  return batch
@@ -147,15 +151,15 @@ model = Wav2Vec2ForCTC.from_pretrained("chrisjay/wav2vec2-large-xlsr-53-fon")
147
  # Preprocessing the datasets.
148
  # We need to read the audio files as arrays
149
  def speech_file_to_array_fn(batch):
150
- \tspeech_array, sampling_rate = torchaudio.load(batch["path"])
151
- \tbatch["speech"]=speech_array.squeeze().numpy()
152
- \treturn batch
153
 
154
  test_dataset = test_dataset.map(speech_file_to_array_fn)
155
  inputs = processor(test_dataset["speech"][:2], sampling_rate=16_000, return_tensors="pt", padding=True)
156
 
157
  with torch.no_grad():
158
- \tlogits = model(inputs.input_values, attention_mask=inputs.attention_mask).logits
159
 
160
  predicted_ids = torch.argmax(logits, dim=-1)
161
 
@@ -178,7 +182,7 @@ import re
178
  for root, dirs, files in os.walk(test_path):
179
  test_dataset = load_dataset("json", data_files=[os.path.join(root,i) for i in files],split="train")
180
 
181
- chars_to_ignore_regex = '[\\,\\?\\.\\!\\-\\;\\:\\"\\“\\%\\‘\\”\\�]'
182
  def remove_special_characters(batch):
183
  batch["sentence"] = re.sub(chars_to_ignore_regex, '', batch["sentence"]).lower() + " "
184
  return batch
 
2
 
3
  datasets:
4
  - [Fon Dataset](https://github.com/laleye/pyFongbe/tree/master/data)
5
+
6
  metrics:
7
  - wer
8
+
9
  tags:
10
  - audio
11
  - automatic-speech-recognition
12
  - speech
13
  - xlsr-fine-tuning-week
14
+
15
  license: apache-2.0
16
+
17
  model-index:
18
  - name: Fon XLSR Wav2Vec2 Large 53
19
  results:
 
135
  test_dataset= load_dataset("json", data_files=[os.path.join(root,i) for i in files],split="train")
136
 
137
  #Remove unnecessary chars
138
+ chars_to_ignore_regex = '[\\\\,\\\\?\\\\.\\\\!\\\\-\\\\;\\\\:\\\\"\\\\“\\\\%\\\\‘\\\\”\\\\�]'
139
  def remove_special_characters(batch):
140
  batch["sentence"] = re.sub(chars_to_ignore_regex, '', batch["sentence"]).lower() + " "
141
  return batch
 
151
  # Preprocessing the datasets.
152
  # We need to read the audio files as arrays
153
  def speech_file_to_array_fn(batch):
154
+ \\tspeech_array, sampling_rate = torchaudio.load(batch["path"])
155
+ \\tbatch["speech"]=speech_array.squeeze().numpy()
156
+ \\treturn batch
157
 
158
  test_dataset = test_dataset.map(speech_file_to_array_fn)
159
  inputs = processor(test_dataset["speech"][:2], sampling_rate=16_000, return_tensors="pt", padding=True)
160
 
161
  with torch.no_grad():
162
+ \\tlogits = model(inputs.input_values, attention_mask=inputs.attention_mask).logits
163
 
164
  predicted_ids = torch.argmax(logits, dim=-1)
165
 
 
182
  for root, dirs, files in os.walk(test_path):
183
  test_dataset = load_dataset("json", data_files=[os.path.join(root,i) for i in files],split="train")
184
 
185
+ chars_to_ignore_regex = '[\\\\,\\\\?\\\\.\\\\!\\\\-\\\\;\\\\:\\\\"\\\\“\\\\%\\\\‘\\\\”\\\\�]'
186
  def remove_special_characters(batch):
187
  batch["sentence"] = re.sub(chars_to_ignore_regex, '', batch["sentence"]).lower() + " "
188
  return batch