Datasets:
Commit
·
aedfd28
1
Parent(s):
bde3325
add n shards as a separate file, update script
Browse files- common_voice_11_0.py +11 -15
- n_shards.json +58 -0
common_voice_11_0.py
CHANGED
@@ -17,17 +17,16 @@
|
|
17 |
|
18 |
import csv
|
19 |
import os
|
20 |
-
import
|
21 |
|
22 |
import datasets
|
23 |
-
import requests
|
24 |
from datasets.utils.py_utils import size_str
|
25 |
-
from huggingface_hub import HfApi, HfFolder
|
26 |
from tqdm import tqdm
|
27 |
|
28 |
from .languages import LANGUAGES
|
29 |
from .release_stats import STATS
|
30 |
|
|
|
31 |
_CITATION = """\
|
32 |
@inproceedings{commonvoice:2020,
|
33 |
author = {Ardila, R. and Branson, M. and Davis, K. and Henretty, M. and Kohler, M. and Meyer, J. and Morais, R. and Saunders, L. and Tyers, F. M. and Weber, G.},
|
@@ -42,16 +41,6 @@ _HOMEPAGE = "https://commonvoice.mozilla.org/en/datasets"
|
|
42 |
|
43 |
_LICENSE = "https://creativecommons.org/publicdomain/zero/1.0/"
|
44 |
|
45 |
-
_N_SHARDS = {
|
46 |
-
"ar": {
|
47 |
-
"train": 1,
|
48 |
-
"dev": 1,
|
49 |
-
"test": 1,
|
50 |
-
"other": 2,
|
51 |
-
"invalidated": 1,
|
52 |
-
}
|
53 |
-
}
|
54 |
-
|
55 |
# TODO: change "streaming" to "main" after merge!
|
56 |
_BASE_URL = "https://huggingface.co/datasets/mozilla-foundation/common_voice_11_0/resolve/streaming/"
|
57 |
|
@@ -59,6 +48,8 @@ _AUDIO_URL = _BASE_URL + "audio/{lang}/{split}/{lang}_{split}_{shard_idx}.tar"
|
|
59 |
|
60 |
_TRANSCRIPT_URL = _BASE_URL + "transcript/{lang}/{split}.tsv"
|
61 |
|
|
|
|
|
62 |
|
63 |
class CommonVoiceConfig(datasets.BuilderConfig):
|
64 |
"""BuilderConfig for CommonVoice."""
|
@@ -102,7 +93,8 @@ class CommonVoice(datasets.GeneratorBasedBuilder):
|
|
102 |
total_hr=float(lang_stats["totalHrs"]) if lang_stats["totalHrs"] else None,
|
103 |
size_bytes=int(lang_stats["size"]) if lang_stats["size"] else None,
|
104 |
)
|
105 |
-
for lang, lang_stats in STATS["locales"].items()
|
|
|
106 |
]
|
107 |
|
108 |
def _info(self):
|
@@ -141,11 +133,15 @@ class CommonVoice(datasets.GeneratorBasedBuilder):
|
|
141 |
|
142 |
def _split_generators(self, dl_manager):
|
143 |
lang = self.config.name
|
|
|
|
|
|
|
|
|
144 |
audio_urls = {}
|
145 |
splits = ("train", "dev", "test", "other", "invalidated")
|
146 |
for split in splits:
|
147 |
audio_urls[split] = [
|
148 |
-
_AUDIO_URL.format(lang=lang, split=split, shard_idx=i) for i in range(
|
149 |
]
|
150 |
archive_paths = dl_manager.download(audio_urls)
|
151 |
local_extracted_archive_paths = dl_manager.extract(archive_paths) if not dl_manager.is_streaming else {}
|
|
|
17 |
|
18 |
import csv
|
19 |
import os
|
20 |
+
import json
|
21 |
|
22 |
import datasets
|
|
|
23 |
from datasets.utils.py_utils import size_str
|
|
|
24 |
from tqdm import tqdm
|
25 |
|
26 |
from .languages import LANGUAGES
|
27 |
from .release_stats import STATS
|
28 |
|
29 |
+
|
30 |
_CITATION = """\
|
31 |
@inproceedings{commonvoice:2020,
|
32 |
author = {Ardila, R. and Branson, M. and Davis, K. and Henretty, M. and Kohler, M. and Meyer, J. and Morais, R. and Saunders, L. and Tyers, F. M. and Weber, G.},
|
|
|
41 |
|
42 |
_LICENSE = "https://creativecommons.org/publicdomain/zero/1.0/"
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
# TODO: change "streaming" to "main" after merge!
|
45 |
_BASE_URL = "https://huggingface.co/datasets/mozilla-foundation/common_voice_11_0/resolve/streaming/"
|
46 |
|
|
|
48 |
|
49 |
_TRANSCRIPT_URL = _BASE_URL + "transcript/{lang}/{split}.tsv"
|
50 |
|
51 |
+
_N_SHARDS_URL = _BASE_URL + "n_shards.json"
|
52 |
+
|
53 |
|
54 |
class CommonVoiceConfig(datasets.BuilderConfig):
|
55 |
"""BuilderConfig for CommonVoice."""
|
|
|
93 |
total_hr=float(lang_stats["totalHrs"]) if lang_stats["totalHrs"] else None,
|
94 |
size_bytes=int(lang_stats["size"]) if lang_stats["size"] else None,
|
95 |
)
|
96 |
+
for lang, lang_stats in STATS["locales"].items()
|
97 |
+
if lang in ["ab", "ar", "as", "ast", "az", "ba", "bas", "de"] # TODO: remove
|
98 |
]
|
99 |
|
100 |
def _info(self):
|
|
|
133 |
|
134 |
def _split_generators(self, dl_manager):
|
135 |
lang = self.config.name
|
136 |
+
n_shards_path = dl_manager.download_and_extract(_N_SHARDS_URL)
|
137 |
+
with open(n_shards_path, encoding="utf-8") as f:
|
138 |
+
n_shards = json.load(f)
|
139 |
+
|
140 |
audio_urls = {}
|
141 |
splits = ("train", "dev", "test", "other", "invalidated")
|
142 |
for split in splits:
|
143 |
audio_urls[split] = [
|
144 |
+
_AUDIO_URL.format(lang=lang, split=split, shard_idx=i) for i in range(n_shards[lang][split])
|
145 |
]
|
146 |
archive_paths = dl_manager.download(audio_urls)
|
147 |
local_extracted_archive_paths = dl_manager.extract(archive_paths) if not dl_manager.is_streaming else {}
|
n_shards.json
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"ab": {
|
3 |
+
"dev": 1,
|
4 |
+
"test": 1,
|
5 |
+
"other": 1,
|
6 |
+
"invalidated": 1,
|
7 |
+
"train": 1
|
8 |
+
},
|
9 |
+
"ar": {
|
10 |
+
"dev": 1,
|
11 |
+
"test": 1,
|
12 |
+
"other": 1,
|
13 |
+
"invalidated": 1,
|
14 |
+
"train": 1
|
15 |
+
},
|
16 |
+
"as": {
|
17 |
+
"dev": 1,
|
18 |
+
"test": 1,
|
19 |
+
"other": 1,
|
20 |
+
"invalidated": 1,
|
21 |
+
"train": 1
|
22 |
+
},
|
23 |
+
"ast": {
|
24 |
+
"dev": 0,
|
25 |
+
"test": 1,
|
26 |
+
"other": 1,
|
27 |
+
"invalidated": 0,
|
28 |
+
"train": 1
|
29 |
+
},
|
30 |
+
"az": {
|
31 |
+
"dev": 1,
|
32 |
+
"test": 1,
|
33 |
+
"other": 1,
|
34 |
+
"invalidated": 1,
|
35 |
+
"train": 1
|
36 |
+
},
|
37 |
+
"ba": {
|
38 |
+
"dev": 1,
|
39 |
+
"test": 1,
|
40 |
+
"other": 1,
|
41 |
+
"invalidated": 1,
|
42 |
+
"train": 3
|
43 |
+
},
|
44 |
+
"bas": {
|
45 |
+
"dev": 1,
|
46 |
+
"test": 1,
|
47 |
+
"other": 1,
|
48 |
+
"invalidated": 1,
|
49 |
+
"train": 1
|
50 |
+
},
|
51 |
+
"de": {
|
52 |
+
"dev": 1,
|
53 |
+
"test": 1,
|
54 |
+
"other": 1,
|
55 |
+
"invalidated": 2,
|
56 |
+
"train": 12
|
57 |
+
}
|
58 |
+
}
|