polinaeterna
commited on
Commit
·
58b647c
1
Parent(s):
3476ae7
add dataset metadate
Browse files- voxpopuli.py +61 -14
voxpopuli.py
CHANGED
|
@@ -7,6 +7,39 @@ from tqdm.auto import tqdm
|
|
| 7 |
import datasets
|
| 8 |
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
_LANGUAGES = sorted(
|
| 11 |
[
|
| 12 |
"en", "de", "fr", "es", "pl", "it", "ro", "hu", "cs", "nl", "fi", "hr",
|
|
@@ -15,6 +48,14 @@ _LANGUAGES = sorted(
|
|
| 15 |
)
|
| 16 |
_LANGUAGES_V2 = [f"{x}_v2" for x in _LANGUAGES]
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
_YEARS = list(range(2009, 2020 + 1))
|
| 19 |
|
| 20 |
# unnecessary
|
|
@@ -22,7 +63,7 @@ _CONFIG_TO_LANGS = {
|
|
| 22 |
"400k": _LANGUAGES,
|
| 23 |
"100k": _LANGUAGES,
|
| 24 |
"10k": _LANGUAGES,
|
| 25 |
-
"asr":
|
| 26 |
}
|
| 27 |
|
| 28 |
_CONFIG_TO_YEARS = {
|
|
@@ -43,7 +84,11 @@ _BASE_URL = "https://dl.fbaipublicfiles.com/voxpopuli/"
|
|
| 43 |
|
| 44 |
_DATA_URL = _BASE_URL + "audios/{lang}_{year}.tar"
|
| 45 |
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
|
| 49 |
class VoxpopuliConfig(datasets.BuilderConfig):
|
|
@@ -57,24 +102,23 @@ class VoxpopuliConfig(datasets.BuilderConfig):
|
|
| 57 |
"""
|
| 58 |
super().__init__(name=name, **kwargs)
|
| 59 |
name = name.split("_")[0]
|
| 60 |
-
self.languages = [name] if name in _LANGUAGES else
|
| 61 |
self.years = _CONFIG_TO_YEARS[name]
|
| 62 |
|
| 63 |
|
| 64 |
class Voxpopuli(datasets.GeneratorBasedBuilder):
|
| 65 |
-
"""The
|
| 66 |
|
| 67 |
-
VERSION = datasets.Version("1.
|
| 68 |
BUILDER_CONFIGS = [
|
| 69 |
VoxpopuliConfig(
|
| 70 |
name=name,
|
| 71 |
-
|
| 72 |
-
description="", # TODO
|
| 73 |
)
|
| 74 |
for name in _LANGUAGES + _LANGUAGES_V2 + ["10k", "100k", "400k"]
|
| 75 |
]
|
| 76 |
# DEFAULT_CONFIG_NAME = "400k"
|
| 77 |
-
DEFAULT_WRITER_BATCH_SIZE = 256
|
| 78 |
|
| 79 |
def _info(self):
|
| 80 |
try:
|
|
@@ -98,14 +142,14 @@ class Voxpopuli(datasets.GeneratorBasedBuilder):
|
|
| 98 |
}
|
| 99 |
)
|
| 100 |
return datasets.DatasetInfo(
|
| 101 |
-
|
| 102 |
features=features,
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
)
|
| 107 |
|
| 108 |
-
def
|
| 109 |
# from https://github.com/facebookresearch/voxpopuli/blob/main/voxpopuli/get_unlabelled_data.py#L34
|
| 110 |
def predicate(id_):
|
| 111 |
is_plenary = id_.find("PLENARY") > -1
|
|
@@ -133,8 +177,11 @@ class Voxpopuli(datasets.GeneratorBasedBuilder):
|
|
| 133 |
|
| 134 |
return metadata
|
| 135 |
|
|
|
|
|
|
|
|
|
|
| 136 |
def _split_generators(self, dl_manager):
|
| 137 |
-
metadata_path = dl_manager.download_and_extract(
|
| 138 |
|
| 139 |
urls = [_DATA_URL.format(lang=language, year=year) for language in self.config.languages for year in self.config.years]
|
| 140 |
dl_manager.download_config.num_proc = len(urls)
|
|
|
|
| 7 |
import datasets
|
| 8 |
|
| 9 |
|
| 10 |
+
_DESCRIPTION = """
|
| 11 |
+
A large-scale multilingual speech corpus for representation learning, semi-supervised learning and interpretation.
|
| 12 |
+
"""
|
| 13 |
+
|
| 14 |
+
_CITATION = """
|
| 15 |
+
@inproceedings{wang-etal-2021-voxpopuli,
|
| 16 |
+
title = "{V}ox{P}opuli: A Large-Scale Multilingual Speech Corpus for Representation Learning,
|
| 17 |
+
Semi-Supervised Learning and Interpretation",
|
| 18 |
+
author = "Wang, Changhan and
|
| 19 |
+
Riviere, Morgane and
|
| 20 |
+
Lee, Ann and
|
| 21 |
+
Wu, Anne and
|
| 22 |
+
Talnikar, Chaitanya and
|
| 23 |
+
Haziza, Daniel and
|
| 24 |
+
Williamson, Mary and
|
| 25 |
+
Pino, Juan and
|
| 26 |
+
Dupoux, Emmanuel",
|
| 27 |
+
booktitle = "Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics
|
| 28 |
+
and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers)",
|
| 29 |
+
month = aug,
|
| 30 |
+
year = "2021",
|
| 31 |
+
publisher = "Association for Computational Linguistics",
|
| 32 |
+
url = "https://aclanthology.org/2021.acl-long.80",
|
| 33 |
+
doi = "10.18653/v1/2021.acl-long.80",
|
| 34 |
+
pages = "993--1003",
|
| 35 |
+
}
|
| 36 |
+
"""
|
| 37 |
+
|
| 38 |
+
_HOMEPAGE = "https://github.com/facebookresearch/voxpopuli"
|
| 39 |
+
|
| 40 |
+
_LICENSE = "CC0, also see https://www.europarl.europa.eu/legal-notice/en/"
|
| 41 |
+
|
| 42 |
+
|
| 43 |
_LANGUAGES = sorted(
|
| 44 |
[
|
| 45 |
"en", "de", "fr", "es", "pl", "it", "ro", "hu", "cs", "nl", "fi", "hr",
|
|
|
|
| 48 |
)
|
| 49 |
_LANGUAGES_V2 = [f"{x}_v2" for x in _LANGUAGES]
|
| 50 |
|
| 51 |
+
_ASR_LANGUAGES = [
|
| 52 |
+
"en", "de", "fr", "es", "pl", "it", "ro", "hu", "cs", "nl", "fi", "hr",
|
| 53 |
+
"sk", "sl", "et", "lt"
|
| 54 |
+
]
|
| 55 |
+
_ASR_ACCENTED_LANGUAGES = [
|
| 56 |
+
"en_accented"
|
| 57 |
+
]
|
| 58 |
+
|
| 59 |
_YEARS = list(range(2009, 2020 + 1))
|
| 60 |
|
| 61 |
# unnecessary
|
|
|
|
| 63 |
"400k": _LANGUAGES,
|
| 64 |
"100k": _LANGUAGES,
|
| 65 |
"10k": _LANGUAGES,
|
| 66 |
+
"asr": _ASR_LANGUAGES, # + _ASR_ACCENTED_LANGUAGES
|
| 67 |
}
|
| 68 |
|
| 69 |
_CONFIG_TO_YEARS = {
|
|
|
|
| 84 |
|
| 85 |
_DATA_URL = _BASE_URL + "audios/{lang}_{year}.tar"
|
| 86 |
|
| 87 |
+
_ASR_DATA_URL = _BASE_URL + "audios/original_{year}.tar"
|
| 88 |
+
|
| 89 |
+
_UNLABELLED_META_URL = _BASE_URL + "annotations/unlabelled_v2.tsv.gz"
|
| 90 |
+
|
| 91 |
+
_ASR_META_URL = _BASE_URL + "annotations/asr/asr_{lang}.tsv.gz"
|
| 92 |
|
| 93 |
|
| 94 |
class VoxpopuliConfig(datasets.BuilderConfig):
|
|
|
|
| 102 |
"""
|
| 103 |
super().__init__(name=name, **kwargs)
|
| 104 |
name = name.split("_")[0]
|
| 105 |
+
self.languages = [name] if name in _LANGUAGES else _CONFIG_TO_LANGS[name]
|
| 106 |
self.years = _CONFIG_TO_YEARS[name]
|
| 107 |
|
| 108 |
|
| 109 |
class Voxpopuli(datasets.GeneratorBasedBuilder):
|
| 110 |
+
"""The VoxPopuli dataset."""
|
| 111 |
|
| 112 |
+
VERSION = datasets.Version("1.3.0") # not sure
|
| 113 |
BUILDER_CONFIGS = [
|
| 114 |
VoxpopuliConfig(
|
| 115 |
name=name,
|
| 116 |
+
version=datasets.Version("1.3.0"),
|
|
|
|
| 117 |
)
|
| 118 |
for name in _LANGUAGES + _LANGUAGES_V2 + ["10k", "100k", "400k"]
|
| 119 |
]
|
| 120 |
# DEFAULT_CONFIG_NAME = "400k"
|
| 121 |
+
DEFAULT_WRITER_BATCH_SIZE = 256 # SET THIS TO A LOWER VALUE IF IT USES TOO MUCH RAM SPACE
|
| 122 |
|
| 123 |
def _info(self):
|
| 124 |
try:
|
|
|
|
| 142 |
}
|
| 143 |
)
|
| 144 |
return datasets.DatasetInfo(
|
| 145 |
+
description=_DESCRIPTION,
|
| 146 |
features=features,
|
| 147 |
+
homepage=_HOMEPAGE,
|
| 148 |
+
license=_LICENSE,
|
| 149 |
+
citation=_CITATION,
|
| 150 |
)
|
| 151 |
|
| 152 |
+
def _read_metadata_unlabelled(self, metadata_path):
|
| 153 |
# from https://github.com/facebookresearch/voxpopuli/blob/main/voxpopuli/get_unlabelled_data.py#L34
|
| 154 |
def predicate(id_):
|
| 155 |
is_plenary = id_.find("PLENARY") > -1
|
|
|
|
| 177 |
|
| 178 |
return metadata
|
| 179 |
|
| 180 |
+
def _read_metadata_asr(self, metadata_paths):
|
| 181 |
+
pass
|
| 182 |
+
|
| 183 |
def _split_generators(self, dl_manager):
|
| 184 |
+
metadata_path = dl_manager.download_and_extract(_UNLABELLED_META_URL)
|
| 185 |
|
| 186 |
urls = [_DATA_URL.format(lang=language, year=year) for language in self.config.languages for year in self.config.years]
|
| 187 |
dl_manager.download_config.num_proc = len(urls)
|