Password and Username no longer used

#1
Files changed (1) hide show
  1. vox_celeb.py +61 -47
vox_celeb.py CHANGED
@@ -29,6 +29,9 @@ import pandas as pd
29
  import requests
30
 
31
  import datasets
 
 
 
32
 
33
  _CITATION = """\
34
  @Article{Nagrani19,
@@ -62,43 +65,43 @@ _URL = "https://mm.kaist.ac.kr/datasets/voxceleb"
62
 
63
  _URLS = {
64
  "video": {
65
- "placeholder": "http://143.248.230.30/voxceleb/vox1a/vox2_dev_mp4_parta",
66
  "dev": (
67
- "http://143.248.230.30/voxceleb/vox1a/vox2_dev_mp4_partaa",
68
- "http://143.248.230.30/voxceleb/vox1a/vox2_dev_mp4_partab",
69
- "http://143.248.230.30/voxceleb/vox1a/vox2_dev_mp4_partac",
70
- "http://143.248.230.30/voxceleb/vox1a/vox2_dev_mp4_partad",
71
- "http://143.248.230.30/voxceleb/vox1a/vox2_dev_mp4_partae",
72
- "http://143.248.230.30/voxceleb/vox1a/vox2_dev_mp4_partaf",
73
- "http://143.248.230.30/voxceleb/vox1a/vox2_dev_mp4_partag",
74
- "http://143.248.230.30/voxceleb/vox1a/vox2_dev_mp4_partah",
75
- "http://143.248.230.30/voxceleb/vox1a/vox2_dev_mp4_partai",
76
  ),
77
- "test": "http://143.248.230.30/voxceleb/vox1a/vox2_test_mp4.zip",
78
  },
79
  "audio1": {
80
- "placeholder": "http://143.248.230.30/voxceleb/vox1a/vox1_dev_wav_parta",
81
  "dev": (
82
- "http://143.248.230.30/voxceleb/vox1a/vox1_dev_wav_partaa",
83
- "http://143.248.230.30/voxceleb/vox1a/vox1_dev_wav_partab",
84
- "http://143.248.230.30/voxceleb/vox1a/vox1_dev_wav_partac",
85
- "http://143.248.230.30/voxceleb/vox1a/vox1_dev_wav_partad",
86
  ),
87
- "test": "http://143.248.230.30/voxceleb/vox1a/vox1_test_wav.zip",
88
  },
89
  "audio2": {
90
- "placeholder": "http://143.248.230.30/voxceleb/vox1a/vox2_dev_aac_parta",
91
  "dev": (
92
- "http://143.248.230.30/voxceleb/vox1a/vox2_dev_aac_partaa",
93
- "http://143.248.230.30/voxceleb/vox1a/vox2_dev_aac_partab",
94
- "http://143.248.230.30/voxceleb/vox1a/vox2_dev_aac_partac",
95
- "http://143.248.230.30/voxceleb/vox1a/vox2_dev_aac_partad",
96
- "http://143.248.230.30/voxceleb/vox1a/vox2_dev_aac_partae",
97
- "http://143.248.230.30/voxceleb/vox1a/vox2_dev_aac_partaf",
98
- "http://143.248.230.30/voxceleb/vox1a/vox2_dev_aac_partag",
99
- "http://143.248.230.30/voxceleb/vox1a/vox2_dev_aac_partah",
100
  ),
101
- "test": "http://143.248.230.30/voxceleb/vox1a/vox2_test_aac.zip",
102
  },
103
  }
104
 
@@ -109,13 +112,23 @@ _PLACEHOLDER_MAPS = dict(
109
  for urls in _URLS.values()
110
  for value in ((urls["placeholder"], urls["dev"]), (urls["test"], (urls["test"],)))
111
  )
 
 
 
 
 
 
 
 
 
 
112
 
 
113
 
114
  def _mp_download(
115
  url,
116
  tmp_path,
117
- cred_user,
118
- cred_pass,
119
  resume_pos,
120
  length,
121
  queue,
@@ -127,7 +140,7 @@ def _mp_download(
127
  if resume_pos != 0:
128
  headers["Range"] = f"bytes={resume_pos}-"
129
  response = requests.get(
130
- url, auth=(cred_user, cred_pass), headers=headers, stream=True
131
  )
132
  if response.status_code >= 200 and response.status_code < 300:
133
  for chunk in response.iter_content(chunk_size=65536):
@@ -186,56 +199,58 @@ class VoxCeleb(datasets.GeneratorBasedBuilder):
186
  )
187
 
188
  def _split_generators(self, dl_manager):
 
189
  if dl_manager.is_streaming:
190
  raise TypeError("Streaming is not supported for VoxCeleb")
191
  targets = (
192
  ["audio1", "audio2"] if self.config.name == "audio" else [self.config.name]
193
  )
194
- cred_user = os.environ.get("HUGGING_FACE_VOX_CELEB_USER")
195
- cred_pass = os.environ.get("HUGGING_FACE_VOX_CELEB_PASS")
196
  creds_path = Path(
197
  f"~/.huggingface/voxceleb_{self.VERSION}_credentials"
198
  ).expanduser()
199
 
200
- if cred_user is None and cred_pass is None:
201
  if creds_path.exists():
202
  with open(creds_path, "r") as creds:
203
- cred_user, cred_pass = json.load(creds)
204
  else:
205
  print(
206
- "You need a temporary username and password to access VoxCeleb.",
207
  f"Go to the project homepage ({_URL}) and fill out the form to request credentials.",
208
  )
209
- cred_user = input("VoxCeleb username: ")
210
- cred_pass = getpass("VoxCeleb password: ")
211
-
212
- if not cred_user or not cred_pass:
213
- raise ValueError("could not find username and password to log in")
214
 
 
 
 
 
215
  saved_credentials = False
216
-
217
  def save_credentials():
218
- nonlocal saved_credentials, cred_user, cred_pass, creds_path
219
  if not saved_credentials:
220
  creds_path.parent.mkdir(exist_ok=True)
221
  with open(creds_path, "w") as creds:
222
- json.dump((cred_user, cred_pass), creds)
223
  saved_credentials = True
224
 
225
  def download_custom(placeholder_url, path):
226
- nonlocal dl_manager, cred_user, cred_pass
227
  sources = _PLACEHOLDER_MAPS[placeholder_url]
228
  tmp_paths = []
229
  lengths = []
230
  start_positions = []
231
  for url in sources:
232
- head = requests.head(url, auth=(cred_user, cred_pass))
 
233
  if head.status_code == 401:
234
  raise ValueError("failed to authenticate with VoxCeleb host")
235
  if head.status_code < 200 or head.status_code >= 300:
236
  raise ValueError("failed to fetch dataset")
237
  save_credentials()
238
  content_length = head.headers.get("Content-Length")
 
239
  if content_length is None:
240
  raise ValueError("expected non-empty Content-Length")
241
  content_length = int(content_length)
@@ -279,8 +294,7 @@ class VoxCeleb(datasets.GeneratorBasedBuilder):
279
  zip(
280
  sources,
281
  tmp_paths,
282
- repeat(cred_user),
283
- repeat(cred_pass),
284
  start_positions,
285
  lengths,
286
  repeat(q),
 
29
  import requests
30
 
31
  import datasets
32
+ from requests.packages.urllib3.exceptions import InsecureRequestWarning
33
+
34
+ requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
35
 
36
  _CITATION = """\
