Datasets:
Init
Browse files- README.md +193 -1
- vox_celeb.py +383 -0
README.md
CHANGED
@@ -1,3 +1,195 @@
|
|
1 |
---
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
annotations_creators:
|
3 |
+
- crowdsourced
|
4 |
+
language: []
|
5 |
+
language_creators:
|
6 |
+
- crowdsourced
|
7 |
+
license:
|
8 |
+
- cc-by-4.0
|
9 |
+
multilinguality:
|
10 |
+
- multilingual
|
11 |
+
pretty_name: VoxCeleb
|
12 |
+
size_categories:
|
13 |
+
- 1K<n<10K
|
14 |
+
- 10K<n<100K
|
15 |
+
- 100K<n<1M
|
16 |
+
source_datasets: []
|
17 |
+
tags: []
|
18 |
+
task_categories:
|
19 |
+
- automatic-speech-recognition
|
20 |
+
- audio-classification
|
21 |
+
- image-classification
|
22 |
+
task_ids:
|
23 |
+
- speaker-identification
|
24 |
---
|
25 |
+
|
26 |
+
# Dataset Card for VoxCeleb
|
27 |
+
|
28 |
+
## Table of Contents
|
29 |
+
- [Table of Contents](#table-of-contents)
|
30 |
+
- [Dataset Description](#dataset-description)
|
31 |
+
- [Dataset Summary](#dataset-summary)
|
32 |
+
- [Supported Tasks and Leaderboards](#supported-tasks-and-leaderboards)
|
33 |
+
- [Languages](#languages)
|
34 |
+
- [Dataset Structure](#dataset-structure)
|
35 |
+
- [Data Instances](#data-instances)
|
36 |
+
- [Data Fields](#data-fields)
|
37 |
+
- [Data Splits](#data-splits)
|
38 |
+
- [Dataset Creation](#dataset-creation)
|
39 |
+
- [Curation Rationale](#curation-rationale)
|
40 |
+
- [Source Data](#source-data)
|
41 |
+
- [Annotations](#annotations)
|
42 |
+
- [Personal and Sensitive Information](#personal-and-sensitive-information)
|
43 |
+
- [Considerations for Using the Data](#considerations-for-using-the-data)
|
44 |
+
- [Social Impact of Dataset](#social-impact-of-dataset)
|
45 |
+
- [Discussion of Biases](#discussion-of-biases)
|
46 |
+
- [Other Known Limitations](#other-known-limitations)
|
47 |
+
- [Additional Information](#additional-information)
|
48 |
+
- [Dataset Curators](#dataset-curators)
|
49 |
+
- [Licensing Information](#licensing-information)
|
50 |
+
- [Citation Information](#citation-information)
|
51 |
+
- [Contributions](#contributions)
|
52 |
+
|
53 |
+
## Dataset Description
|
54 |
+
|
55 |
+
### Dataset Summary
|
56 |
+
|
57 |
+
VoxCeleb is an audio-visual dataset consisting of short clips of human speech, extracted from interview videos uploaded to YouTube.
|
58 |
+
|
59 |
+
NOTE: Although this dataset can be automatically downloaded, you must manually request credentials to access it from the creators' website.
|
60 |
+
|
61 |
+
### Supported Tasks and Leaderboards
|
62 |
+
|
63 |
+
[More Information Needed]
|
64 |
+
|
65 |
+
### Languages
|
66 |
+
|
67 |
+
[More Information Needed]
|
68 |
+
|
69 |
+
## Dataset Structure
|
70 |
+
|
71 |
+
### Data Instances
|
72 |
+
|
73 |
+
Each datapoint has a path to the audio/video clip along with metadata about the speaker.
|
74 |
+
|
75 |
+
```
|
76 |
+
{
|
77 |
+
'file': '/datasets/downloads/extracted/[hash]/wav/id10271/_YimahVgI1A/00003.wav',
|
78 |
+
'file_format': 'wav',
|
79 |
+
'dataset_id': 'vox1',
|
80 |
+
'speaker_id': 'id10271',
|
81 |
+
'speaker_gender': 'm',
|
82 |
+
'speaker_name': 'Ed_Westwick',
|
83 |
+
'speaker_nationality': 'UK',
|
84 |
+
'video_id': '_YimahVgI1A',
|
85 |
+
'clip_id': '00003',
|
86 |
+
'audio': {
|
87 |
+
'path': '/datasets/downloads/extracted/[hash]/wav/id10271/_YimahVgI1A/00003.wav',
|
88 |
+
'array': array([...], dtype=float32),
|
89 |
+
'sampling_rate': 16000
|
90 |
+
}
|
91 |
+
}
|
92 |
+
```
|
93 |
+
|
94 |
+
### Data Fields
|
95 |
+
|
96 |
+
Each row includes the following fields:
|
97 |
+
- `file`: The path to the audio/video clip
|
98 |
+
- `file_format`: The file format in which the clip is stored (e.g. `wav`, `aac`, `mp4`)
|
99 |
+
- `dataset_id`: The ID of the dataset this clip is from (`vox1`, `vox2`)
|
100 |
+
- `speaker_id`: The ID of the speaker in this clip
|
101 |
+
- `speaker_gender`: The gender of the speaker (`m`/`f`)
|
102 |
+
- `speaker_name` (VoxCeleb1 only): The full name of the speaker in the clip
|
103 |
+
- `speaker_nationality` (VoxCeleb1 only): The speaker's country of origin
|
104 |
+
- `video_id`: The ID of the video from which this clip was taken
|
105 |
+
- `clip_index`: The index of the clip for this specific video
|
106 |
+
- `audio` (Audio dataset only): The audio signal data
|
107 |
+
|
108 |
+
### Data Splits
|
109 |
+
|
110 |
+
The dataset has a predefined dev set and test set, but no training set. For training purposes, the dev set may be split into training and validation sets.
|
111 |
+
|
112 |
+
## Dataset Creation
|
113 |
+
|
114 |
+
### Curation Rationale
|
115 |
+
|
116 |
+
[More Information Needed]
|
117 |
+
|
118 |
+
### Source Data
|
119 |
+
|
120 |
+
#### Initial Data Collection and Normalization
|
121 |
+
|
122 |
+
[More Information Needed]
|
123 |
+
|
124 |
+
#### Who are the source language producers?
|
125 |
+
|
126 |
+
[More Information Needed]
|
127 |
+
|
128 |
+
### Annotations
|
129 |
+
|
130 |
+
#### Annotation process
|
131 |
+
|
132 |
+
[More Information Needed]
|
133 |
+
|
134 |
+
#### Who are the annotators?
|
135 |
+
|
136 |
+
[More Information Needed]
|
137 |
+
|
138 |
+
### Personal and Sensitive Information
|
139 |
+
|
140 |
+
The dataset includes recordings of clips (mostly of celebrities and public figures) from public YouTube videos. The names of speakers in VoxCeleb1 are provided.
|
141 |
+
|
142 |
+
## Considerations for Using the Data
|
143 |
+
|
144 |
+
### Social Impact of Dataset
|
145 |
+
|
146 |
+
[More Information Needed]
|
147 |
+
|
148 |
+
### Discussion of Biases
|
149 |
+
|
150 |
+
[More Information Needed]
|
151 |
+
|
152 |
+
### Other Known Limitations
|
153 |
+
|
154 |
+
[More Information Needed]
|
155 |
+
|
156 |
+
## Additional Information
|
157 |
+
|
158 |
+
### Dataset Curators
|
159 |
+
|
160 |
+
[More Information Needed]
|
161 |
+
|
162 |
+
### Licensing Information
|
163 |
+
|
164 |
+
[More Information Needed]
|
165 |
+
|
166 |
+
### Citation Information
|
167 |
+
|
168 |
+
The VoxCeleb authors request that anyone who uses VoxCeleb1 or VoxCeleb2 includes the following three citations:
|
169 |
+
```
|
170 |
+
@Article{Nagrani19,
|
171 |
+
author = "Arsha Nagrani and Joon~Son Chung and Weidi Xie and Andrew Zisserman",
|
172 |
+
title = "Voxceleb: Large-scale speaker verification in the wild",
|
173 |
+
journal = "Computer Science and Language",
|
174 |
+
year = "2019",
|
175 |
+
publisher = "Elsevier",
|
176 |
+
}
|
177 |
+
|
178 |
+
@InProceedings{Chung18b,
|
179 |
+
author = "Chung, J.~S. and Nagrani, A. and Zisserman, A.",
|
180 |
+
title = "VoxCeleb2: Deep Speaker Recognition",
|
181 |
+
booktitle = "INTERSPEECH",
|
182 |
+
year = "2018",
|
183 |
+
}
|
184 |
+
|
185 |
+
@InProceedings{Nagrani17,
|
186 |
+
author = "Nagrani, A. and Chung, J.~S. and Zisserman, A.",
|
187 |
+
title = "VoxCeleb: a large-scale speaker identification dataset",
|
188 |
+
booktitle = "INTERSPEECH",
|
189 |
+
year = "2017",
|
190 |
+
}
|
191 |
+
```
|
192 |
+
|
193 |
+
### Contributions
|
194 |
+
|
195 |
+
Thanks to [@101arrowz](https://github.com/101arrowz) for adding this dataset.
|
vox_celeb.py
ADDED
@@ -0,0 +1,383 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2022 The HuggingFace Datasets Authors and Arjun Barrett.
|
3 |
+
#
|
4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
+
# you may not use this file except in compliance with the License.
|
6 |
+
# You may obtain a copy of the License at
|
7 |
+
#
|
8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
+
#
|
10 |
+
# Unless required by applicable law or agreed to in writing, software
|
11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
+
# See the License for the specific language governing permissions and
|
14 |
+
# limitations under the License.
|
15 |
+
|
16 |
+
# Lint as: python3
|
17 |
+
"""VoxCeleb audio-visual human speech dataset."""
|
18 |
+
|
19 |
+
import json
|
20 |
+
import os
|
21 |
+
from getpass import getpass
|
22 |
+
from hashlib import sha256
|
23 |
+
from itertools import repeat
|
24 |
+
from multiprocessing import Manager, Pool, Process
|
25 |
+
from pathlib import Path
|
26 |
+
from queue import Queue
|
27 |
+
from shutil import copyfileobj
|
28 |
+
from typing import Optional, cast
|
29 |
+
|
30 |
+
import pandas as pd
|
31 |
+
import requests
|
32 |
+
|
33 |
+
import datasets
|
34 |
+
|
35 |
+
_CITATION = """\
|
36 |
+
@Article{Nagrani19,
|
37 |
+
author = "Arsha Nagrani and Joon~Son Chung and Weidi Xie and Andrew Zisserman",
|
38 |
+
title = "Voxceleb: Large-scale speaker verification in the wild",
|
39 |
+
journal = "Computer Science and Language",
|
40 |
+
year = "2019",
|
41 |
+
publisher = "Elsevier",
|
42 |
+
}
|
43 |
+
|
44 |
+
@InProceedings{Chung18b,
|
45 |
+
author = "Chung, J.~S. and Nagrani, A. and Zisserman, A.",
|
46 |
+
title = "VoxCeleb2: Deep Speaker Recognition",
|
47 |
+
booktitle = "INTERSPEECH",
|
48 |
+
year = "2018",
|
49 |
+
}
|
50 |
+
|
51 |
+
@InProceedings{Nagrani17,
|
52 |
+
author = "Nagrani, A. and Chung, J.~S. and Zisserman, A.",
|
53 |
+
title = "VoxCeleb: a large-scale speaker identification dataset",
|
54 |
+
booktitle = "INTERSPEECH",
|
55 |
+
year = "2017",
|
56 |
+
}
|
57 |
+
"""
|
58 |
+
|
59 |
+
_DESCRIPTION = """\
|
60 |
+
VoxCeleb is an audio-visual dataset consisting of short clips of human speech, extracted from interview videos uploaded to YouTube
|
61 |
+
"""
|
62 |
+
|
63 |
+
_URL = "https://mm.kaist.ac.kr/datasets/voxceleb"
|
64 |
+
|
65 |
+
_URLS = {
|
66 |
+
"video": {
|
67 |
+
"placeholder": "http://143.248.230.30/voxceleb/vox1a/vox2_dev_mp4_parta",
|
68 |
+
"dev": (
|
69 |
+
"http://143.248.230.30/voxceleb/vox1a/vox2_dev_mp4_partaa",
|
70 |
+
"http://143.248.230.30/voxceleb/vox1a/vox2_dev_mp4_partab",
|
71 |
+
"http://143.248.230.30/voxceleb/vox1a/vox2_dev_mp4_partac",
|
72 |
+
"http://143.248.230.30/voxceleb/vox1a/vox2_dev_mp4_partad",
|
73 |
+
"http://143.248.230.30/voxceleb/vox1a/vox2_dev_mp4_partae",
|
74 |
+
"http://143.248.230.30/voxceleb/vox1a/vox2_dev_mp4_partaf",
|
75 |
+
"http://143.248.230.30/voxceleb/vox1a/vox2_dev_mp4_partag",
|
76 |
+
"http://143.248.230.30/voxceleb/vox1a/vox2_dev_mp4_partah",
|
77 |
+
"http://143.248.230.30/voxceleb/vox1a/vox2_dev_mp4_partai",
|
78 |
+
),
|
79 |
+
"test": "http://143.248.230.30/voxceleb/vox1a/vox2_test_mp4.zip",
|
80 |
+
},
|
81 |
+
"audio1": {
|
82 |
+
"placeholder": "http://143.248.230.30/voxceleb/vox1a/vox1_dev_wav_parta",
|
83 |
+
"dev": (
|
84 |
+
"http://143.248.230.30/voxceleb/vox1a/vox1_dev_wav_partaa",
|
85 |
+
"http://143.248.230.30/voxceleb/vox1a/vox1_dev_wav_partab",
|
86 |
+
"http://143.248.230.30/voxceleb/vox1a/vox1_dev_wav_partac",
|
87 |
+
"http://143.248.230.30/voxceleb/vox1a/vox1_dev_wav_partad",
|
88 |
+
),
|
89 |
+
"test": "http://143.248.230.30/voxceleb/vox1a/vox1_test_wav.zip",
|
90 |
+
},
|
91 |
+
"audio2": {
|
92 |
+
"placeholder": "http://143.248.230.30/voxceleb/vox1a/vox2_dev_aac_parta",
|
93 |
+
"dev": (
|
94 |
+
"http://143.248.230.30/voxceleb/vox1a/vox2_dev_aac_partaa",
|
95 |
+
"http://143.248.230.30/voxceleb/vox1a/vox2_dev_aac_partab",
|
96 |
+
"http://143.248.230.30/voxceleb/vox1a/vox2_dev_aac_partac",
|
97 |
+
"http://143.248.230.30/voxceleb/vox1a/vox2_dev_aac_partad",
|
98 |
+
"http://143.248.230.30/voxceleb/vox1a/vox2_dev_aac_partae",
|
99 |
+
"http://143.248.230.30/voxceleb/vox1a/vox2_dev_aac_partaf",
|
100 |
+
"http://143.248.230.30/voxceleb/vox1a/vox2_dev_aac_partag",
|
101 |
+
"http://143.248.230.30/voxceleb/vox1a/vox2_dev_aac_partah",
|
102 |
+
),
|
103 |
+
"test": "http://143.248.230.30/voxceleb/vox1a/vox2_test_aac.zip",
|
104 |
+
},
|
105 |
+
}
|
106 |
+
|
107 |
+
_DATASET_IDS = {"video": "vox2", "audio1": "vox1", "audio2": "vox2"}
|
108 |
+
|
109 |
+
_PLACEHOLDER_MAPS = dict(
|
110 |
+
value
|
111 |
+
for urls in _URLS.values()
|
112 |
+
for value in ((urls["placeholder"], urls["dev"]), (urls["test"], (urls["test"],)))
|
113 |
+
)
|
114 |
+
|
115 |
+
|
116 |
+
def _mp_download(
|
117 |
+
url: str,
|
118 |
+
tmp_path: Path,
|
119 |
+
cred_user: str,
|
120 |
+
cred_pass: str,
|
121 |
+
resume_pos: int,
|
122 |
+
length: int,
|
123 |
+
queue: Queue,
|
124 |
+
):
|
125 |
+
if length == resume_pos:
|
126 |
+
return
|
127 |
+
with open(tmp_path, "ab" if resume_pos else "wb") as tmp:
|
128 |
+
headers: dict[str, str] = {}
|
129 |
+
if resume_pos != 0:
|
130 |
+
headers["Range"] = f"bytes={resume_pos}-"
|
131 |
+
response = requests.get(
|
132 |
+
url, auth=(cred_user, cred_pass), headers=headers, stream=True
|
133 |
+
)
|
134 |
+
if response.status_code >= 200 and response.status_code < 300:
|
135 |
+
for chunk in response.iter_content(chunk_size=65536):
|
136 |
+
queue.put(len(chunk))
|
137 |
+
tmp.write(chunk)
|
138 |
+
else:
|
139 |
+
raise ConnectionError("failed to fetch dataset")
|
140 |
+
|
141 |
+
|
142 |
+
# TODO: Name of the dataset usually matches the script name with CamelCase instead of snake_case
|
143 |
+
class VoxCeleb(datasets.GeneratorBasedBuilder):
|
144 |
+
"""TODO: Short description of my dataset."""
|
145 |
+
|
146 |
+
VERSION = datasets.Version("1.0.0")
|
147 |
+
|
148 |
+
BUILDER_CONFIGS = [
|
149 |
+
datasets.BuilderConfig(
|
150 |
+
name="video", version=VERSION, description="Video clips of human speech"
|
151 |
+
),
|
152 |
+
datasets.BuilderConfig(
|
153 |
+
name="audio", version=VERSION, description="Audio clips of human speech"
|
154 |
+
),
|
155 |
+
datasets.BuilderConfig(
|
156 |
+
name="audio1",
|
157 |
+
version=datasets.Version("1.0.0"),
|
158 |
+
description="Audio clips of human speech from VoxCeleb1",
|
159 |
+
),
|
160 |
+
datasets.BuilderConfig(
|
161 |
+
name="audio2",
|
162 |
+
version=datasets.Version("2.0.0"),
|
163 |
+
description="Audio clips of human speech from VoxCeleb2",
|
164 |
+
),
|
165 |
+
]
|
166 |
+
|
167 |
+
def _info(self):
|
168 |
+
features = cast(
|
169 |
+
dict,
|
170 |
+
{
|
171 |
+
"file": datasets.Value("string"),
|
172 |
+
"file_format": datasets.Value("string"),
|
173 |
+
"dataset_id": datasets.Value("string"),
|
174 |
+
"speaker_id": datasets.Value("string"),
|
175 |
+
"speaker_gender": datasets.Value("string"),
|
176 |
+
"video_id": datasets.Value("string"),
|
177 |
+
"clip_index": datasets.Value("int32"),
|
178 |
+
},
|
179 |
+
)
|
180 |
+
if self.config.name == "audio1":
|
181 |
+
features["speaker_name"] = datasets.Value("string")
|
182 |
+
features["speaker_nationality"] = datasets.Value("string")
|
183 |
+
if self.config.name.startswith("audio"):
|
184 |
+
features["audio"] = datasets.Audio(sampling_rate=16000)
|
185 |
+
|
186 |
+
return datasets.DatasetInfo(
|
187 |
+
description=_DESCRIPTION,
|
188 |
+
homepage=_URL,
|
189 |
+
supervised_keys=datasets.info.SupervisedKeysData("file", "speaker_id"),
|
190 |
+
features=datasets.Features(features),
|
191 |
+
citation=_CITATION,
|
192 |
+
)
|
193 |
+
|
194 |
+
def _split_generators(self, dl_manager):
|
195 |
+
if dl_manager.is_streaming:
|
196 |
+
raise TypeError("Streaming is not supported for VoxCeleb")
|
197 |
+
targets = (
|
198 |
+
["audio1", "audio2"] if self.config.name == "audio" else [self.config.name]
|
199 |
+
)
|
200 |
+
cred_user: Optional[str] = os.environ.get("HUGGING_FACE_VOX_CELEB_USER")
|
201 |
+
cred_pass: Optional[str] = os.environ.get("HUGGING_FACE_VOX_CELEB_PASS")
|
202 |
+
creds_path = Path(
|
203 |
+
f"~/.huggingface/voxceleb_{self.VERSION}_credentials"
|
204 |
+
).expanduser()
|
205 |
+
|
206 |
+
if cred_user is None and cred_pass is None:
|
207 |
+
if creds_path.exists():
|
208 |
+
with open(creds_path, "r") as creds:
|
209 |
+
cred_user, cred_pass = json.load(creds)
|
210 |
+
else:
|
211 |
+
print(
|
212 |
+
"You need a temporary username and password to access VoxCeleb.",
|
213 |
+
f"Go to the project homepage ({_URL}) and fill out the form to request credentials.",
|
214 |
+
)
|
215 |
+
cred_user = input("VoxCeleb username: ")
|
216 |
+
cred_pass = getpass("VoxCeleb password: ")
|
217 |
+
|
218 |
+
if not cred_user or not cred_pass:
|
219 |
+
raise ValueError("could not find username and password to log in")
|
220 |
+
|
221 |
+
saved_credentials = False
|
222 |
+
|
223 |
+
def save_credentials():
|
224 |
+
nonlocal saved_credentials, cred_user, cred_pass, creds_path
|
225 |
+
if not saved_credentials:
|
226 |
+
creds_path.parent.mkdir(exist_ok=True)
|
227 |
+
with open(creds_path, "w") as creds:
|
228 |
+
json.dump((cred_user, cred_pass), creds)
|
229 |
+
saved_credentials = True
|
230 |
+
|
231 |
+
def download_custom(placeholder_url: str, path: str):
|
232 |
+
nonlocal dl_manager, cred_user, cred_pass
|
233 |
+
sources = _PLACEHOLDER_MAPS[placeholder_url]
|
234 |
+
tmp_paths: list[Path] = []
|
235 |
+
lengths: list[int] = []
|
236 |
+
start_positions: list[int] = []
|
237 |
+
for url in sources:
|
238 |
+
head = requests.head(url, auth=(cred_user, cred_pass))
|
239 |
+
if head.status_code == 401:
|
240 |
+
raise ValueError("failed to authenticate with VoxCeleb host")
|
241 |
+
if head.status_code < 200 or head.status_code >= 300:
|
242 |
+
raise ValueError("failed to fetch dataset")
|
243 |
+
save_credentials()
|
244 |
+
content_length = head.headers.get("Content-Length")
|
245 |
+
if content_length is None:
|
246 |
+
raise ValueError("expected non-empty Content-Length")
|
247 |
+
content_length = int(content_length)
|
248 |
+
tmp_path = Path(path + "." + sha256(url.encode("utf-8")).hexdigest())
|
249 |
+
tmp_paths.append(tmp_path)
|
250 |
+
lengths.append(content_length)
|
251 |
+
start_positions.append(
|
252 |
+
tmp_path.stat().st_size
|
253 |
+
if tmp_path.exists() and dl_manager.download_config.resume_download
|
254 |
+
else 0
|
255 |
+
)
|
256 |
+
|
257 |
+
def progress(q: Queue[int], cur: int, total: int):
|
258 |
+
with datasets.utils.logging.tqdm(
|
259 |
+
unit="B",
|
260 |
+
unit_scale=True,
|
261 |
+
total=total,
|
262 |
+
initial=cur,
|
263 |
+
desc="Downloading",
|
264 |
+
disable=not datasets.utils.logging.is_progress_bar_enabled(),
|
265 |
+
) as progress:
|
266 |
+
while cur < total:
|
267 |
+
try:
|
268 |
+
added = q.get(timeout=1)
|
269 |
+
progress.update(added)
|
270 |
+
cur += added
|
271 |
+
except:
|
272 |
+
continue
|
273 |
+
|
274 |
+
manager = Manager()
|
275 |
+
q = manager.Queue()
|
276 |
+
with Pool(len(sources)) as pool:
|
277 |
+
proc = Process(
|
278 |
+
target=progress,
|
279 |
+
args=(q, sum(start_positions), sum(lengths)),
|
280 |
+
daemon=True,
|
281 |
+
)
|
282 |
+
proc.start()
|
283 |
+
pool.starmap(
|
284 |
+
_mp_download,
|
285 |
+
zip(
|
286 |
+
sources,
|
287 |
+
tmp_paths,
|
288 |
+
repeat(cred_user),
|
289 |
+
repeat(cred_pass),
|
290 |
+
start_positions,
|
291 |
+
lengths,
|
292 |
+
repeat(q),
|
293 |
+
),
|
294 |
+
)
|
295 |
+
pool.close()
|
296 |
+
proc.join()
|
297 |
+
with open(path, "wb") as out:
|
298 |
+
for tmp_path in tmp_paths:
|
299 |
+
with open(tmp_path, "rb") as tmp:
|
300 |
+
copyfileobj(tmp, out)
|
301 |
+
tmp_path.unlink()
|
302 |
+
|
303 |
+
metadata = dl_manager.download(
|
304 |
+
dict(
|
305 |
+
(
|
306 |
+
target,
|
307 |
+
f"https://mm.kaist.ac.kr/datasets/voxceleb/meta/{_DATASET_IDS[target]}_meta.csv",
|
308 |
+
)
|
309 |
+
for target in targets
|
310 |
+
)
|
311 |
+
)
|
312 |
+
|
313 |
+
mapped_paths = cast(
|
314 |
+
dict[str, dict[str, str]],
|
315 |
+
dl_manager.extract(
|
316 |
+
dl_manager.download_custom(
|
317 |
+
dict(
|
318 |
+
(
|
319 |
+
placeholder_key,
|
320 |
+
dict(
|
321 |
+
(target, _URLS[target][placeholder_key])
|
322 |
+
for target in targets
|
323 |
+
),
|
324 |
+
)
|
325 |
+
for placeholder_key in ("placeholder", "test")
|
326 |
+
),
|
327 |
+
download_custom,
|
328 |
+
)
|
329 |
+
),
|
330 |
+
)
|
331 |
+
|
332 |
+
return [
|
333 |
+
datasets.SplitGenerator(
|
334 |
+
name="validation",
|
335 |
+
gen_kwargs={
|
336 |
+
"paths": mapped_paths["placeholder"],
|
337 |
+
"meta_paths": metadata,
|
338 |
+
},
|
339 |
+
),
|
340 |
+
datasets.SplitGenerator(
|
341 |
+
name="test",
|
342 |
+
gen_kwargs={
|
343 |
+
"paths": mapped_paths["test"],
|
344 |
+
"meta_paths": metadata,
|
345 |
+
},
|
346 |
+
),
|
347 |
+
]
|
348 |
+
|
349 |
+
def _generate_examples(self, paths: dict[str, str], meta_paths: dict[str, str]):
|
350 |
+
key = 0
|
351 |
+
for conf in paths:
|
352 |
+
dataset_id = "vox1" if conf == "audio1" else "vox2"
|
353 |
+
meta = pd.read_csv(
|
354 |
+
meta_paths[conf],
|
355 |
+
sep="\t" if conf == "audio1" else " ,",
|
356 |
+
index_col=0,
|
357 |
+
engine="python",
|
358 |
+
)
|
359 |
+
dataset_path = next(Path(paths[conf]).iterdir())
|
360 |
+
dataset_format = dataset_path.name
|
361 |
+
for speaker_path in dataset_path.iterdir():
|
362 |
+
speaker = speaker_path.name
|
363 |
+
speaker_info = meta.loc[speaker]
|
364 |
+
for video in speaker_path.iterdir():
|
365 |
+
video_id = video.name
|
366 |
+
for clip in video.iterdir():
|
367 |
+
clip_index = int(clip.stem)
|
368 |
+
info = {
|
369 |
+
"file": str(clip),
|
370 |
+
"file_format": dataset_format,
|
371 |
+
"dataset_id": dataset_id,
|
372 |
+
"speaker_id": speaker,
|
373 |
+
"speaker_gender": speaker_info["Gender"],
|
374 |
+
"video_id": video_id,
|
375 |
+
"clip_index": clip_index,
|
376 |
+
}
|
377 |
+
if dataset_id == "vox1":
|
378 |
+
info["speaker_name"] = speaker_info["VGGFace1 ID"]
|
379 |
+
info["speaker_nationality"] = speaker_info["Nationality"]
|
380 |
+
if conf.startswith("audio"):
|
381 |
+
info["audio"] = info["file"]
|
382 |
+
yield key, info
|
383 |
+
key += 1
|