marcel commited on
Commit
87cfe44
1 Parent(s): 156f527

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +12 -10
README.md CHANGED
@@ -69,7 +69,7 @@ print("Reference:", test_dataset["sentence"][:2])
69
 
70
  ## Evaluation
71
 
72
- The model can be evaluated as follows on the {language} test data of Common Voice. # TODO: replace #TODO: replace language with your {language}, *e.g.* French
73
 
74
 
75
  ```python
@@ -79,24 +79,26 @@ from datasets import load_dataset, load_metric
79
  from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
80
  import re
81
 
82
- test_dataset = load_dataset("common_voice", "de", split="test") #TODO: replace {lang_id} in your language code here. Make sure the code is one of the *ISO codes* of [this](https://huggingface.co/languages) site.
83
  wer = load_metric("wer")
84
 
85
- processor = Wav2Vec2Processor.from_pretrained("de") #TODO: replace {model_id} with your model id. The model id consists of {your_username}/{your_modelname}, *e.g.* `elgeish/wav2vec2-large-xlsr-53-arabic`
86
- model = Wav2Vec2ForCTC.from_pretrained("de") #TODO: replace {model_id} with your model id. The model id consists of {your_username}/{your_modelname}, *e.g.* `elgeish/wav2vec2-large-xlsr-53-arabic`
 
 
87
  model.to("cuda")
88
 
89
- chars_to_ignore_regex = '[\\\\,\\\\?\\\\.\\\\!\\\\-\\\\;\\\\:\\\\"\\\\“]' # TODO: adapt this list to include all special characters you removed from the data
90
  resampler = torchaudio.transforms.Resample(48_000, 16_000)
91
 
92
  # Preprocessing the datasets.
93
  # We need to read the aduio files as arrays
94
  def speech_file_to_array_fn(batch):
95
- \\tbatch["sentence"] = re.sub(chars_to_ignore_regex, '', batch["sentence"]).lower()
96
- \\tbatch["sentence"] = re.sub('\\ß', 'ss', batch["sentence"])
97
- \\tspeech_array, sampling_rate = torchaudio.load(batch["path"])
98
- \\tbatch["speech"] = resampler(speech_array).squeeze().numpy()
99
- \\treturn batch
100
 
101
  test_dataset = test_dataset.map(speech_file_to_array_fn)
102
 
 
69
 
70
  ## Evaluation
71
 
72
+ The model can be evaluated as follows on the {language} test data of Common Voice.
73
 
74
 
75
  ```python
 
79
  from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
80
  import re
81
 
82
+ test_dataset = load_dataset("common_voice", "de", split="test") [this](https://huggingface.co/languages) site.
83
  wer = load_metric("wer")
84
 
85
+ processor = Wav2Vec2Processor.from_pretrained("de")
86
+ `elgeish/wav2vec2-large-xlsr-53-arabic`
87
+ model = Wav2Vec2ForCTC.from_pretrained("de")
88
+ `elgeish/wav2vec2-large-xlsr-53-arabic`
89
  model.to("cuda")
90
 
91
+ chars_to_ignore_regex = '[\\,\\?\\.\\!\\-\\;\\:\\"\\“]'
92
  resampler = torchaudio.transforms.Resample(48_000, 16_000)
93
 
94
  # Preprocessing the datasets.
95
  # We need to read the aduio files as arrays
96
  def speech_file_to_array_fn(batch):
97
+ \\\\tbatch["sentence"] = re.sub(chars_to_ignore_regex, '', batch["sentence"]).lower()
98
+ \\\\tbatch["sentence"] = re.sub('\\ß', 'ss', batch["sentence"])
99
+ \\\\tspeech_array, sampling_rate = torchaudio.load(batch["path"])
100
+ \\\\tbatch["speech"] = resampler(speech_array).squeeze().numpy()
101
+ \\\\treturn batch
102
 
103
  test_dataset = test_dataset.map(speech_file_to_array_fn)
104