aapot commited on
Commit
6c6e835
1 Parent(s): 6157892

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +4 -4
README.md CHANGED
@@ -47,13 +47,13 @@ test_dataset = load_dataset("common_voice", "fi", split="test[:2%]")
47
  processor = Wav2Vec2Processor.from_pretrained("aapot/wav2vec2-large-xlsr-53-finnish")
48
  model = Wav2Vec2ForCTC.from_pretrained("aapot/wav2vec2-large-xlsr-53-finnish")
49
 
50
- resampler = lambda sr, y: librosa.resample(y.squeeze(), sr, 16_000)
51
 
52
  # Preprocessing the datasets.
53
  # We need to read the audio files as arrays
54
  def speech_file_to_array_fn(batch):
55
  speech_array, sampling_rate = torchaudio.load(batch["path"])
56
- batch["speech"] = resampler(sampling_rate, speech_array.numpy()).squeeze()
57
  return batch
58
 
59
  test_dataset = test_dataset.map(speech_file_to_array_fn)
@@ -90,14 +90,14 @@ model = Wav2Vec2ForCTC.from_pretrained("aapot/wav2vec2-large-xlsr-53-finnish")
90
  model.to("cuda")
91
 
92
  chars_to_ignore_regex = '[\,\?\.\!\-\;\:\"\“\%\‘\”\�\'\...\…\–\é]'
93
- resampler = lambda sr: lambda y: librosa.resample(y.numpy().squeeze(), sr, 16_000)
94
 
95
  # Preprocessing the datasets.
96
  # We need to read the audio files as arrays
97
  def speech_file_to_array_fn(batch):
98
  batch["sentence"] = re.sub(chars_to_ignore_regex, '', batch["sentence"]).lower()
99
  speech_array, sampling_rate = torchaudio.load(batch["path"])
100
- batch["speech"] = resampler(sampling_rate)(speech_array).squeeze()
101
  return batch
102
 
103
  test_dataset = test_dataset.map(speech_file_to_array_fn)
 
47
  processor = Wav2Vec2Processor.from_pretrained("aapot/wav2vec2-large-xlsr-53-finnish")
48
  model = Wav2Vec2ForCTC.from_pretrained("aapot/wav2vec2-large-xlsr-53-finnish")
49
 
50
+ resampler = lambda sr, y: librosa.resample(y.numpy().squeeze(), sr, 16_000)
51
 
52
  # Preprocessing the datasets.
53
  # We need to read the audio files as arrays
54
  def speech_file_to_array_fn(batch):
55
  speech_array, sampling_rate = torchaudio.load(batch["path"])
56
+ batch["speech"] = resampler(sampling_rate, speech_array).squeeze()
57
  return batch
58
 
59
  test_dataset = test_dataset.map(speech_file_to_array_fn)
 
90
  model.to("cuda")
91
 
92
  chars_to_ignore_regex = '[\,\?\.\!\-\;\:\"\“\%\‘\”\�\'\...\…\–\é]'
93
+ resampler = lambda sr, y: librosa.resample(y.numpy().squeeze(), sr, 16_000)
94
 
95
  # Preprocessing the datasets.
96
  # We need to read the audio files as arrays
97
  def speech_file_to_array_fn(batch):
98
  batch["sentence"] = re.sub(chars_to_ignore_regex, '', batch["sentence"]).lower()
99
  speech_array, sampling_rate = torchaudio.load(batch["path"])
100
+ batch["speech"] = resampler(sampling_rate, speech_array).squeeze()
101
  return batch
102
 
103
  test_dataset = test_dataset.map(speech_file_to_array_fn)