101arrowz commited on
Commit
34b66c0
1 Parent(s): d395618

allow either direct or proxy download

Browse files
Files changed (1) hide show
  1. vox_celeb.py +66 -16
vox_celeb.py CHANGED
@@ -106,11 +106,53 @@ _URLS = {
106
  },
107
  }
108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  _DATASET_IDS = {"video": "vox2", "audio1": "vox1", "audio2": "vox2"}
110
 
111
  _PLACEHOLDER_MAPS = dict(
112
  value
113
- for urls in _URLS.values()
114
  for value in ((urls["placeholder"], urls["dev"]), (urls["test"], (urls["test"],)))
115
  )
116
 
@@ -196,9 +238,15 @@ class VoxCeleb(datasets.GeneratorBasedBuilder):
196
  ["audio1", "audio2"] if self.config.name == "audio" else [self.config.name]
197
  )
198
  cred_key = os.environ.get("HUGGING_FACE_VOX_CELEB_KEY")
199
- creds_path = Path(
200
- f"~/.huggingface/voxceleb_{self.VERSION}_credentials"
201
- ).expanduser()
 
 
 
 
 
 
202
 
203
  if cred_key is None:
204
  if creds_path.exists():
@@ -208,18 +256,20 @@ class VoxCeleb(datasets.GeneratorBasedBuilder):
208
  print(
209
  "You need a key to access VoxCeleb directly.",
210
  f"Fill out the form ({_REQ_URL}) and paste in any of the download links you receive in your email.",
 
211
  )
212
- cred_url = getpass("Paste any VoxCeleb download URL here: ")
213
- cred_url_parsed = urlparse(cred_url)
214
- if cred_url_parsed.scheme != 'https' or cred_url_parsed.hostname != 'cn01.mmai.io' or cred_url_parsed.path != '/download/voxceleb':
215
- raise ValueError("couldn't parse as VoxCeleb download URL")
216
- cred_url_query = parse_qs(cred_url_parsed.query)
217
- if 'key' not in cred_url_query or len(cred_url_query['key']) != 1:
218
- raise ValueError("couldn't find key in URL")
219
- cred_key = cred_url_query['key'][0]
220
-
221
- if not cred_key:
222
- raise ValueError("could not find key to log in")
 
223
 
224
  saved_credentials = False
225
 
@@ -320,7 +370,7 @@ class VoxCeleb(datasets.GeneratorBasedBuilder):
320
  (
321
  placeholder_key,
322
  dict(
323
- (target, _URLS[target][placeholder_key])
324
  for target in targets
325
  ),
326
  )
 
106
  },
107
  }
108
 
109
+ _NO_AUTH_URLS = {
110
+ "video": {
111
+ "placeholder": "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_mp4",
112
+ "dev": (
113
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_mp4_partaa",
114
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_mp4_partab",
115
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_mp4_partac",
116
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_mp4_partad",
117
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_mp4_partae",
118
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_mp4_partaf",
119
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_mp4_partag",
120
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_mp4_partah",
121
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_mp4_partai",
122
+ ),
123
+ "test": "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_test_mp4.zip",
124
+ },
125
+ "audio1": {
126
+ "placeholder": "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox1/vox1_dev_wav",
127
+ "dev": (
128
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox1/vox1_dev_wav_partaa",
129
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox1/vox1_dev_wav_partab",
130
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox1/vox1_dev_wav_partac",
131
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox1/vox1_dev_wav_partad",
132
+ ),
133
+ "test": "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox1/vox1_test_wav.zip",
134
+ },
135
+ "audio2": {
136
+ "placeholder": "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_aac",
137
+ "dev": (
138
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_aac_partaa",
139
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_aac_partab",
140
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_aac_partac",
141
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_aac_partad",
142
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_aac_partae",
143
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_aac_partaf",
144
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_aac_partag",
145
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_aac_partah",
146
+ ),
147
+ "test": "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_test_aac.zip",
148
+ },
149
+ }
150
+
151
  _DATASET_IDS = {"video": "vox2", "audio1": "vox1", "audio2": "vox2"}
152
 
153
  _PLACEHOLDER_MAPS = dict(
154
  value
155
+ for urls in (*_URLS.values(), *_NO_AUTH_URLS.values())
156
  for value in ((urls["placeholder"], urls["dev"]), (urls["test"], (urls["test"],)))
157
  )
158
 
 
238
  ["audio1", "audio2"] if self.config.name == "audio" else [self.config.name]
239
  )
240
  cred_key = os.environ.get("HUGGING_FACE_VOX_CELEB_KEY")
241
+ hf_dir = os.getenv(
242
+ "HF_HOME",
243
+ os.path.join(
244
+ os.getenv("XDG_CACHE_HOME", os.path.join(os.path.expanduser("~"), ".cache")),
245
+ "huggingface"
246
+ )
247
+ )
248
+ creds_path = Path(hf_dir) / f"voxceleb_{self.VERSION}_credentials"
249
+ all_urls = _URLS
250
 
251
  if cred_key is None:
252
  if creds_path.exists():
 
256
  print(
257
  "You need a key to access VoxCeleb directly.",
258
  f"Fill out the form ({_REQ_URL}) and paste in any of the download links you receive in your email.",
259
+ "Alternatively, enter an empty string to use a third-party proxy by https://huggingface.co/ProgramComputer."
260
  )
261
+ cred_url = getpass("Paste any VoxCeleb download URL here (leave blank for proxy): ")
262
+ if cred_url != "":
263
+ cred_url_parsed = urlparse(cred_url)
264
+ if cred_url_parsed.scheme != 'https' or cred_url_parsed.hostname != 'cn01.mmai.io' or cred_url_parsed.path != '/download/voxceleb':
265
+ raise ValueError("couldn't parse as VoxCeleb download URL")
266
+ cred_url_query = parse_qs(cred_url_parsed.query)
267
+ if 'key' not in cred_url_query or len(cred_url_query['key']) != 1:
268
+ raise ValueError("couldn't find key in URL")
269
+ cred_key = cred_url_query['key'][0]
270
+
271
+ if cred_key is None:
272
+ all_urls = _NO_AUTH_URLS
273
 
274
  saved_credentials = False
275
 
 
370
  (
371
  placeholder_key,
372
  dict(
373
+ (target, all_urls[target][placeholder_key])
374
  for target in targets
375
  ),
376
  )