carlosdanielhernandezmena commited on
Commit
2912382
1 Parent(s): 1ac3f1c

Adding all the files for the first time

Browse files
corpus/files/metadata_dev.tsv ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ audio_id split gender normalized_text relative_path
2
+ common_voice_es_18328658 dev male ni siquiera pienses en eso vaquero o sí muchacho rudo corpus/speech/dev/male/common_voice_es_18328658.flac
3
+ common_voice_es_18549611 dev female invitados del cumpleaños a las tres en punto cálmense todos corpus/speech/dev/female/common_voice_es_18549611.flac
4
+ common_voice_es_19026674 dev male en la supervivencia de la especie corpus/speech/dev/male/common_voice_es_19026674.flac
5
+ common_voice_es_19159450 dev male antes de la llegada de los europeos era fue una potencia política en halmahera corpus/speech/dev/male/common_voice_es_19159450.flac
6
+ common_voice_es_19597257 dev male la liga quedó interrumpida en los últimos años de la segunda guerra mundial corpus/speech/dev/male/common_voice_es_19597257.flac
7
+ common_voice_es_19603417 dev female desde entonces ha participado en numerosas novilladas sin picadores corpus/speech/dev/female/common_voice_es_19603417.flac
8
+ common_voice_es_19604077 dev male apareció en la película toma estas alas rotas corpus/speech/dev/male/common_voice_es_19604077.flac
9
+ common_voice_es_19666365 dev female sin embargo a lo largo del capítulo subyace una gran pregunta corpus/speech/dev/female/common_voice_es_19666365.flac
10
+ common_voice_es_19738526 dev female fue su reino en su tiempo el más poderoso e influyente de europa occidental corpus/speech/dev/female/common_voice_es_19738526.flac
11
+ common_voice_es_19942148 dev female en las últimas versiones de final cut pro apple inc corpus/speech/dev/female/common_voice_es_19942148.flac
corpus/files/metadata_test.tsv ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ audio_id split gender normalized_text relative_path
2
+ common_voice_es_18307761 test male y calló tal vez esperando una disculpa amante pero yo preferí guardar silencio corpus/speech/test/male/common_voice_es_18307761.flac
3
+ common_voice_es_18569707 test male esos hombres son profesionales son los mejores corpus/speech/test/male/common_voice_es_18569707.flac
4
+ common_voice_es_18831947 test male uno levanta la caza y otro la mata corpus/speech/test/male/common_voice_es_18831947.flac
5
+ common_voice_es_19131994 test female ante esta situación el oficial mandó prender fuego a la casa corpus/speech/test/female/common_voice_es_19131994.flac
6
+ common_voice_es_19523672 test male fue vicario apostólico del uruguay corpus/speech/test/male/common_voice_es_19523672.flac
7
+ common_voice_es_19610763 test male se desempeñó como mediocampista ofensivo corpus/speech/test/male/common_voice_es_19610763.flac
8
+ common_voice_es_19629310 test female esta pieza se retira del paciente junto con la aguja corpus/speech/test/female/common_voice_es_19629310.flac
9
+ common_voice_es_19699841 test female el grupo que acabe antes será el ganador corpus/speech/test/female/common_voice_es_19699841.flac
10
+ common_voice_es_19960886 test female el gobierno estadounidense no la reconoció como representante del pueblo cubano corpus/speech/test/female/common_voice_es_19960886.flac
11
+ common_voice_es_20260627 test female fue redactor en jefe de la página deportiva de el diario el país corpus/speech/test/female/common_voice_es_20260627.flac
corpus/files/metadata_train.tsv ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ audio_id split gender normalized_text relative_path
2
+ common_voice_es_18306568 train male no me hables acerca de importancia corpus/speech/train/male/common_voice_es_18306568.flac
3
+ common_voice_es_18320698 train male he restringido el acceso a la cubierta superior corpus/speech/train/male/common_voice_es_18320698.flac
4
+ common_voice_es_19596707 train male los orígenes precisos de the hood son desconocidos corpus/speech/train/male/common_voice_es_19596707.flac
5
+ common_voice_es_20501506 train male una vez destruidos se pierden inexorablemente corpus/speech/train/male/common_voice_es_20501506.flac
6
+ common_voice_es_20507096 train male el resto están todas en inglaterra corpus/speech/train/male/common_voice_es_20507096.flac
7
+ common_voice_es_20511043 train male las canciones de los comerciales sirvieron como singles para lee entre sus álbumes corpus/speech/train/male/common_voice_es_20511043.flac
8
+ common_voice_es_20711016 train female los hombres se quedan a jugar a las cartas hasta que amanece sin dormir corpus/speech/train/female/common_voice_es_20711016.flac
9
+ common_voice_es_20711252 train female con trece años comienza a realizar pequeños papeles para series de televisión y cine corpus/speech/train/female/common_voice_es_20711252.flac
10
+ common_voice_es_20717545 train female su actividad fuera del campo fue variada corpus/speech/train/female/common_voice_es_20717545.flac
11
+ common_voice_es_20717953 train female actualmente no está activo corpus/speech/train/female/common_voice_es_20717953.flac
12
+ common_voice_es_20722210 train female es nativo de farmington hills michigan corpus/speech/train/female/common_voice_es_20722210.flac
13
+ common_voice_es_20722849 train female incluye el navegador web safari y la aplicación mail de apple corpus/speech/train/female/common_voice_es_20722849.flac
14
+ common_voice_es_20724424 train female desempeña un papel vital en la promoción del talento nacional e internacional emergente corpus/speech/train/female/common_voice_es_20724424.flac
15
+ common_voice_es_20725001 train female las grabaciones se extendieron hasta finales del mes de mayo corpus/speech/train/female/common_voice_es_20725001.flac
16
+ common_voice_es_20931278 train female entre las personas nombradas se encontraba carlos alberto lacoste corpus/speech/train/female/common_voice_es_20931278.flac
17
+ common_voice_es_20932253 train female hasta el presente ningún vehículo orbital reutilizable real se ha llegado a usar corpus/speech/train/female/common_voice_es_20932253.flac
18
+ common_voice_es_21469616 train male sus principales producciones fueron escritas para ser representadas ó cantadas corpus/speech/train/male/common_voice_es_21469616.flac
19
+ common_voice_es_21486095 train male permite eliminar los reflejos luminosos y obtener efectos con las sombras corpus/speech/train/male/common_voice_es_21486095.flac
20
+ common_voice_es_21543608 train male el número y clase de pájaros varía en cada nivel corpus/speech/train/male/common_voice_es_21543608.flac
21
+ common_voice_es_21580953 train male la parte norte del brocal es más irregular con una protuberancia hacia el norte noroeste corpus/speech/train/male/common_voice_es_21580953.flac
corpus/files/tars_dev.paths ADDED
@@ -0,0 +1 @@
 
 
1
+ https://huggingface.co/datasets/carlosdanielhernandezmena/toy_corpus_asr_es/resolve/main/corpus/speech/dev.tar.gz
corpus/files/tars_test.paths ADDED
@@ -0,0 +1 @@
 
 
1
+ https://huggingface.co/datasets/carlosdanielhernandezmena/toy_corpus_asr_es/resolve/main/corpus/speech/test.tar.gz
corpus/files/tars_train.paths ADDED
@@ -0,0 +1 @@
 
 
1
+ https://huggingface.co/datasets/carlosdanielhernandezmena/toy_corpus_asr_es/resolve/main/corpus/speech/train.tar.gz
prueba.py ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from collections import defaultdict
2
+ import os
3
+ import json
4
+ import csv
5
+
6
+ import datasets
7
+
8
+ _NAME="prueba"
9
+ _VERSION="1.0.0"
10
+
11
+ _DESCRIPTION = """
12
+ An extremely small corpus of 40 audio files taken from Common Voice (es) with the objective of testing how to share datasets in Hugging Face.
13
+ """
14
+
15
+ _CITATION = """
16
+ @misc{toy_corpus_asr_es,
17
+ title={Toy Corpus for ASR in Spanish.},
18
+ author={Hernandez Mena, Carlos Daniel},
19
+ year={2022},
20
+ url={https://huggingface.co/datasets/carlosdanielhernandezmena/toy_corpus_asr_es},
21
+ }
22
+ """
23
+
24
+ _HOMEPAGE = "https://huggingface.co/datasets/carlosdanielhernandezmena/toy_corpus_asr_es"
25
+
26
+ _LICENSE = "CC-BY-4.0, See https://creativecommons.org/licenses/by/4.0/"
27
+
28
+ _BASE_DATA_DIR = "corpus/"
29
+ _METADATA_TRAIN = os.path.join(_BASE_DATA_DIR,"files","metadata_train.tsv")
30
+ _METADATA_TEST = os.path.join(_BASE_DATA_DIR,"files", "metadata_test.tsv")
31
+ _METADATA_DEV = os.path.join(_BASE_DATA_DIR,"files", "metadata_dev.tsv")
32
+
33
+ _TARS_TRAIN = os.path.join(_BASE_DATA_DIR,"files","tars_train.paths")
34
+ _TARS_TEST = os.path.join(_BASE_DATA_DIR,"files", "tars_test.paths")
35
+ _TARS_DEV = os.path.join(_BASE_DATA_DIR,"files", "tars_dev.paths")
36
+
37
+ class ToyCorpusAsrEsConfig(datasets.BuilderConfig):
38
+ """BuilderConfig for Toy Corpus ASR ES."""
39
+
40
+ def __init__(self, name, **kwargs):
41
+ name=_NAME
42
+ super().__init__(name=name, **kwargs)
43
+
44
+ class ToyCorpusAsrEs(datasets.GeneratorBasedBuilder):
45
+ """The Toy Corpus ASR ES dataset."""
46
+
47
+ VERSION = datasets.Version(_VERSION)
48
+ BUILDER_CONFIGS = [
49
+ ToyCorpusAsrEsConfig(
50
+ name=_NAME,
51
+ version=datasets.Version(_VERSION),
52
+ )
53
+ ]
54
+
55
+ def _info(self):
56
+ features = datasets.Features(
57
+ {
58
+ "audio_id": datasets.Value("string"),
59
+ "audio": datasets.Audio(sampling_rate=16000),
60
+ "split": datasets.Value("string"),
61
+ "gender": datasets.Value("string"),
62
+ "normalized_text": datasets.Value("string"),
63
+ "relative_path": datasets.Value("string"),
64
+ }
65
+ )
66
+ return datasets.DatasetInfo(
67
+ description=_DESCRIPTION,
68
+ features=features,
69
+ homepage=_HOMEPAGE,
70
+ license=_LICENSE,
71
+ citation=_CITATION,
72
+ )
73
+
74
+ def _split_generators(self, dl_manager):
75
+
76
+ metadata_train=dl_manager.download_and_extract(_METADATA_TRAIN)
77
+ metadata_test=dl_manager.download_and_extract(_METADATA_TEST)
78
+ metadata_dev=dl_manager.download_and_extract(_METADATA_DEV)
79
+
80
+ tars_train=dl_manager.download_and_extract(_TARS_TRAIN)
81
+ tars_test=dl_manager.download_and_extract(_TARS_TEST)
82
+ tars_dev=dl_manager.download_and_extract(_TARS_DEV)
83
+
84
+ hash_tar_files=defaultdict(dict)
85
+ with open(tars_train,'r') as f:
86
+ hash_tar_files['train']=[path.replace('\n','') for path in f]
87
+
88
+ with open(tars_test,'r') as f:
89
+ hash_tar_files['test']=[path.replace('\n','') for path in f]
90
+
91
+ with open(tars_dev,'r') as f:
92
+ hash_tar_files['dev']=[path.replace('\n','') for path in f]
93
+
94
+ hash_meta_paths={"train":metadata_train,"test":metadata_test,"dev":metadata_dev}
95
+ audio_paths = dl_manager.download(hash_tar_files)
96
+
97
+ splits=["train","dev","test"]
98
+ local_extracted_audio_paths = (
99
+ dl_manager.extract(audio_paths) if not dl_manager.is_streaming else
100
+ {
101
+ split:[None] * len(audio_paths[split]) for split in splits
102
+ }
103
+ )
104
+
105
+ return [
106
+ datasets.SplitGenerator(
107
+ name=datasets.Split.TRAIN,
108
+ gen_kwargs={
109
+ "audio_archives":[dl_manager.iter_archive(archive) for archive in audio_paths["train"]],
110
+ "local_extracted_archives_paths": local_extracted_audio_paths["train"],
111
+ "metadata_paths": hash_meta_paths["train"],
112
+ }
113
+ ),
114
+ datasets.SplitGenerator(
115
+ name=datasets.Split.VALIDATION,
116
+ gen_kwargs={
117
+ "audio_archives": [dl_manager.iter_archive(archive) for archive in audio_paths["dev"]],
118
+ "local_extracted_archives_paths": local_extracted_audio_paths["dev"],
119
+ "metadata_paths": hash_meta_paths["dev"],
120
+ }
121
+ ),
122
+ datasets.SplitGenerator(
123
+ name=datasets.Split.TEST,
124
+ gen_kwargs={
125
+ "audio_archives": [dl_manager.iter_archive(archive) for archive in audio_paths["test"]],
126
+ "local_extracted_archives_paths": local_extracted_audio_paths["test"],
127
+ "metadata_paths": hash_meta_paths["test"],
128
+ }
129
+ ),
130
+ ]
131
+
132
+ def _generate_examples(self, audio_archives, local_extracted_archives_paths, metadata_paths):
133
+
134
+ features = ["normalized_text","gender","split","relative_path"]
135
+
136
+ with open(metadata_paths) as f:
137
+ metadata = {x["audio_id"]: x for x in csv.DictReader(f, delimiter="\t")}
138
+
139
+ for audio_archive, local_extracted_archive_path in zip(audio_archives, local_extracted_archives_paths):
140
+ for audio_filename, audio_file in audio_archive:
141
+ audio_id =os.path.splitext(os.path.basename(audio_filename))[0]
142
+ path = os.path.join(local_extracted_archive_path, audio_filename) if local_extracted_archive_path else audio_filename
143
+ yield audio_id, {
144
+ "audio_id": audio_id,
145
+ **{feature: metadata[audio_id][feature] for feature in features},
146
+ "audio": {"path": path, "bytes": audio_file.read()},
147
+ }