Datasets:
Commit ·
f093558
1
Parent(s): ec3c8d4
Password and Username no longer used
Browse files- vox_celeb.py +51 -44
vox_celeb.py
CHANGED
|
@@ -62,43 +62,43 @@ _URL = "https://mm.kaist.ac.kr/datasets/voxceleb"
|
|
| 62 |
|
| 63 |
_URLS = {
|
| 64 |
"video": {
|
| 65 |
-
"placeholder": "
|
| 66 |
"dev": (
|
| 67 |
-
"
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
"
|
| 72 |
-
|
| 73 |
-
"
|
| 74 |
-
"
|
| 75 |
-
"
|
| 76 |
),
|
| 77 |
-
"test": "
|
| 78 |
},
|
| 79 |
"audio1": {
|
| 80 |
-
"placeholder": "
|
| 81 |
"dev": (
|
| 82 |
-
|
| 83 |
-
"
|
| 84 |
-
|
| 85 |
-
|
| 86 |
),
|
| 87 |
-
"test": "
|
| 88 |
},
|
| 89 |
"audio2": {
|
| 90 |
-
"placeholder":
|
| 91 |
"dev": (
|
| 92 |
-
|
| 93 |
-
"
|
| 94 |
-
"
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
"
|
| 98 |
-
|
| 99 |
-
|
| 100 |
),
|
| 101 |
-
"test": "
|
| 102 |
},
|
| 103 |
}
|
| 104 |
|
|
@@ -109,7 +109,18 @@ _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,
|
|
@@ -186,18 +197,18 @@ 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 |
-
|
| 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
|
| 201 |
if creds_path.exists():
|
| 202 |
with open(creds_path, "r") as creds:
|
| 203 |
cred_user, cred_pass = json.load(creds)
|
|
@@ -206,34 +217,30 @@ class VoxCeleb(datasets.GeneratorBasedBuilder):
|
|
| 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 |
-
|
| 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,
|
| 219 |
if not saved_credentials:
|
| 220 |
creds_path.parent.mkdir(exist_ok=True)
|
| 221 |
with open(creds_path, "w") as creds:
|
| 222 |
-
json.dump((
|
| 223 |
saved_credentials = True
|
| 224 |
|
| 225 |
def download_custom(placeholder_url, path):
|
| 226 |
-
nonlocal dl_manager,
|
| 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:
|
|
|
|
| 62 |
|
| 63 |
_URLS = {
|
| 64 |
"video": {
|
| 65 |
+
"placeholder": "https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_mp4_parta",
|
| 66 |
"dev": (
|
| 67 |
+
"https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_mp4_partaa",
|
| 68 |
+
"https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_mp4_partab",
|
| 69 |
+
"https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_mp4_partac",
|
| 70 |
+
"https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_mp4_partad",
|
| 71 |
+
"https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_mp4_partae",
|
| 72 |
+
"https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_mp4_partaf",
|
| 73 |
+
"https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_mp4_partag",
|
| 74 |
+
"https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_mp4_partah",
|
| 75 |
+
"https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_mp4_partai",
|
| 76 |
),
|
| 77 |
+
"test": "https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_test_mp4.zip",
|
| 78 |
},
|
| 79 |
"audio1": {
|
| 80 |
+
"placeholder": f"https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox1_dev_wav_parta",
|
| 81 |
"dev": (
|
| 82 |
+
"https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox1_dev_wav_partaa",
|
| 83 |
+
"https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox1_dev_wav_partab",
|
| 84 |
+
"https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox1_dev_wav_partac",
|
| 85 |
+
"https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox1_dev_wav_partad",
|
| 86 |
),
|
| 87 |
+
"test": "https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox1_test_wav.zip",
|
| 88 |
},
|
| 89 |
"audio2": {
|
| 90 |
+
"placeholder": "https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_aac_parta",
|
| 91 |
"dev": (
|
| 92 |
+
"https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_aac_partaa",
|
| 93 |
+
"https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_aac_partab",
|
| 94 |
+
"https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_aac_partac",
|
| 95 |
+
"https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_aac_partad",
|
| 96 |
+
"https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_aac_partae",
|
| 97 |
+
"https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_aac_partaf",
|
| 98 |
+
"https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_aac_partag",
|
| 99 |
+
"https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_dev_aac_partah",
|
| 100 |
),
|
| 101 |
+
"test": "https://cn01.mmai.io/download/voxceleb?key={cred_key}&file=vox2_test_aac.zip",
|
| 102 |
},
|
| 103 |
}
|
| 104 |
|
|
|
|
| 109 |
for urls in _URLS.values()
|
| 110 |
for value in ((urls["placeholder"], urls["dev"]), (urls["test"], (urls["test"],)))
|
| 111 |
)
|
| 112 |
+
def format_urls(urls_dict, cred_key):
|
| 113 |
+
formatted_urls = {}
|
| 114 |
+
|
| 115 |
+
for key, value in urls_dict.items():
|
| 116 |
+
if isinstance(value, dict):
|
| 117 |
+
formatted_urls[key] = format_urls(value, cred_key)
|
| 118 |
+
elif isinstance(value, tuple):
|
| 119 |
+
formatted_urls[key] = tuple([url.format(_CRED_KEY=cred_key) for url in value])
|
| 120 |
+
else:
|
| 121 |
+
formatted_urls[key] = value.format(_CRED_KEY=cred_key)
|
| 122 |
|
| 123 |
+
return formatted_urls
|
| 124 |
|
| 125 |
def _mp_download(
|
| 126 |
url,
|
|
|
|
| 197 |
)
|
| 198 |
|
| 199 |
def _split_generators(self, dl_manager):
|
| 200 |
+
global _URLS,_PLACEHOLDER_MAPS
|
| 201 |
if dl_manager.is_streaming:
|
| 202 |
raise TypeError("Streaming is not supported for VoxCeleb")
|
| 203 |
targets = (
|
| 204 |
["audio1", "audio2"] if self.config.name == "audio" else [self.config.name]
|
| 205 |
)
|
| 206 |
+
cred_key = os.environ.get("HUGGING_FACE_VOX_CELEB_KEY")
|
|
|
|
| 207 |
creds_path = Path(
|
| 208 |
f"~/.huggingface/voxceleb_{self.VERSION}_credentials"
|
| 209 |
).expanduser()
|
| 210 |
|
| 211 |
+
if cred_key is None:
|
| 212 |
if creds_path.exists():
|
| 213 |
with open(creds_path, "r") as creds:
|
| 214 |
cred_user, cred_pass = json.load(creds)
|
|
|
|
| 217 |
"You need a temporary username and password to access VoxCeleb.",
|
| 218 |
f"Go to the project homepage ({_URL}) and fill out the form to request credentials.",
|
| 219 |
)
|
| 220 |
+
cred_key = input("VoxCeleb key: ")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 221 |
|
| 222 |
+
if not cred_key:
|
| 223 |
+
raise ValueError("could not find key to log in")
|
| 224 |
+
format_urls(_URLS, cred_key):
|
| 225 |
+
|
| 226 |
+
_PLACEHOLDER_MAPS = dict(value for urls in _URLS.values() for value in ((urls["placeholder"], urls["dev"]), (urls["test"], (urls["test"],))))
|
| 227 |
saved_credentials = False
|
| 228 |
+
|
| 229 |
def save_credentials():
|
| 230 |
+
nonlocal saved_credentials, cred_key, creds_path
|
| 231 |
if not saved_credentials:
|
| 232 |
creds_path.parent.mkdir(exist_ok=True)
|
| 233 |
with open(creds_path, "w") as creds:
|
| 234 |
+
json.dump((cred_key), creds)
|
| 235 |
saved_credentials = True
|
| 236 |
|
| 237 |
def download_custom(placeholder_url, path):
|
| 238 |
+
nonlocal dl_manager, cred_key
|
| 239 |
sources = _PLACEHOLDER_MAPS[placeholder_url]
|
| 240 |
tmp_paths = []
|
| 241 |
lengths = []
|
| 242 |
start_positions = []
|
| 243 |
for url in sources:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 244 |
save_credentials()
|
| 245 |
content_length = head.headers.get("Content-Length")
|
| 246 |
if content_length is None:
|