shahukareem commited on
Commit
1e05833
1 Parent(s): 5a9f5d9

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +13 -11
README.md CHANGED
@@ -62,6 +62,7 @@ inputs = processor(test_dataset["speech"][:2], sampling_rate=16_000, return_tens
62
  with torch.no_grad():
63
  logits = model(inputs.input_values, attention_mask=inputs.attention_mask).logits
64
 
 
65
  predicted_ids = torch.argmax(logits, dim=-1)
66
 
67
  print("Prediction:", processor.batch_decode(predicted_ids))
@@ -88,7 +89,7 @@ processor = Wav2Vec2Processor.from_pretrained("shahukareem/wav2vec2-large-xlsr-5
88
  model = Wav2Vec2ForCTC.from_pretrained("shahukareem/wav2vec2-large-xlsr-53-dhivehi")
89
  model.to("cuda")
90
 
91
- chars_to_ignore_regex = '[\\\\,\\\\?\\\\.\\\\!\\\\-\\\\;\\\\:\\\\"\\\\“\\\\%\\\\‘\\\\”\\\\�\\\\،\\\\.\\\\؟\\\\!\\\\'\\\\"\\\\–\\\\’]'
92
  resampler = torchaudio.transforms.Resample(48_000, 16_000)
93
 
94
  # Preprocessing the datasets.
@@ -104,14 +105,14 @@ test_dataset = test_dataset.map(speech_file_to_array_fn)
104
  # Preprocessing the datasets.
105
  # We need to read the aduio files as arrays
106
  def evaluate(batch):
107
- inputs = processor(batch["speech"], sampling_rate=16_000, return_tensors="pt", padding=True)
108
 
109
- with torch.no_grad():
110
- logits = model(inputs.input_values.to("cuda"), attention_mask=inputs.attention_mask.to("cuda")).logits
111
 
112
- pred_ids = torch.argmax(logits, dim=-1)
113
- batch["pred_strings"] = processor.batch_decode(pred_ids)
114
- return batch
115
 
116
  result = test_dataset.map(evaluate, batched=True, batch_size=8)
117
 
@@ -124,15 +125,16 @@ print("WER: {:2f}".format(100 * wer.compute(predictions=result["pred_strings"],
124
  The Common Voice `train` and `validation` datasets were used for training.
125
 
126
  ## Example predictions
 
127
  reference: ކަރަންޓް ވައިރުކޮށް ބޮކި ހަރުކުރުން
128
  predicted: ކަރަންޓް ވައިރުކޮށް ބޮކި ހަރުކުރުން
129
- --
130
  reference: ދެން އެކުދިންނާ ދިމާއަށް އަތް ދިށްކޮށްލެވެ
131
  predicted: ދެން އެކުދިންނާ ދިމާއަށް އަތް ދިއްކޮށްލެވެ ް
132
- --
133
  reference: ރަކި ހިނިތުންވުމަކާއެކު އޭނާ އަމިއްލައަށް ތައާރަފްވި
134
  predicted: ރަކި ހިނިތުންވުމަކާއެކު އޭނާ އަމިއްލައަށް ތައަރަފްވި
135
- --
136
  reference: ކޮޓަރީގެ ކުޑަދޮރުން ބޭރު ބަލަހައްޓައިގެން އިން ރޫނާގެ މޫނުމަތިން ފާޅުވަމުން ދިޔައީ ކަންބޮޑުވުމުގެ އަސަރުތައް
137
  predicted: ކޮޓަރީގެ ކުޑަދޮރުން ބޭރު ބަލަހައްޓައިގެން އިން ރނާގެ މޫނުމަތިން ފާޅުވަމުން ދިޔައީ ކަންބޮޑުވުމުގެ އަސަރުތައް
138
- --
 
62
  with torch.no_grad():
63
  logits = model(inputs.input_values, attention_mask=inputs.attention_mask).logits
64
 
65
+
66
  predicted_ids = torch.argmax(logits, dim=-1)
67
 
68
  print("Prediction:", processor.batch_decode(predicted_ids))
 
89
  model = Wav2Vec2ForCTC.from_pretrained("shahukareem/wav2vec2-large-xlsr-53-dhivehi")
90
  model.to("cuda")
91
 
92
+ chars_to_ignore_regex = '[\,\?\.\!\-\;\:\"\“\%\‘\”\�\،\.\؟\!\'\"\–\’]'
93
  resampler = torchaudio.transforms.Resample(48_000, 16_000)
94
 
95
  # Preprocessing the datasets.
 
105
  # Preprocessing the datasets.
106
  # We need to read the aduio files as arrays
107
  def evaluate(batch):
108
+ \tinputs = processor(batch["speech"], sampling_rate=16_000, return_tensors="pt", padding=True)
109
 
110
+ \twith torch.no_grad():
111
+ \t\tlogits = model(inputs.input_values.to("cuda"), attention_mask=inputs.attention_mask.to("cuda")).logits
112
 
113
+ \tpred_ids = torch.argmax(logits, dim=-1)
114
+ \tbatch["pred_strings"] = processor.batch_decode(pred_ids)
115
+ \treturn batch
116
 
117
  result = test_dataset.map(evaluate, batched=True, batch_size=8)
118
 
 
125
  The Common Voice `train` and `validation` datasets were used for training.
126
 
127
  ## Example predictions
128
+
129
  reference: ކަރަންޓް ވައިރުކޮށް ބޮކި ހަރުކުރުން
130
  predicted: ކަރަންޓް ވައިރުކޮށް ބޮކި ހަރުކުރުން
131
+ --\
132
  reference: ދެން އެކުދިންނާ ދިމާއަށް އަތް ދިށްކޮށްލެވެ
133
  predicted: ދެން އެކުދިންނާ ދިމާއަށް އަތް ދިއްކޮށްލެވެ ް
134
+ --\
135
  reference: ރަކި ހިނިތުންވުމަކާއެކު އޭނާ އަމިއްލައަށް ތައާރަފްވި
136
  predicted: ރަކި ހިނިތުންވުމަކާއެކު އޭނާ އަމިއްލައަށް ތައަރަފްވި
137
+ --\
138
  reference: ކޮޓަރީގެ ކުޑަދޮރުން ބޭރު ބަލަހައްޓައިގެން އިން ރޫނާގެ މޫނުމަތިން ފާޅުވަމުން ދިޔައީ ކަންބޮޑުވުމުގެ އަސަރުތައް
139
  predicted: ކޮޓަރީގެ ކުޑަދޮރުން ބޭރު ބަލަހައްޓައިގެން އިން ރނާގެ މޫނުމަތިން ފާޅުވަމުން ދިޔައީ ކަންބޮޑުވުމުގެ އަސަރުތައް
140
+ --\