Aniket-Tathe-08 commited on
Commit
15e3836
1 Parent(s): 193d455

Update common_voice_16_0.py

Browse files
Files changed (1) hide show
  1. common_voice_16_0.py +12 -16
common_voice_16_0.py CHANGED
@@ -41,7 +41,8 @@ _HOMEPAGE = "https://commonvoice.mozilla.org/en/datasets"
41
 
42
  _LICENSE = "https://creativecommons.org/publicdomain/zero/1.0/"
43
 
44
- _BASE_URL = "https://huggingface.co/datasets/Aniket-Tathe-08/Custom_common_voice_dataset_using_RVC/raw/main/"
 
45
 
46
  _AUDIO_URL = _BASE_URL + "audio/{lang}/{split}/{lang}_{split}_{shard_idx}.tar"
47
 
@@ -87,10 +88,8 @@ class CommonVoice(datasets.GeneratorBasedBuilder):
87
  release_date=STATS["date"],
88
  num_clips=lang_stats["clips"],
89
  num_speakers=lang_stats["users"],
90
- validated_hr=float(
91
- lang_stats["validHrs"]) if lang_stats["validHrs"] else None,
92
- total_hr=float(lang_stats["totalHrs"]
93
- ) if lang_stats["totalHrs"] else None,
94
  size_bytes=int(lang_stats["size"]) if lang_stats["size"] else None,
95
  )
96
  for lang, lang_stats in STATS["locales"].items()
@@ -117,6 +116,7 @@ class CommonVoice(datasets.GeneratorBasedBuilder):
117
  "accent": datasets.Value("string"),
118
  "locale": datasets.Value("string"),
119
  "segment": datasets.Value("string"),
 
120
  }
121
  )
122
 
@@ -137,18 +137,15 @@ class CommonVoice(datasets.GeneratorBasedBuilder):
137
  n_shards = json.load(f)
138
 
139
  audio_urls = {}
140
- splits = ("train", "dev", "test", "other")
141
  for split in splits:
142
  audio_urls[split] = [
143
  _AUDIO_URL.format(lang=lang, split=split, shard_idx=i) for i in range(n_shards[lang][split])
144
  ]
145
- print(audio_urls)
146
  archive_paths = dl_manager.download(audio_urls)
147
- local_extracted_archive_paths = dl_manager.extract(
148
- archive_paths) if not dl_manager.is_streaming else {}
149
 
150
- meta_urls = {split: _TRANSCRIPT_URL.format(
151
- lang=lang, split=split) for split in splits}
152
  meta_paths = dl_manager.download_and_extract(meta_urls)
153
 
154
  split_generators = []
@@ -177,8 +174,8 @@ class CommonVoice(datasets.GeneratorBasedBuilder):
177
  with open(meta_path, encoding="utf-8") as f:
178
  reader = csv.DictReader(f, delimiter="\t", quoting=csv.QUOTE_NONE)
179
  for row in tqdm(reader, desc="Reading metadata..."):
180
- if not row["path"].endswith(".wav"):
181
- row["path"] += ".wav"
182
  # accent -> accents in CV 8.0
183
  if "accents" in row:
184
  row["accent"] = row["accents"]
@@ -195,8 +192,7 @@ class CommonVoice(datasets.GeneratorBasedBuilder):
195
  if filename in metadata:
196
  result = dict(metadata[filename])
197
  # set the audio feature and the path to the extracted file
198
- path = os.path.join(
199
- local_extracted_archive_paths[i], path) if local_extracted_archive_paths else path
200
  result["audio"] = {"path": path, "bytes": file.read()}
201
  result["path"] = path
202
- yield path, result
 
41
 
42
  _LICENSE = "https://creativecommons.org/publicdomain/zero/1.0/"
43
 
44
+ # TODO: change "streaming" to "main" after merge!
45
+ _BASE_URL = "https://huggingface.co/datasets/reach-vb/common_voice_16_0/resolve/main/"
46
 
47
  _AUDIO_URL = _BASE_URL + "audio/{lang}/{split}/{lang}_{split}_{shard_idx}.tar"
48
 
 
88
  release_date=STATS["date"],
89
  num_clips=lang_stats["clips"],
90
  num_speakers=lang_stats["users"],
91
+ validated_hr=float(lang_stats["validHrs"]) if lang_stats["validHrs"] else None,
92
+ total_hr=float(lang_stats["totalHrs"]) if lang_stats["totalHrs"] else None,
 
 
93
  size_bytes=int(lang_stats["size"]) if lang_stats["size"] else None,
94
  )
95
  for lang, lang_stats in STATS["locales"].items()
 
116
  "accent": datasets.Value("string"),
117
  "locale": datasets.Value("string"),
118
  "segment": datasets.Value("string"),
119
+ "variant": datasets.Value("string"),
120
  }
121
  )
122
 
 
137
  n_shards = json.load(f)
138
 
139
  audio_urls = {}
140
+ splits = ("train", "dev", "test", "other", "invalidated")
141
  for split in splits:
142
  audio_urls[split] = [
143
  _AUDIO_URL.format(lang=lang, split=split, shard_idx=i) for i in range(n_shards[lang][split])
144
  ]
 
145
  archive_paths = dl_manager.download(audio_urls)
146
+ local_extracted_archive_paths = dl_manager.extract(archive_paths) if not dl_manager.is_streaming else {}
 
147
 
148
+ meta_urls = {split: _TRANSCRIPT_URL.format(lang=lang, split=split) for split in splits}
 
149
  meta_paths = dl_manager.download_and_extract(meta_urls)
150
 
151
  split_generators = []
 
174
  with open(meta_path, encoding="utf-8") as f:
175
  reader = csv.DictReader(f, delimiter="\t", quoting=csv.QUOTE_NONE)
176
  for row in tqdm(reader, desc="Reading metadata..."):
177
+ if not row["path"].endswith(".mp3"):
178
+ row["path"] += ".mp3"
179
  # accent -> accents in CV 8.0
180
  if "accents" in row:
181
  row["accent"] = row["accents"]
 
192
  if filename in metadata:
193
  result = dict(metadata[filename])
194
  # set the audio feature and the path to the extracted file
195
+ path = os.path.join(local_extracted_archive_paths[i], path) if local_extracted_archive_paths else path
 
196
  result["audio"] = {"path": path, "bytes": file.read()}
197
  result["path"] = path
198
+ yield path, result