Datasets:
carlosdanielhernandezmena
commited on
Commit
•
ccf7cba
1
Parent(s):
329b196
Delete loading script
Browse files- voxforge_spanish.py +0 -121
voxforge_spanish.py
DELETED
@@ -1,121 +0,0 @@
|
|
1 |
-
from collections import defaultdict
|
2 |
-
import os
|
3 |
-
import json
|
4 |
-
import csv
|
5 |
-
import datasets
|
6 |
-
|
7 |
-
_NAME="voxforge_spanish"
|
8 |
-
_VERSION="1.0.0"
|
9 |
-
|
10 |
-
_DESCRIPTION = """
|
11 |
-
The VOXFORGE SPANISH CORPUS has a duration of 49 hours and it is constituted by read speech
|
12 |
-
recorded by more than 2 thousand speakers. Most of the speakers contribute with 10 recordings
|
13 |
-
of approximately 10 seconds of duration each.
|
14 |
-
"""
|
15 |
-
|
16 |
-
_CITATION = """
|
17 |
-
@misc{menavoxforgespanish2017,
|
18 |
-
title={VOXFORGE SPANISH CORPUS: Audio and Transcripts in Spanish with a CIEMPIESS Corpus style, taken from voxforge.org},
|
19 |
-
author={Hernandez Mena, Carlos Daniel},
|
20 |
-
year={2017},
|
21 |
-
url={https://huggingface.co/ciempiess/voxforge_spanish},
|
22 |
-
}
|
23 |
-
"""
|
24 |
-
|
25 |
-
_HOMEPAGE = "https://huggingface.co/ciempiess/voxforge_spanish"
|
26 |
-
|
27 |
-
_LICENSE = "GPLv3, See https://www.gnu.org/licenses/gpl.txt"
|
28 |
-
|
29 |
-
_BASE_DATA_DIR = "corpus/"
|
30 |
-
_METADATA_TRAIN = os.path.join(_BASE_DATA_DIR,"files", "metadata_train.tsv")
|
31 |
-
|
32 |
-
_TARS_TRAIN = os.path.join(_BASE_DATA_DIR,"files", "tars_train.paths")
|
33 |
-
|
34 |
-
class VoxforgeSpanishConfig(datasets.BuilderConfig):
|
35 |
-
"""BuilderConfig for VOXFORGE SPANISH CORPUS"""
|
36 |
-
|
37 |
-
def __init__(self, name, **kwargs):
|
38 |
-
name=_NAME
|
39 |
-
super().__init__(name=name, **kwargs)
|
40 |
-
|
41 |
-
class VoxforgeSpanish(datasets.GeneratorBasedBuilder):
|
42 |
-
"""VOXFORGE SPANISH CORPUS"""
|
43 |
-
|
44 |
-
VERSION = datasets.Version(_VERSION)
|
45 |
-
BUILDER_CONFIGS = [
|
46 |
-
VoxforgeSpanishConfig(
|
47 |
-
name=_NAME,
|
48 |
-
version=datasets.Version(_VERSION),
|
49 |
-
)
|
50 |
-
]
|
51 |
-
|
52 |
-
def _info(self):
|
53 |
-
features = datasets.Features(
|
54 |
-
{
|
55 |
-
"audio_id": datasets.Value("string"),
|
56 |
-
"audio": datasets.Audio(sampling_rate=16000),
|
57 |
-
"speaker_id": datasets.Value("string"),
|
58 |
-
"country": datasets.Value("string"),
|
59 |
-
"gender": datasets.Value("string"),
|
60 |
-
"duration": datasets.Value("float32"),
|
61 |
-
"normalized_text": datasets.Value("string"),
|
62 |
-
}
|
63 |
-
)
|
64 |
-
return datasets.DatasetInfo(
|
65 |
-
description=_DESCRIPTION,
|
66 |
-
features=features,
|
67 |
-
homepage=_HOMEPAGE,
|
68 |
-
license=_LICENSE,
|
69 |
-
citation=_CITATION,
|
70 |
-
)
|
71 |
-
|
72 |
-
def _split_generators(self, dl_manager):
|
73 |
-
|
74 |
-
metadata_train=dl_manager.download_and_extract(_METADATA_TRAIN)
|
75 |
-
|
76 |
-
tars_train=dl_manager.download_and_extract(_TARS_TRAIN)
|
77 |
-
|
78 |
-
hash_tar_files=defaultdict(dict)
|
79 |
-
|
80 |
-
with open(tars_train,'r') as f:
|
81 |
-
hash_tar_files['train']=[path.replace('\n','') for path in f]
|
82 |
-
|
83 |
-
hash_meta_paths={"train":metadata_train}
|
84 |
-
audio_paths = dl_manager.download(hash_tar_files)
|
85 |
-
|
86 |
-
splits=["train"]
|
87 |
-
local_extracted_audio_paths = (
|
88 |
-
dl_manager.extract(audio_paths) if not dl_manager.is_streaming else
|
89 |
-
{
|
90 |
-
split:[None] * len(audio_paths[split]) for split in splits
|
91 |
-
}
|
92 |
-
)
|
93 |
-
|
94 |
-
return [
|
95 |
-
datasets.SplitGenerator(
|
96 |
-
name=datasets.Split.TRAIN,
|
97 |
-
gen_kwargs={
|
98 |
-
"audio_archives": [dl_manager.iter_archive(archive) for archive in audio_paths["train"]],
|
99 |
-
"local_extracted_archives_paths": local_extracted_audio_paths["train"],
|
100 |
-
"metadata_paths": hash_meta_paths["train"],
|
101 |
-
}
|
102 |
-
),
|
103 |
-
]
|
104 |
-
|
105 |
-
def _generate_examples(self, audio_archives, local_extracted_archives_paths, metadata_paths):
|
106 |
-
|
107 |
-
features = ["speaker_id","country","gender","duration","normalized_text"]
|
108 |
-
|
109 |
-
with open(metadata_paths) as f:
|
110 |
-
metadata = {x["audio_id"]: x for x in csv.DictReader(f, delimiter="\t")}
|
111 |
-
|
112 |
-
for audio_archive, local_extracted_archive_path in zip(audio_archives, local_extracted_archives_paths):
|
113 |
-
for audio_filename, audio_file in audio_archive:
|
114 |
-
audio_id =os.path.splitext(os.path.basename(audio_filename))[0]
|
115 |
-
path = os.path.join(local_extracted_archive_path, audio_filename) if local_extracted_archive_path else audio_filename
|
116 |
-
|
117 |
-
yield audio_id, {
|
118 |
-
"audio_id": audio_id,
|
119 |
-
**{feature: metadata[audio_id][feature] for feature in features},
|
120 |
-
"audio": {"path": path, "bytes": audio_file.read()},
|
121 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|