carlosdanielhernandezmena commited on
Commit
6b3c87e
1 Parent(s): 8c90c7a

Delete loading script

Browse files
Files changed (1) hide show
  1. ciempiess_complementary.py +0 -131
ciempiess_complementary.py DELETED
@@ -1,131 +0,0 @@
1
- from collections import defaultdict
2
- import os
3
- import json
4
- import csv
5
-
6
- import datasets
7
-
8
- _NAME="ciempiess_complementary"
9
- _VERSION="1.0.0"
10
- _AUDIO_EXTENSIONS=".flac"
11
-
12
- _DESCRIPTION = """
13
- The CIEMPIESS COMPLEMENTARY Corpus was created with the voices of 10 male and 10 female volunteers reading isolated words. The words were chosen to assure users to get, at least, twenty instances of every single phoneme and allophone of the Mexican phonetic alphabet called Mexbet.
14
- """
15
-
16
- _CITATION = """
17
- @misc{carlosmenaciempiesscomplementary2019,
18
- title={CIEMPIESS COMPLEMENTARY CORPUS: Audio and Transcripts of Spanish Isolated Words.},
19
- ldc_catalog_no={LDC2019S07},
20
- DOI={https://doi.org/10.35111/xdx5-n815},
21
- author={Hernandez Mena, Carlos Daniel and Jiménez Sandoval, Susana Alejandra},
22
- journal={Linguistic Data Consortium, Philadelphia},
23
- year={2019},
24
- url={https://catalog.ldc.upenn.edu/LDC2019S07},
25
- }
26
- """
27
-
28
- _HOMEPAGE = "https://catalog.ldc.upenn.edu/LDC2019S07"
29
-
30
- _LICENSE = "CC-BY-SA-4.0, See https://creativecommons.org/licenses/by-sa/4.0/"
31
-
32
- _BASE_DATA_DIR = "corpus/"
33
- _METADATA_TRAIN = os.path.join(_BASE_DATA_DIR,"files", "metadata_train.tsv")
34
-
35
- _TARS_TRAIN = os.path.join(_BASE_DATA_DIR,"files", "tars_train.paths")
36
-
37
- class CiempiessComplementaryConfig(datasets.BuilderConfig):
38
- """BuilderConfig for CIEMPIESS COMPLEMENTARY Corpus"""
39
-
40
- def __init__(self, name, **kwargs):
41
- name=_NAME
42
- super().__init__(name=name, **kwargs)
43
-
44
- class CiempiessComplementary(datasets.GeneratorBasedBuilder):
45
- """CIEMPIESS COMPLEMENTARY Corpus"""
46
-
47
- VERSION = datasets.Version(_VERSION)
48
- BUILDER_CONFIGS = [
49
- CiempiessComplementaryConfig(
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
- "speaker_id": datasets.Value("string"),
61
- "gender": datasets.Value("string"),
62
- "duration": datasets.Value("float32"),
63
-
64
- "utt_type": datasets.Value("string"),
65
- "age": datasets.Value("int32"),
66
- "education": datasets.Value("string"),
67
- "birthplace": datasets.Value("string"),
68
- "residence": datasets.Value("string"),
69
-
70
-
71
- "normalized_text": datasets.Value("string"),
72
- }
73
- )
74
- return datasets.DatasetInfo(
75
- description=_DESCRIPTION,
76
- features=features,
77
- homepage=_HOMEPAGE,
78
- license=_LICENSE,
79
- citation=_CITATION,
80
- )
81
-
82
- def _split_generators(self, dl_manager):
83
-
84
- metadata_train=dl_manager.download_and_extract(_METADATA_TRAIN)
85
-
86
- tars_train=dl_manager.download_and_extract(_TARS_TRAIN)
87
-
88
- hash_tar_files=defaultdict(dict)
89
-
90
- with open(tars_train,'r') as f:
91
- hash_tar_files['train']=[path.replace('\n','') for path in f]
92
-
93
- hash_meta_paths={"train":metadata_train}
94
- audio_paths = dl_manager.download(hash_tar_files)
95
-
96
- splits=["train"]
97
- local_extracted_audio_paths = (
98
- dl_manager.extract(audio_paths) if not dl_manager.is_streaming else
99
- {
100
- split:[None] * len(audio_paths[split]) for split in splits
101
- }
102
- )
103
-
104
- return [
105
- datasets.SplitGenerator(
106
- name=datasets.Split.TRAIN,
107
- gen_kwargs={
108
- "audio_archives": [dl_manager.iter_archive(archive) for archive in audio_paths["train"]],
109
- "local_extracted_archives_paths": local_extracted_audio_paths["train"],
110
- "metadata_paths": hash_meta_paths["train"],
111
- }
112
- ),
113
- ]
114
-
115
- def _generate_examples(self, audio_archives, local_extracted_archives_paths, metadata_paths):
116
-
117
- features = ["speaker_id","gender","duration","utt_type","age","education","birthplace","residence","normalized_text"]
118
-
119
- with open(metadata_paths) as f:
120
- metadata = {x["audio_id"]: x for x in csv.DictReader(f, delimiter="\t")}
121
-
122
- for audio_archive, local_extracted_archive_path in zip(audio_archives, local_extracted_archives_paths):
123
- for audio_filename, audio_file in audio_archive:
124
- audio_id = audio_filename.split(os.sep)[-1].split(_AUDIO_EXTENSIONS)[0]
125
- path = os.path.join(local_extracted_archive_path, audio_filename) if local_extracted_archive_path else audio_filename
126
-
127
- yield audio_id, {
128
- "audio_id": audio_id,
129
- **{feature: metadata[audio_id][feature] for feature in features},
130
- "audio": {"path": path, "bytes": audio_file.read()},
131
- }