albertvillanova HF Staff commited on
Commit
3e78835
·
verified ·
1 Parent(s): e2ad60c

Create dataset

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