phongdtd commited on
Commit
86a1eaa
·
1 Parent(s): 8b68763

[Update] Update

Browse files
Files changed (1) hide show
  1. custom_common_voice.py +23 -14
custom_common_voice.py CHANGED
@@ -18,13 +18,14 @@
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"
24
  _PROMPTS_URLS = {
25
- "train": "https://drive.google.com/uc?export=download&id=1fHl3UuM73AGdTmOuTSRRSDnDxPiNBZas",
26
- "test": "https://drive.google.com/uc?export=download&id=1MoBJsfIvjfSnYXApiIqtnMV3z0u0o2UZ",
27
- "val": "https://drive.google.com/uc?export=download&id=1V8M437ncD6ogE-e56OipMPuuFqLgEt5g",
28
  }
29
 
30
  _DESCRIPTION = """\
@@ -81,11 +82,11 @@ class CustomCommonVoice(datasets.GeneratorBasedBuilder):
81
  name=lang_id,
82
  language=_LANGUAGES[lang_id]["Language"],
83
  sub_version=_LANGUAGES[lang_id]["Version"],
84
- date=_LANGUAGES[lang_id]["Date"],
85
- size=_LANGUAGES[lang_id]["Size"],
86
- val_hrs=_LANGUAGES[lang_id]["Validated_Hr_Total"],
87
- total_hrs=_LANGUAGES[lang_id]["Overall_Hr_Total"],
88
- num_of_voice=_LANGUAGES[lang_id]["Number_Of_Voice"],
89
  )
90
  for lang_id in _LANGUAGES.keys()
91
  ]
@@ -115,7 +116,6 @@ class CustomCommonVoice(datasets.GeneratorBasedBuilder):
115
  archive = dl_manager.download(_DATA_URL)
116
  path_to_data = "data_1"
117
  path_to_clips = path_to_data + "/" + "audio"
118
- path_to_script = path_to_data + "/" + "script"
119
 
120
  return [
121
  datasets.SplitGenerator(
@@ -170,10 +170,19 @@ class CustomCommonVoice(datasets.GeneratorBasedBuilder):
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,
@@ -186,10 +195,10 @@ class CustomCommonVoice(datasets.GeneratorBasedBuilder):
186
  if path in examples:
187
  audio = {"path": path, "bytes": f.read()}
188
  yield path, {**examples[path], "audio": audio}
189
- elif "custom_common_voice.tsv" in path:
190
- continue
191
- elif ".txt" in path:
192
- continue
193
  elif inside_clips_dir:
194
  break
195
 
 
18
  import datasets
19
  from datasets.tasks import AutomaticSpeechRecognition
20
  import pandas as pd
21
+ import re
22
 
23
 
24
+ _DATA_URL = "https://drive.google.com/uc?export=download&id=15WLhuiIl7q-zM_VFol8zw4tXMoyKTOJz"
25
  _PROMPTS_URLS = {
26
+ "train": "https://drive.google.com/uc?export=download&id=1L3-sTsiSVUMbPM6nWWBJNsh09mnQzC8J",
27
+ "test": "https://drive.google.com/uc?export=download&id=1-9Ahfqkn_DD3bteH06F8EThUbjmcWI7k",
28
+ "val": "https://drive.google.com/uc?export=download&id=1HLehZezcHyIBWsL6Tt5YuVQqRGynsZ2s",
29
  }
30
 
31
  _DESCRIPTION = """\
 
82
  name=lang_id,
83
  language=_LANGUAGES[lang_id]["Language"],
84
  sub_version=_LANGUAGES[lang_id]["Version"],
85
+ # date=_LANGUAGES[lang_id]["Date"],
86
+ # size=_LANGUAGES[lang_id]["Size"],
87
+ # val_hrs=_LANGUAGES[lang_id]["Validated_Hr_Total"],
88
+ # total_hrs=_LANGUAGES[lang_id]["Overall_Hr_Total"],
89
+ # num_of_voice=_LANGUAGES[lang_id]["Number_Of_Voice"],
90
  )
91
  for lang_id in _LANGUAGES.keys()
92
  ]
 
116
  archive = dl_manager.download(_DATA_URL)
117
  path_to_data = "data_1"
118
  path_to_clips = path_to_data + "/" + "audio"
 
119
 
120
  return [
121
  datasets.SplitGenerator(
 
170
 
171
  df = pd.read_csv(tsv_files, sep="\t", header=0)
172
  df = df.dropna()
173
+ chars_to_ignore_regex = r'[,?.!\-;:"“%\'�]'
174
 
175
  for file_path, script in zip(df["file_path"], df["script"]):
176
  # set full path for mp3 audio file
177
  audio_path = path_to_clips + "/" + file_path
178
+
179
+ # Preprocessing script
180
+ if ":" in script:
181
+ two_dot_index = script.index(":")
182
+ script = script[two_dot_index + 1:]
183
+ script = script.replace("\n", " ")
184
+ script = re.sub(chars_to_ignore_regex, '', script).lower()
185
+
186
  examples[audio_path] = {
187
  "file_path": audio_path,
188
  "script": script,
 
195
  if path in examples:
196
  audio = {"path": path, "bytes": f.read()}
197
  yield path, {**examples[path], "audio": audio}
198
+ # elif "custom_common_voice.tsv" in path:
199
+ # continue
200
+ # elif ".txt" in path:
201
+ # continue
202
  elif inside_clips_dir:
203
  break
204