nakkhatra commited on
Commit
292ff66
1 Parent(s): 4cac875

changed archive_path (hardcoded)

Browse files
Files changed (1) hide show
  1. common_voice_bn.py +21 -10
common_voice_bn.py CHANGED
@@ -71,7 +71,7 @@ class CommonVoiceConfig(datasets.BuilderConfig):
71
 
72
 
73
  class CommonVoice(datasets.GeneratorBasedBuilder):
74
- #DEFAULT_CONFIG_NAME = "en"
75
  DEFAULT_CONFIG_NAME = "bn"
76
  DEFAULT_WRITER_BATCH_SIZE = 1000
77
 
@@ -133,7 +133,9 @@ class CommonVoice(datasets.GeneratorBasedBuilder):
133
  path = urllib.parse.quote(path.encode("utf-8"), safe="~()*!.'")
134
  # use_cdn = self.config.size_bytes < 20 * 1024 * 1024 * 1024
135
  # response = requests.get(f"{_API_URL}/bucket/dataset/{path}/{use_cdn}", timeout=10.0).json()
136
- response = requests.get(f"{_API_URL}/bucket/dataset/{path}", timeout=10.0).json()
 
 
137
  return response["url"]
138
 
139
  def _log_download(self, locale, bundle_version, auth_token):
@@ -157,8 +159,14 @@ class CommonVoice(datasets.GeneratorBasedBuilder):
157
  dl_manager.download_config.ignore_url_params = True
158
 
159
  self._log_download(self.config.name, bundle_version, hf_auth_token)
160
- archive_path = dl_manager.download(self._get_bundle_url(self.config.name, bundle_url_template))
161
- local_extracted_archive = dl_manager.extract(archive_path) if not dl_manager.is_streaming else None
 
 
 
 
 
 
162
 
163
  if self.config.version < datasets.Version("5.0.0"):
164
  path_to_data = ""
@@ -166,8 +174,7 @@ class CommonVoice(datasets.GeneratorBasedBuilder):
166
  path_to_data = "/".join([bundle_version, self.config.name])
167
  path_to_clips = "/".join([path_to_data, "clips"]) if path_to_data else "clips"
168
 
169
-
170
- #we provide our custom csvs with the huggingface repo so,
171
  path_to_tsvs = "/" + "bengali_ai_tsv" + "/"
172
 
