phongdtd commited on
Commit
1102f82
·
1 Parent(s): ed91264

[Update] Update

Browse files
Files changed (1) hide show
  1. custom_common_voice.py +11 -13
custom_common_voice.py CHANGED
@@ -17,6 +17,7 @@
17
 
18
  import datasets
19
  from datasets.tasks import AutomaticSpeechRecognition
 
20
 
21
 
22
  _DATA_URL = "https://drive.google.com/uc?export=download&id=18ssh3gjpsMmjBfaIhcCwrfJMAvsdLGaI"
@@ -165,21 +166,18 @@ class CustomCommonVoice(datasets.GeneratorBasedBuilder):
165
 
166
  # audio is not a header of the csv files
167
  data_fields.remove("audio")
168
- path_idx = data_fields.index("file_path")
169
- script_idx = data_fields.index("script")
170
  examples = {}
171
 
172
- with open(tsv_files, encoding="utf-8") as f:
173
- lines = f.readlines()
174
- for line in lines[1:]:
175
- field_values = line.split("\t")
176
- # set full path for mp3 audio file
177
- audio_path = path_to_clips + "/" + field_values[path_idx]
178
- script = field_values[script_idx]
179
- examples[audio_path] = {
180
- "file_path": audio_path,
181
- "script": script,
182
- }
183
 
184
  inside_clips_dir = False
185
  for path, f in audio_files:
 
17
 
18
  import datasets
19
  from datasets.tasks import AutomaticSpeechRecognition
20
+ import pandas as pd
21
 
22
 
23
  _DATA_URL = "https://drive.google.com/uc?export=download&id=18ssh3gjpsMmjBfaIhcCwrfJMAvsdLGaI"
 
166
 
167
  # audio is not a header of the csv files
168
  data_fields.remove("audio")
 
 
169
  examples = {}
170
 
171
+ df = pd.read_csv(tsv_files, sep="\t", header=0)
172
+ df = df.dropna()
173
+
174
+ for file_path, script in zip(df["file_path"], df["script"]):
175
+ # set full path for mp3 audio file
176
+ audio_path = path_to_clips + "/" + file_path
177
+ examples[audio_path] = {
178
+ "file_path": audio_path,
179
+ "script": script,
180
+ }
 
181
 
182
  inside_clips_dir = False
183
  for path, f in audio_files: