Datasets:
don't waste bandwidth
Browse files- vox_celeb.py +12 -9
vox_celeb.py
CHANGED
|
@@ -291,15 +291,18 @@ class VoxCeleb(datasets.GeneratorBasedBuilder):
|
|
| 291 |
with catch_warnings():
|
| 292 |
filterwarnings("ignore", category=InsecureRequestWarning)
|
| 293 |
head = requests.get(url.format(key=cred_key), verify=False, timeout=5, stream=True)
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
|
|
|
|
|
|
|
|
|
| 303 |
tmp_path = Path(path + "." + sha256(url.encode("utf-8")).hexdigest())
|
| 304 |
tmp_paths.append(tmp_path)
|
| 305 |
lengths.append(content_length)
|
|
|
|
| 291 |
with catch_warnings():
|
| 292 |
filterwarnings("ignore", category=InsecureRequestWarning)
|
| 293 |
head = requests.get(url.format(key=cred_key), verify=False, timeout=5, stream=True)
|
| 294 |
+
try:
|
| 295 |
+
if head.status_code == 401:
|
| 296 |
+
raise ValueError("failed to authenticate with VoxCeleb host")
|
| 297 |
+
if head.status_code < 200 or head.status_code >= 300:
|
| 298 |
+
raise ValueError("failed to fetch dataset")
|
| 299 |
+
save_credentials()
|
| 300 |
+
content_length = head.headers.get("Content-Length")
|
| 301 |
+
if content_length is None:
|
| 302 |
+
raise ValueError("expected non-empty Content-Length")
|
| 303 |
+
content_length = int(content_length)
|
| 304 |
+
finally:
|
| 305 |
+
head.close()
|
| 306 |
tmp_path = Path(path + "." + sha256(url.encode("utf-8")).hexdigest())
|
| 307 |
tmp_paths.append(tmp_path)
|
| 308 |
lengths.append(content_length)
|