173
  return [
@@ -176,7 +183,7 @@ class CommonVoice(datasets.GeneratorBasedBuilder):
176
  gen_kwargs={
177
  "local_extracted_archive": local_extracted_archive,
178
  "archive_iterator": dl_manager.iter_archive(archive_path),
179
- #"metadata_filepath": "/".join([path_to_data, "train.tsv"]) if path_to_data else "train.tsv",
180
  "metadata_filepath": "/".join([path_to_tsvs, "train.tsv"]),
181
  "path_to_clips": path_to_clips,
182
  },
@@ -186,7 +193,7 @@ class CommonVoice(datasets.GeneratorBasedBuilder):
186
  gen_kwargs={
187
  "local_extracted_archive": local_extracted_archive,
188
  "archive_iterator": dl_manager.iter_archive(archive_path),
189
- #"metadata_filepath": "/".join([path_to_data, "test.tsv"]) if path_to_data else "test.tsv",
190
  "metadata_filepath": "/".join([path_to_tsvs, "test.tsv"]),
191
  "path_to_clips": path_to_clips,
192
  },
@@ -196,7 +203,7 @@ class CommonVoice(datasets.GeneratorBasedBuilder):
196
  gen_kwargs={
197
  "local_extracted_archive": local_extracted_archive,
198
  "archive_iterator": dl_manager.iter_archive(archive_path),
199
- #"metadata_filepath": "/".join([path_to_data, "dev.tsv"]) if path_to_data else "dev.tsv",
200
  "metadata_filepath": "/".join([path_to_tsvs, "dev.tsv"]),
201
  "path_to_clips": path_to_clips,
202
  },
@@ -240,7 +247,11 @@ class CommonVoice(datasets.GeneratorBasedBuilder):
240
  if path in metadata:
241
  result = metadata[path]
242
  # set the audio feature and the path to the extracted file
243
- path = os.path.join(local_extracted_archive, path) if local_extracted_archive else path
 
 
 
 
244
  result["audio"] = {"path": path, "bytes": f.read()}
245
  # set path to None if the audio file doesn't exist locally (i.e. in streaming mode)
246
  result["path"] = path if local_extracted_archive else None
 
71
 
72
 
73
  class CommonVoice(datasets.GeneratorBasedBuilder):
74
+ # DEFAULT_CONFIG_NAME = "en"
75
  DEFAULT_CONFIG_NAME = "bn"
76
  DEFAULT_WRITER_BATCH_SIZE = 1000
77
 
 
133
  path = urllib.parse.quote(path.encode("utf-8"), safe="~()*!.'")
134
  # use_cdn = self.config.size_bytes < 20 * 1024 * 1024 * 1024
135
  # response = requests.get(f"{_API_URL}/bucket/dataset/{path}/{use_cdn}", timeout=10.0).json()
136
+ response = requests.get(
137
+ f"{_API_URL}/bucket/dataset/{path}", timeout=10.0
138
+ ).json()
139
  return response["url"]
140
 
141
  def _log_download(self, locale, bundle_version, auth_token):
 
159
  dl_manager.download_config.ignore_url_params = True
160
 
161
  self._log_download(self.config.name, bundle_version, hf_auth_token)
162
+ # archive_path = dl_manager.download(self._get_bundle_url(self.config.name, bundle_url_template))
163
+ archive_path = dl_manager.download(
164
+ "https://mozilla-common-voice-datasets.s3.dualstack.us-west-2.amazonaws.com/cv-corpus-9.0-2022-04-27/cv-corpus-9.0-2022-04-27-bn.tar.gz"
165
+ )
166
+
167
+ local_extracted_archive = (
168
+ dl_manager.extract(archive_path) if not dl_manager.is_streaming else None
169
+ )
170
 
171
  if self.config.version < datasets.Version("5.0.0"):
172
  path_to_data = ""
 
174
  path_to_data = "/".join([bundle_version, self.config.name])
175
  path_to_clips = "/".join([path_to_data, "clips"]) if path_to_data else "clips"
176
 
177
+ # we provide our custom csvs with the huggingface repo so,
 
178
  path_to_tsvs = "/" + "bengali_ai_tsv" + "/"
179
 
180
  return [
 
183
  gen_kwargs={
184
  "local_extracted_archive": local_extracted_archive,
185
  "archive_iterator": dl_manager.iter_archive(archive_path),
186
+ # "metadata_filepath": "/".join([path_to_data, "train.tsv"]) if path_to_data else "train.tsv",
187
  "metadata_filepath": "/".join([path_to_tsvs, "train.tsv"]),
188
  "path_to_clips": path_to_clips,
189
  },
 
193
  gen_kwargs={
194
  "local_extracted_archive": local_extracted_archive,
195
  "archive_iterator": dl_manager.iter_archive(archive_path),
196
+ # "metadata_filepath": "/".join([path_to_data, "test.tsv"]) if path_to_data else "test.tsv",
197
  "metadata_filepath": "/".join([path_to_tsvs, "test.tsv"]),
198
  "path_to_clips": path_to_clips,
199
  },
 
203
  gen_kwargs={
204
  "local_extracted_archive": local_extracted_archive,
205
  "archive_iterator": dl_manager.iter_archive(archive_path),
206
+ # "metadata_filepath": "/".join([path_to_data, "dev.tsv"]) if path_to_data else "dev.tsv",
207
  "metadata_filepath": "/".join([path_to_tsvs, "dev.tsv"]),
208
  "path_to_clips": path_to_clips,
209
  },
 
247
  if path in metadata:
248
  result = metadata[path]
249
  # set the audio feature and the path to the extracted file
250
+ path = (
251
+ os.path.join(local_extracted_archive, path)
252
+ if local_extracted_archive
253
+ else path
254
+ )
255
  result["audio"] = {"path": path, "bytes": f.read()}
256
  # set path to None if the audio file doesn't exist locally (i.e. in streaming mode)
257
  result["path"] = path if local_extracted_archive else None