Datasets:
Use HuggingFace for large files and remove creds
#2
by ProgramComputer - opened
- vox_celeb.py +30 -63
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 |
|
|
@@ -114,8 +114,6 @@ _PLACEHOLDER_MAPS = dict(
|
|
| 114 |
def _mp_download(
|
| 115 |
url,
|
| 116 |
tmp_path,
|
| 117 |
-
cred_user,
|
| 118 |
-
cred_pass,
|
| 119 |
resume_pos,
|
| 120 |
length,
|
| 121 |
queue,
|
|
@@ -127,7 +125,7 @@ def _mp_download(
|
|
| 127 |
if resume_pos != 0:
|
| 128 |
headers["Range"] = f"bytes={resume_pos}-"
|
| 129 |
response = requests.get(
|
| 130 |
-
url,
|
| 131 |
)
|
| 132 |
if response.status_code >= 200 and response.status_code < 300:
|
| 133 |
for chunk in response.iter_content(chunk_size=65536):
|
|
@@ -191,45 +189,16 @@ class VoxCeleb(datasets.GeneratorBasedBuilder):
|
|
| 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
|
| 227 |
sources = _PLACEHOLDER_MAPS[placeholder_url]
|
| 228 |
tmp_paths = []
|
| 229 |
lengths = []
|
| 230 |
start_positions = []
|
| 231 |
for url in sources:
|
| 232 |
-
head = requests.head(url
|
| 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:
|
|
@@ -279,8 +248,6 @@ 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),
|
|
|
|
| 62 |
|
| 63 |
_URLS = {
|
| 64 |
"video": {
|
| 65 |
+
"placeholder": "https://huggingface.co/datasets/ProgramComputer/voxceleb/tree/main/vox2/vox2_dev_mp4_parta",
|
| 66 |
"dev": (
|
| 67 |
+
"https://huggingface.co/datasets/ProgramComputer/voxceleb/tree/main/vox2/vox2_dev_mp4_partaa",
|
| 68 |
+
"https://huggingface.co/datasets/ProgramComputer/voxceleb/tree/main/vox2/vox2_dev_mp4_partab",
|
| 69 |
+
"https://huggingface.co/datasets/ProgramComputer/voxceleb/tree/main/vox2/vox2_dev_mp4_partac",
|
| 70 |
+
"https://huggingface.co/datasets/ProgramComputer/voxceleb/tree/main/vox2/vox2_dev_mp4_partad",
|
| 71 |
+
"https://huggingface.co/datasets/ProgramComputer/voxceleb/tree/main/vox2/vox2_dev_mp4_partae",
|
| 72 |
+
"https://huggingface.co/datasets/ProgramComputer/voxceleb/tree/main/vox2/vox2_dev_mp4_partaf",
|
| 73 |
+
"https://huggingface.co/datasets/ProgramComputer/voxceleb/tree/main/vox2/vox2_dev_mp4_partag",
|
| 74 |
+
"https://huggingface.co/datasets/ProgramComputer/voxceleb/tree/main/vox2/vox2_dev_mp4_partah",
|
| 75 |
+
"https://huggingface.co/datasets/ProgramComputer/voxceleb/tree/main/vox2/vox2_dev_mp4_partai",
|
| 76 |
),
|
| 77 |
+
"test": "https://huggingface.co/datasets/ProgramComputer/voxceleb/tree/main/vox2/vox2_test_mp4.zip",
|
| 78 |
},
|
| 79 |
"audio1": {
|
| 80 |
+
"placeholder": "https://huggingface.co/datasets/ProgramComputer/voxceleb/tree/main/vox1/vox1_dev_wav_parta",
|
| 81 |
"dev": (
|
| 82 |
+
"https://huggingface.co/datasets/ProgramComputer/voxceleb/tree/main/vox1/vox1_dev_wav_partaa",
|
| 83 |
+
"https://huggingface.co/datasets/ProgramComputer/voxceleb/tree/main/vox1/vox1_dev_wav_partab",
|
| 84 |
+
"https://huggingface.co/datasets/ProgramComputer/voxceleb/tree/main/vox1/vox1_dev_wav_partac",
|
| 85 |
+
"https://huggingface.co/datasets/ProgramComputer/voxceleb/tree/main/vox1/vox1_dev_wav_partad",
|
| 86 |
),
|
| 87 |
+
"test": "https://huggingface.co/datasets/ProgramComputer/voxceleb/tree/main/vox1/vox1_test_wav.zip",
|
| 88 |
},
|
| 89 |
"audio2": {
|
| 90 |
+
"placeholder": "https://huggingface.co/datasets/ProgramComputer/voxceleb/tree/main/vox2/vox2_dev_aac_parta",
|
| 91 |
"dev": (
|
| 92 |
+
"https://huggingface.co/datasets/ProgramComputer/voxceleb/tree/main/vox2/vox2_dev_aac_partaa",
|
| 93 |
+
"https://huggingface.co/datasets/ProgramComputer/voxceleb/tree/main/vox2/vox2_dev_aac_partab",
|
| 94 |
+
"https://huggingface.co/datasets/ProgramComputer/voxceleb/tree/main/vox2/vox2_dev_aac_partac",
|
| 95 |
+
"https://huggingface.co/datasets/ProgramComputer/voxceleb/tree/main/vox2/vox2_dev_aac_partad",
|
| 96 |
+
"https://huggingface.co/datasets/ProgramComputer/voxceleb/tree/main/vox2/vox2_dev_aac_partae",
|
| 97 |
+
"https://huggingface.co/datasets/ProgramComputer/voxceleb/tree/main/vox2/vox2_dev_aac_partaf",
|
| 98 |
+
"https://huggingface.co/datasets/ProgramComputer/voxceleb/tree/main/vox2/vox2_dev_aac_partag",
|
| 99 |
+
"https://huggingface.co/datasets/ProgramComputer/voxceleb/tree/main/vox2/vox2_dev_aac_partah",
|
| 100 |
),
|
| 101 |
+
"test": "https://huggingface.co/datasets/ProgramComputer/voxceleb/tree/main/vox2/vox2_test_aac.zip",
|
| 102 |
},
|
| 103 |
}
|
| 104 |
|
|
|
|
| 114 |
def _mp_download(
|
| 115 |
url,
|
| 116 |
tmp_path,
|
|
|
|
|
|
|
| 117 |
resume_pos,
|
| 118 |
length,
|
| 119 |
queue,
|
|
|
|
| 125 |
if resume_pos != 0:
|
| 126 |
headers["Range"] = f"bytes={resume_pos}-"
|
| 127 |
response = requests.get(
|
| 128 |
+
url, headers=headers, stream=True
|
| 129 |
)
|
| 130 |
if response.status_code >= 200 and response.status_code < 300:
|
| 131 |
for chunk in response.iter_content(chunk_size=65536):
|
|
|
|
| 189 |
targets = (
|
| 190 |
["audio1", "audio2"] if self.config.name == "audio" else [self.config.name]
|
| 191 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 192 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
|
| 194 |
def download_custom(placeholder_url, path):
|
| 195 |
+
nonlocal dl_manager
|
| 196 |
sources = _PLACEHOLDER_MAPS[placeholder_url]
|
| 197 |
tmp_paths = []
|
| 198 |
lengths = []
|
| 199 |
start_positions = []
|
| 200 |
for url in sources:
|
| 201 |
+
head = requests.head(url)
|
| 202 |
if head.status_code == 401:
|
| 203 |
raise ValueError("failed to authenticate with VoxCeleb host")
|
| 204 |
if head.status_code < 200 or head.status_code >= 300:
|
|
|
|
| 248 |
zip(
|
| 249 |
sources,
|
| 250 |
tmp_paths,
|
|
|
|
|
|
|
| 251 |
start_positions,
|
| 252 |
lengths,
|
| 253 |
repeat(q),
|