gcjavi commited on
Commit
e65315a
1 Parent(s): 5a7bc8e

updated script

Browse files
Files changed (2) hide show
  1. README.md +12 -5
  2. test-user.py +126 -0
README.md CHANGED
@@ -7,12 +7,19 @@ license:
7
  - mit
8
  multilinguality:
9
  - monolingual
10
- configs:
11
  - config_name: default
12
- datafiles:
13
- - split: train
14
- path: transcript/train.tsv
15
-
 
 
 
 
 
 
 
16
  ---
17
 
18
 
 
7
  - mit
8
  multilinguality:
9
  - monolingual
10
+ dataset_info:
11
  - config_name: default
12
+ features:
13
+ - name: path
14
+ dtype: string
15
+ - name: audio
16
+ dtype:
17
+ audio:
18
+ sampling_rate: 16000
19
+ - name: sentence
20
+ dtype: string
21
+ - name: speaker_id
22
+ dtype: string
23
  ---
24
 
25
 
test-user.py ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Lint as: python3
3
+
4
+
5
+ import csv
6
+ import os
7
+ import json
8
+
9
+ import datasets
10
+ from datasets.utils.py_utils import size_str
11
+ from tqdm import tqdm
12
+
13
+
14
+ _CITATION = """\
15
+ @inproceedings{panayotov2015librispeech,
16
+ title={Librispeech: an ASR corpus based on public domain audio books},
17
+ author={Panayotov, Vassil and Chen, Guoguo and Povey, Daniel and Khudanpur, Sanjeev},
18
+ booktitle={Acoustics, Speech and Signal Processing (ICASSP), 2015 IEEE International Conference on},
19
+ pages={5206--5210},
20
+ year={2015},
21
+ organization={IEEE}
22
+ }
23
+ """
24
+
25
+ _DESCRIPTION = """\
26
+ Lorem ipsum
27
+ """
28
+
29
+
30
+ _BASE_URL = "https://huggingface.co/datasets/gcjavi/dataviewer-test"
31
+ _DATA_URL = "data/train.zip"
32
+ _PROMPTS_URLS = {"train": "transcript/train.tsv"}
33
+
34
+ logger = datasets.logging.get_logger(__name__)
35
+
36
+ class TestConfig(datasets.BuilderConfig):
37
+
38
+ def __init__(self, name, **kwargs):
39
+ # self.language = kwargs.pop("language", None)
40
+ # self.release_date = kwargs.pop("release_date", None)
41
+ # self.num_clips = kwargs.pop("num_clips", None)
42
+ # self.num_speakers = kwargs.pop("num_speakers", None)
43
+ # self.validated_hr = kwargs.pop("validated_hr", None)
44
+ # self.total_hr = kwargs.pop("total_hr", None)
45
+ # self.size_bytes = kwargs.pop("size_bytes", None)
46
+ # self.size_human = size_str(self.size_bytes)
47
+ description = (
48
+ f"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor "
49
+ f"incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud "
50
+ f"exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure "
51
+ f"dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. "
52
+ f"Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt "
53
+ f"mollit anim id est laborum."
54
+ )
55
+ super(TestConfig, self).__init__(
56
+ name=name,
57
+ description=description,
58
+ **kwargs,
59
+ )
60
+
61
+ class TestASR(datasets.GeneratorBasedBuilder):
62
+ """Lorem ipsum."""
63
+
64
+
65
+ BUILDER_CONFIGS = [
66
+ TestConfig(
67
+ name="dataviewer-test",
68
+ )
69
+ ]
70
+
71
+ def _info(self):
72
+ return datasets.DatasetInfo(
73
+ description=_DESCRIPTION,
74
+ features=datasets.Features(
75
+ {
76
+ "path": datasets.Value("string"),
77
+ "audio": datasets.Audio(sampling_rate=16_000),
78
+ "sentence": datasets.Value("string"),
79
+ "speaker_id": datasets.Value("string")
80
+ }
81
+ ),
82
+ supervised_keys=None,
83
+ homepage=_BASE_URL,
84
+ citation=_CITATION
85
+ )
86
+
87
+ def _split_generators(self, dl_manager):
88
+ audio_path = dl_manager.download(_DATA_URL)
89
+ local_extracted_archive = dl_manager.extract(audio_path) if not dl_manager.is_streaming else None
90
+ meta_path = dl_manager.download(_PROMPTS_URLS)
91
+ return [datasets.SplitGenerator(
92
+ name=datasets.Split.TEST,
93
+ gen_kwargs={
94
+ "meta_path": meta_path["train"],
95
+ "audio_files": dl_manager.iter_archive(audio_path),
96
+ "local_extracted_archive": local_extracted_archive,
97
+ }
98
+ )]
99
+
100
+ def _generate_examples(self, meta_path, audio_files, local_extracted_archive):
101
+ """Lorem ipsum."""
102
+ data_fields = list(self._info().features.keys())
103
+ metadata = {}
104
+ with open(meta_path, encoding="utf-8") as f:
105
+ next(f)
106
+ for row in f:
107
+ print(row)
108
+ r = row.split("\t")
109
+ print(r)
110
+ audio_id = r[0]
111
+ sentence = r[1]
112
+ speaker_id = r[2]
113
+ metadata[audio_id] = {"path": audio_id,
114
+ "sentence": sentence,
115
+ "speaker_id": speaker_id}
116
+
117
+ id_ = 0
118
+ for path, f in audio_files:
119
+ print(path, f)
120
+ _, audio_name = os.path.split(path)
121
+ if audio_name in metadata:
122
+ result = dict(metadata[audio_name])
123
+ path = os.path.join(local_extracted_archive, "train", path) if local_extracted_archive else path
124
+ result["audio"] = {"path": path, "bytes":f.read()}
125
+ yield id_, result
126
+ id_ +=1