Delete loading script
Browse files- superb_dummy.py +0 -273
superb_dummy.py
DELETED
@@ -1,273 +0,0 @@
|
|
1 |
-
# coding=utf-8
|
2 |
-
# Copyright 2021 The TensorFlow Datasets Authors and the HuggingFace Datasets Authors.
|
3 |
-
#
|
4 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
# you may not use this file except in compliance with the License.
|
6 |
-
# You may obtain a copy of the License at
|
7 |
-
#
|
8 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
-
#
|
10 |
-
# Unless required by applicable law or agreed to in writing, software
|
11 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
-
# See the License for the specific language governing permissions and
|
14 |
-
# limitations under the License.
|
15 |
-
|
16 |
-
# Lint as: python3
|
17 |
-
"""SUPERB: Speech processing Universal PERformance Benchmark."""
|
18 |
-
|
19 |
-
|
20 |
-
import base64
|
21 |
-
import json
|
22 |
-
import textwrap
|
23 |
-
|
24 |
-
import datasets
|
25 |
-
import numpy as np
|
26 |
-
|
27 |
-
_CITATION = """\
|
28 |
-
@article{DBLP:journals/corr/abs-2105-01051,
|
29 |
-
author = {Shu{-}Wen Yang and
|
30 |
-
Po{-}Han Chi and
|
31 |
-
Yung{-}Sung Chuang and
|
32 |
-
Cheng{-}I Jeff Lai and
|
33 |
-
Kushal Lakhotia and
|
34 |
-
Yist Y. Lin and
|
35 |
-
Andy T. Liu and
|
36 |
-
Jiatong Shi and
|
37 |
-
Xuankai Chang and
|
38 |
-
Guan{-}Ting Lin and
|
39 |
-
Tzu{-}Hsien Huang and
|
40 |
-
Wei{-}Cheng Tseng and
|
41 |
-
Ko{-}tik Lee and
|
42 |
-
Da{-}Rong Liu and
|
43 |
-
Zili Huang and
|
44 |
-
Shuyan Dong and
|
45 |
-
Shang{-}Wen Li and
|
46 |
-
Shinji Watanabe and
|
47 |
-
Abdelrahman Mohamed and
|
48 |
-
Hung{-}yi Lee},
|
49 |
-
title = {{SUPERB:} Speech processing Universal PERformance Benchmark},
|
50 |
-
journal = {CoRR},
|
51 |
-
volume = {abs/2105.01051},
|
52 |
-
year = {2021},
|
53 |
-
url = {https://arxiv.org/abs/2105.01051},
|
54 |
-
archivePrefix = {arXiv},
|
55 |
-
eprint = {2105.01051},
|
56 |
-
timestamp = {Thu, 01 Jul 2021 13:30:22 +0200},
|
57 |
-
biburl = {https://dblp.org/rec/journals/corr/abs-2105-01051.bib},
|
58 |
-
bibsource = {dblp computer science bibliography, https://dblp.org}
|
59 |
-
}
|
60 |
-
"""
|
61 |
-
|
62 |
-
_DESCRIPTION = """\
|
63 |
-
Self-supervised learning (SSL) has proven vital for advancing research in
|
64 |
-
natural language processing (NLP) and computer vision (CV). The paradigm
|
65 |
-
pretrains a shared model on large volumes of unlabeled data and achieves
|
66 |
-
state-of-the-art (SOTA) for various tasks with minimal adaptation. However, the
|
67 |
-
speech processing community lacks a similar setup to systematically explore the
|
68 |
-
paradigm. To bridge this gap, we introduce Speech processing Universal
|
69 |
-
PERformance Benchmark (SUPERB). SUPERB is a leaderboard to benchmark the
|
70 |
-
performance of a shared model across a wide range of speech processing tasks
|
71 |
-
with minimal architecture changes and labeled data. Among multiple usages of the
|
72 |
-
shared model, we especially focus on extracting the representation learned from
|
73 |
-
SSL due to its preferable re-usability. We present a simple framework to solve
|
74 |
-
SUPERB tasks by learning task-specialized lightweight prediction heads on top of
|
75 |
-
the frozen shared model. Our results demonstrate that the framework is promising
|
76 |
-
as SSL representations show competitive generalizability and accessibility
|
77 |
-
across SUPERB tasks. We release SUPERB as a challenge with a leaderboard and a
|
78 |
-
benchmark toolkit to fuel the research in representation learning and general
|
79 |
-
speech processing.
|
80 |
-
"""
|
81 |
-
|
82 |
-
|
83 |
-
class SuperbConfig(datasets.BuilderConfig):
|
84 |
-
"""BuilderConfig for Superb."""
|
85 |
-
|
86 |
-
def __init__(
|
87 |
-
self,
|
88 |
-
features,
|
89 |
-
url,
|
90 |
-
data_url=None,
|
91 |
-
supervised_keys=None,
|
92 |
-
**kwargs,
|
93 |
-
):
|
94 |
-
super().__init__(version=datasets.Version("1.9.0", ""), **kwargs)
|
95 |
-
self.features = features
|
96 |
-
self.data_url = data_url
|
97 |
-
self.url = url
|
98 |
-
self.supervised_keys = supervised_keys
|
99 |
-
|
100 |
-
|
101 |
-
class Superb(datasets.GeneratorBasedBuilder):
|
102 |
-
"""Superb dataset."""
|
103 |
-
|
104 |
-
BUILDER_CONFIGS = [
|
105 |
-
SuperbConfig(
|
106 |
-
name="ks",
|
107 |
-
description=textwrap.dedent(
|
108 |
-
"""\
|
109 |
-
Keyword Spotting (KS) detects preregistered keywords by classifying utterances into a predefined set of
|
110 |
-
words. The task is usually performed on-device for the fast response time. Thus, accuracy, model size, and
|
111 |
-
inference time are all crucial. SUPERB uses the widely used [Speech Commands dataset v1.0] for the task.
|
112 |
-
The dataset consists of ten classes of keywords, a class for silence, and an unknown class to include the
|
113 |
-
false positive. The evaluation metric is accuracy (ACC)"""
|
114 |
-
),
|
115 |
-
features=datasets.Features(
|
116 |
-
{
|
117 |
-
"file": datasets.Value("string"),
|
118 |
-
"label": datasets.ClassLabel(
|
119 |
-
names=[
|
120 |
-
"yes",
|
121 |
-
"no",
|
122 |
-
"up",
|
123 |
-
"down",
|
124 |
-
"left",
|
125 |
-
"right",
|
126 |
-
"on",
|
127 |
-
"off",
|
128 |
-
"stop",
|
129 |
-
"go",
|
130 |
-
"_silence_",
|
131 |
-
"_unknown_",
|
132 |
-
]
|
133 |
-
),
|
134 |
-
"speech": datasets.Sequence(datasets.Value("float32")),
|
135 |
-
}
|
136 |
-
),
|
137 |
-
url="https://www.tensorflow.org/datasets/catalog/speech_commands",
|
138 |
-
data_url="ks.json",
|
139 |
-
),
|
140 |
-
SuperbConfig(
|
141 |
-
name="ic",
|
142 |
-
description=textwrap.dedent(
|
143 |
-
"""\
|
144 |
-
Intent Classification (IC) classifies utterances into predefined classes to determine the intent of
|
145 |
-
speakers. SUPERB uses the Fluent Speech Commands dataset, where each utterance is tagged with three intent
|
146 |
-
labels: action, object, and location. The evaluation metric is accuracy (ACC)."""
|
147 |
-
),
|
148 |
-
features=datasets.Features(
|
149 |
-
{
|
150 |
-
"file": datasets.Value("string"),
|
151 |
-
"speaker_id": datasets.Value("string"),
|
152 |
-
"text": datasets.Value("string"),
|
153 |
-
"action": datasets.ClassLabel(
|
154 |
-
names=["activate", "bring", "change language", "deactivate", "decrease", "increase"]
|
155 |
-
),
|
156 |
-
"object": datasets.ClassLabel(
|
157 |
-
names=[
|
158 |
-
"Chinese",
|
159 |
-
"English",
|
160 |
-
"German",
|
161 |
-
"Korean",
|
162 |
-
"heat",
|
163 |
-
"juice",
|
164 |
-
"lamp",
|
165 |
-
"lights",
|
166 |
-
"music",
|
167 |
-
"newspaper",
|
168 |
-
"none",
|
169 |
-
"shoes",
|
170 |
-
"socks",
|
171 |
-
"volume",
|
172 |
-
]
|
173 |
-
),
|
174 |
-
"location": datasets.ClassLabel(names=["bedroom", "kitchen", "none", "washroom"]),
|
175 |
-
"speech": datasets.Sequence(datasets.Value("float32")),
|
176 |
-
}
|
177 |
-
),
|
178 |
-
url="https://fluent.ai/fluent-speech-commands-a-dataset-for-spoken-language-understanding-research/",
|
179 |
-
data_url="ic.json",
|
180 |
-
),
|
181 |
-
SuperbConfig(
|
182 |
-
name="si",
|
183 |
-
description=textwrap.dedent(
|
184 |
-
"""\
|
185 |
-
Speaker Identification (SI) classifies each utterance for its speaker identity as a multi-class
|
186 |
-
classification, where speakers are in the same predefined set for both training and testing. The widely
|
187 |
-
used VoxCeleb1 dataset is adopted, and the evaluation metric is accuracy (ACC)."""
|
188 |
-
),
|
189 |
-
features=datasets.Features(
|
190 |
-
{
|
191 |
-
"file": datasets.Value("string"),
|
192 |
-
"label": datasets.ClassLabel(names=[f"id{i+10001}" for i in range(1251)]),
|
193 |
-
"speech": datasets.Sequence(datasets.Value("float32")),
|
194 |
-
}
|
195 |
-
),
|
196 |
-
url="https://www.robots.ox.ac.uk/~vgg/data/voxceleb/vox1.html",
|
197 |
-
data_url="si.json",
|
198 |
-
),
|
199 |
-
SuperbConfig(
|
200 |
-
name="er",
|
201 |
-
description=textwrap.dedent(
|
202 |
-
"""\
|
203 |
-
Emotion Recognition (ER) predicts an emotion class for each utterance. The most widely used ER dataset
|
204 |
-
IEMOCAP is adopted, and we follow the conventional evaluation protocol: we drop the unbalance emotion
|
205 |
-
classes to leave the final four classes with a similar amount of data points and cross-validates on five
|
206 |
-
folds of the standard splits. The evaluation metric is accuracy (ACC)."""
|
207 |
-
),
|
208 |
-
features=datasets.Features(
|
209 |
-
{
|
210 |
-
"file": datasets.Value("string"),
|
211 |
-
"label": datasets.ClassLabel(names=["neu", "hap", "ang", "sad"]),
|
212 |
-
"speech": datasets.Sequence(datasets.Value("float32")),
|
213 |
-
}
|
214 |
-
),
|
215 |
-
url="https://sail.usc.edu/iemocap/",
|
216 |
-
data_url="er.json",
|
217 |
-
),
|
218 |
-
SuperbConfig(
|
219 |
-
name="sd",
|
220 |
-
description=textwrap.dedent(
|
221 |
-
"""\
|
222 |
-
Speaker Diarization (SD) predicts `who is speaking when` for each timestamp, and multiple speakers can
|
223 |
-
speak simultaneously. The model has to encode rich speaker characteristics for each frame and should be
|
224 |
-
able to represent mixtures of signals. [LibriMix] is adopted where LibriSpeech
|
225 |
-
train-clean-100/dev-clean/test-clean are used to generate mixtures for training/validation/testing.
|
226 |
-
We focus on the two-speaker scenario as the first step. The time-coded speaker labels were generated using
|
227 |
-
alignments from Kaldi LibriSpeech ASR model. The evaluation metric is diarization error rate (DER)."""
|
228 |
-
),
|
229 |
-
features=datasets.Features(
|
230 |
-
{
|
231 |
-
"file": datasets.Value("string"),
|
232 |
-
"speech": datasets.Sequence(datasets.Value("float32")),
|
233 |
-
"speakers": [
|
234 |
-
{
|
235 |
-
"speaker_id": datasets.Value("string"),
|
236 |
-
"start": datasets.Value("int64"),
|
237 |
-
"end": datasets.Value("int64"),
|
238 |
-
}
|
239 |
-
],
|
240 |
-
}
|
241 |
-
),
|
242 |
-
url="https://github.com/ftshijt/LibriMix",
|
243 |
-
data_url="sd.json",
|
244 |
-
),
|
245 |
-
]
|
246 |
-
|
247 |
-
def _info(self):
|
248 |
-
return datasets.DatasetInfo(
|
249 |
-
description=_DESCRIPTION,
|
250 |
-
features=self.config.features,
|
251 |
-
supervised_keys=self.config.supervised_keys,
|
252 |
-
homepage=self.config.url,
|
253 |
-
citation=_CITATION,
|
254 |
-
)
|
255 |
-
|
256 |
-
def _split_generators(self, dl_manager):
|
257 |
-
data_path = dl_manager.download_and_extract(self.config.data_url)
|
258 |
-
|
259 |
-
return [
|
260 |
-
datasets.SplitGenerator(
|
261 |
-
name=datasets.Split.TEST,
|
262 |
-
gen_kwargs={"data_path": data_path},
|
263 |
-
)
|
264 |
-
]
|
265 |
-
|
266 |
-
def _generate_examples(self, data_path):
|
267 |
-
"""Generate examples."""
|
268 |
-
with open(data_path, "r", encoding="utf-8") as f:
|
269 |
-
for key, line in enumerate(f):
|
270 |
-
example = json.loads(line)
|
271 |
-
example["speech"] = np.frombuffer(base64.b64decode(example["speech"]), dtype=np.float32)
|
272 |
-
|
273 |
-
yield key, example
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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