37
  @Article{Nagrani19,
 
65
 
66
  _URLS = {
67
  "video": {
68
+ "placeholder": "https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_mp4_partaa",
69
  "dev": (
70
+ "https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_mp4_partaa",
71
+ "https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_mp4_partab",
72
+ "https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_mp4_partac",
73
+ "https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_mp4_partad",
74
+ "https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_mp4_partae",
75
+ "https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_mp4_partaf",
76
+ "https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_mp4_partag",
77
+ "https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_mp4_partah",
78
+ "https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_mp4_partai",
79
  ),
80
+ "test": "https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_test_mp4.zip",
81
  },
82
  "audio1": {
83
+ "placeholder": "https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox1_dev_wav_partaa",
84
  "dev": (
85
+ "https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox1_dev_wav_partaa",
86
+ "https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox1_dev_wav_partab",
87
+ "https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox1_dev_wav_partac",
88
+ "https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox1_dev_wav_partad",
89
  ),
90
+ "test": "https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox1_test_wav.zip",
91
  },
92
  "audio2": {
93
+ "placeholder": "https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_aac_partaa",
94
  "dev": (
95
+ "https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_aac_partaa",
96
+ "https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_aac_partab",
97
+ "https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_aac_partac",
98
+ "https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_aac_partad",
99
+ "https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_aac_partae",
100
+ "https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_aac_partaf",
101
+ "https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_aac_partag",
102
+ "https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_aac_partah",
103
  ),
104
+ "test": "https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_test_aac.zip",
105
  },
106
  }
107
 
 
112
  for urls in _URLS.values()
113
  for value in ((urls["placeholder"], urls["dev"]), (urls["test"], (urls["test"],)))
114
  )
