JJFrancisco
commited on
Commit
•
cbdca64
1
Parent(s):
c5b524e
Upload 3 files
Browse files- test-user.py +125 -0
- test.tsv +5 -0
- test.zip +3 -0
test-user.py
ADDED
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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/gcjavi/dataviewer-test"
|
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 |
+
"sentence": 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 |
+
return [datasets.SplitGenerator(
|
93 |
+
name=datasets.Split.TEST,
|
94 |
+
gen_kwargs={
|
95 |
+
"meta_path": meta_path["test"],
|
96 |
+
"audio_files": dl_manager.iter_archive(audio_path),
|
97 |
+
"local_extracted_archive": local_extracted_archive,
|
98 |
+
}
|
99 |
+
)]
|
100 |
+
|
101 |
+
def _generate_examples(self, meta_path, audio_files, local_extracted_archive):
|
102 |
+
"""Lorem ipsum."""
|
103 |
+
data_fields = list(self._info().features.keys())
|
104 |
+
metadata = {}
|
105 |
+
with open(meta_path, encoding="utf-8") as f:
|
106 |
+
next(f)
|
107 |
+
for row in f:
|
108 |
+
print(row)
|
109 |
+
r = row.split("\t")
|
110 |
+
print(r)
|
111 |
+
audio_id = r[0]
|
112 |
+
sentence = r[1]
|
113 |
+
metadata[audio_id] = {"audio_id": audio_id,
|
114 |
+
"sentence": sentence}
|
115 |
+
|
116 |
+
id_ = 0
|
117 |
+
for path, f in audio_files:
|
118 |
+
print(path, f)
|
119 |
+
_, audio_name = os.path.split(path)
|
120 |
+
if audio_name in metadata:
|
121 |
+
result = dict(metadata[audio_name])
|
122 |
+
path = os.path.join(local_extracted_archive, "test", path) if local_extracted_archive else path
|
123 |
+
result["audio"] = {"path": path, "bytes":f.read()}
|
124 |
+
yield id_, result
|
125 |
+
id_ +=1
|
test.tsv
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"audio_id" "sentence"
|
2 |
+
"DSPG_011_16012017_4.98_5.67.wav" "bos días."
|
3 |
+
"DSPG_011_16012017_5.85_7.08.wav" "vamos a dar comezo a sesión"
|
4 |
+
"DSPG_011_16012017_40.98_41.97.wav" "abrese a sesión."
|
5 |
+
"DSPG_011_16012017_43.68_50.25.wav" "a orde do día está publicada no boletín oficial do parlamento de galicia polo que non procederemos á sua lectura."
|
test.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:38514134b33884d6f055943617d19c7126297408a865e415f9dfa5c07a250579
|
3 |
+
size 270146
|