carlosdanielhernandezmena commited on
Commit
41b3311
1 Parent(s): 265ff40

Delete loading script

Browse files
Files changed (1) hide show
  1. dimex100_light.py +0 -122
dimex100_light.py DELETED
@@ -1,122 +0,0 @@
1
- from collections import defaultdict
2
- import os
3
- import json
4
- import csv
5
- import datasets
6
-
7
- _NAME="dimex100_light"
8
- _VERSION="1.0.0"
9
-
10
- _DESCRIPTION = """
11
- The DIMEx100 LIGHT Corpus is a reduced version of the DIMEx100 Adult Corpus,
12
- with the aim of facilitating the use of the DIMEx100 Corpus in various automatic
13
- speech recognition systems. DIMEx100 Adult Corpus was created by Dr. Luis Pineda
14
- from UNAM University at Mexico City.
15
- """
16
-
17
- _CITATION = """
18
- @misc{menadimex100light2017,
19
- title={DIMEx100 LIGHT CORPUS: Reduced version of the DIMEx100 Adult Corpus by Dr. Luis Pineda from UNAM University (Mexico).},
20
- author={Hernandez Mena, Carlos Daniel},
21
- year={2017},
22
- url={https://huggingface.co/datasets/carlosdanielhernandezmena/dimex100_light},
23
- }
24
- """
25
-
26
- _HOMEPAGE = "https://huggingface.co/datasets/carlosdanielhernandezmena/dimex100_light"
27
-
28
- _LICENSE = "CC-BY-NC-ND-4.0, See https://creativecommons.org/licenses/by-nc-nd/4.0/deed.en"
29
-
30
- _BASE_DATA_DIR = "corpus/"
31
- _METADATA_TRAIN = os.path.join(_BASE_DATA_DIR,"files", "metadata_train.tsv")
32
-
33
- _TARS_TRAIN = os.path.join(_BASE_DATA_DIR,"files", "tars_train.paths")
34
-
35
- class Dimex100LightConfig(datasets.BuilderConfig):
36
- """BuilderConfig for DIMEx100 LIGHT CORPUS"""
37
-
38
- def __init__(self, name, **kwargs):
39
- name=_NAME
40
- super().__init__(name=name, **kwargs)
41
-
42
- class Dimex100Light(datasets.GeneratorBasedBuilder):
43
- """DIMEx100 LIGHT CORPUS"""
44
-
45
- VERSION = datasets.Version(_VERSION)
46
- BUILDER_CONFIGS = [
47
- Dimex100LightConfig(
48
- name=_NAME,
49
- version=datasets.Version(_VERSION),
50
- )
51
- ]
52
-
53
- def _info(self):
54
- features = datasets.Features(
55
- {
56
- "audio_id": datasets.Value("string"),
57
- "audio": datasets.Audio(sampling_rate=16000),
58
- "speaker_id": datasets.Value("string"),
59
- "utterance_type": datasets.Value("string"),
60
- "gender": datasets.Value("string"),
61
- "duration": datasets.Value("float32"),
62
- "normalized_text": datasets.Value("string"),
63
- }
64
- )
65
- return datasets.DatasetInfo(
66
- description=_DESCRIPTION,
67
- features=features,
68
- homepage=_HOMEPAGE,
69
- license=_LICENSE,
70
- citation=_CITATION,
71
- )
72
-
73
- def _split_generators(self, dl_manager):
74
-
75
- metadata_train=dl_manager.download_and_extract(_METADATA_TRAIN)
76
-
77
- tars_train=dl_manager.download_and_extract(_TARS_TRAIN)
78
-
79
- hash_tar_files=defaultdict(dict)
80
-
81
- with open(tars_train,'r') as f:
82
- hash_tar_files['train']=[path.replace('\n','') for path in f]
83
-
84
- hash_meta_paths={"train":metadata_train}
85
- audio_paths = dl_manager.download(hash_tar_files)
86
-
87
- splits=["train"]
88
- local_extracted_audio_paths = (
89
- dl_manager.extract(audio_paths) if not dl_manager.is_streaming else
90
- {
91
- split:[None] * len(audio_paths[split]) for split in splits
92
- }
93
- )
94
-
95
- return [
96
- datasets.SplitGenerator(
97
- name=datasets.Split.TRAIN,
98
- gen_kwargs={
99
- "audio_archives": [dl_manager.iter_archive(archive) for archive in audio_paths["train"]],
100
- "local_extracted_archives_paths": local_extracted_audio_paths["train"],
101
- "metadata_paths": hash_meta_paths["train"],
102
- }
103
- ),
104
- ]
105
-
106
- def _generate_examples(self, audio_archives, local_extracted_archives_paths, metadata_paths):
107
-
108
- features = ["speaker_id","utterance_type","gender","duration","normalized_text"]
109
-
110
- with open(metadata_paths) as f:
111
- metadata = {x["audio_id"]: x for x in csv.DictReader(f, delimiter="\t")}
112
-
113
- for audio_archive, local_extracted_archive_path in zip(audio_archives, local_extracted_archives_paths):
114
- for audio_filename, audio_file in audio_archive:
115
- audio_id =os.path.splitext(os.path.basename(audio_filename))[0]
116
- path = os.path.join(local_extracted_archive_path, audio_filename) if local_extracted_archive_path else audio_filename
117
-
118
- yield audio_id, {
119
- "audio_id": audio_id,
120
- **{feature: metadata[audio_id][feature] for feature in features},
121
- "audio": {"path": path, "bytes": audio_file.read()},
122
- }