115
+ def format_urls(urls_dict, cred_key):
116
+ formatted_urls = {}
117
+
118
+ for key, value in urls_dict.items():
119
+ if isinstance(value, dict):
120
+ formatted_urls[key] = format_urls(value, cred_key)
121
+ elif isinstance(value, tuple):
122
+ formatted_urls[key] = tuple([url.format(cred_key=cred_key) for url in value])
123
+ else:
124
+ formatted_urls[key] = value.format(cred_key=cred_key)
125
 
126
+ return formatted_urls
127
 
128
  def _mp_download(
129
  url,
130
  tmp_path,
131
+ cred_key,
 
132
  resume_pos,
133
  length,
134
  queue,
 
140
  if resume_pos != 0:
141
  headers["Range"] = f"bytes={resume_pos}-"
142
  response = requests.get(
143
+ url, headers=headers, stream=True,verify=False
144
  )
145
  if response.status_code >= 200 and response.status_code < 300:
146
  for chunk in response.iter_content(chunk_size=65536):
 
199
  )
200
 
201
  def _split_generators(self, dl_manager):
202
+ global _URLS,_PLACEHOLDER_MAPS
203
  if dl_manager.is_streaming:
204
  raise TypeError("Streaming is not supported for VoxCeleb")
205
  targets = (
206
  ["audio1", "audio2"] if self.config.name == "audio" else [self.config.name]
207
  )
208
+ cred_key = os.environ.get("HUGGING_FACE_VOX_CELEB_KEY")
 
209
  creds_path = Path(
210
  f"~/.huggingface/voxceleb_{self.VERSION}_credentials"
211
  ).expanduser()
212
 
213
+ if cred_key is None:
214
  if creds_path.exists():
215
  with open(creds_path, "r") as creds:
216
+ cred_key = json.load(creds)
217
  else:
218
  print(
219
+ "You need a temporary key to access VoxCeleb.",
220
  f"Go to the project homepage ({_URL}) and fill out the form to request credentials.",
221
  )
222
+ cred_key = input("VoxCeleb key: ")
 
 
 
 
223
 
224
+ if not cred_key:
225
+ raise ValueError("could not find key to log in")
226
+ _URLS = format_urls(_URLS, cred_key)
227
+ _PLACEHOLDER_MAPS = dict(value for urls in _URLS.values() for value in ((urls["placeholder"], urls["dev"]), (urls["test"], (urls["test"],))))
228
  saved_credentials = False
229
+
230
  def save_credentials():
231
+ nonlocal saved_credentials, cred_key, creds_path
232
  if not saved_credentials:
233
  creds_path.parent.mkdir(exist_ok=True)
234
  with open(creds_path, "w") as creds:
235
+ json.dump((cred_key), creds)
236
  saved_credentials = True
237
 
238
  def download_custom(placeholder_url, path):
239
+ nonlocal dl_manager, cred_key
240
  sources = _PLACEHOLDER_MAPS[placeholder_url]
241
  tmp_paths = []
242
  lengths = []
243
  start_positions = []
244
  for url in sources:
245
+ head = requests.get(url,timeout=5,stream=True,allow_redirects=True,verify=False)
246
+
247
  if head.status_code == 401:
248
  raise ValueError("failed to authenticate with VoxCeleb host")
249
  if head.status_code < 200 or head.status_code >= 300:
250
  raise ValueError("failed to fetch dataset")
251
  save_credentials()
252
  content_length = head.headers.get("Content-Length")
253
+ head.close()
254
  if content_length is None:
255
  raise ValueError("expected non-empty Content-Length")
256
  content_length = int(content_length)
 
294
  zip(
295
  sources,
296
  tmp_paths,
297
+ repeat(cred_key),
 
298
  start_positions,
299
  lengths,
300
  repeat(q),