|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""SUPERB: Speech processing Universal PERformance Benchmark.""" |
|
|
|
|
|
import glob |
|
import os |
|
import textwrap |
|
|
|
import datasets |
|
|
|
|
|
_CITATION = """\ |
|
@article{DBLP:journals/corr/abs-2105-01051, |
|
author = {Shu{-}Wen Yang and |
|
Po{-}Han Chi and |
|
Yung{-}Sung Chuang and |
|
Cheng{-}I Jeff Lai and |
|
Kushal Lakhotia and |
|
Yist Y. Lin and |
|
Andy T. Liu and |
|
Jiatong Shi and |
|
Xuankai Chang and |
|
Guan{-}Ting Lin and |
|
Tzu{-}Hsien Huang and |
|
Wei{-}Cheng Tseng and |
|
Ko{-}tik Lee and |
|
Da{-}Rong Liu and |
|
Zili Huang and |
|
Shuyan Dong and |
|
Shang{-}Wen Li and |
|
Shinji Watanabe and |
|
Abdelrahman Mohamed and |
|
Hung{-}yi Lee}, |
|
title = {{SUPERB:} Speech processing Universal PERformance Benchmark}, |
|
journal = {CoRR}, |
|
volume = {abs/2105.01051}, |
|
year = {2021}, |
|
url = {https://arxiv.org/abs/2105.01051}, |
|
archivePrefix = {arXiv}, |
|
eprint = {2105.01051}, |
|
timestamp = {Thu, 01 Jul 2021 13:30:22 +0200}, |
|
biburl = {https://dblp.org/rec/journals/corr/abs-2105-01051.bib}, |
|
bibsource = {dblp computer science bibliography, https://dblp.org} |
|
} |
|
""" |
|
|
|
_DESCRIPTION = """\ |
|
Self-supervised learning (SSL) has proven vital for advancing research in |
|
natural language processing (NLP) and computer vision (CV). The paradigm |
|
pretrains a shared model on large volumes of unlabeled data and achieves |
|
state-of-the-art (SOTA) for various tasks with minimal adaptation. However, the |
|
speech processing community lacks a similar setup to systematically explore the |
|
paradigm. To bridge this gap, we introduce Speech processing Universal |
|
PERformance Benchmark (SUPERB). SUPERB is a leaderboard to benchmark the |
|
performance of a shared model across a wide range of speech processing tasks |
|
with minimal architecture changes and labeled data. Among multiple usages of the |
|
shared model, we especially focus on extracting the representation learned from |
|
SSL due to its preferable re-usability. We present a simple framework to solve |
|
SUPERB tasks by learning task-specialized lightweight prediction heads on top of |
|
the frozen shared model. Our results demonstrate that the framework is promising |
|
as SSL representations show competitive generalizability and accessibility |
|
across SUPERB tasks. We release SUPERB as a challenge with a leaderboard and a |
|
benchmark toolkit to fuel the research in representation learning and general |
|
speech processing. |
|
|
|
Note that in order to limit the required storage for preparing this dataset, the |
|
audio is stored in the .flac format and is not converted to a float32 array. To |
|
convert, the audio file to a float32 array, please make use of the `.map()` |
|
function as follows: |
|
|
|
|
|
```python |
|
import soundfile as sf |
|
|
|
def map_to_array(batch): |
|
speech_array, _ = sf.read(batch["file"]) |
|
batch["speech"] = speech_array |
|
return batch |
|
|
|
dataset = dataset.map(map_to_array, remove_columns=["file"]) |
|
``` |
|
""" |
|
|
|
|
|
class AsrDummybConfig(datasets.BuilderConfig): |
|
"""BuilderConfig for Superb.""" |
|
|
|
def __init__( |
|
self, |
|
data_url, |
|
url, |
|
**kwargs, |
|
): |
|
super(AsrDummybConfig, self).__init__(version=datasets.Version("1.9.0", ""), **kwargs) |
|
self.data_url = data_url |
|
self.url = url |
|
|
|
|
|
class AsrDummy(datasets.GeneratorBasedBuilder): |
|
"""Superb dataset.""" |
|
|
|
BUILDER_CONFIGS = [ |
|
AsrDummybConfig( |
|
name="asr", |
|
description=textwrap.dedent( |
|
"""\ |
|
ASR transcribes utterances into words. While PR analyzes the |
|
improvement in modeling phonetics, ASR reflects the significance of |
|
the improvement in a real-world scenario. LibriSpeech |
|
train-clean-100/dev-clean/test-clean subsets are used for |
|
training/validation/testing. The evaluation metric is word error |
|
rate (WER).""" |
|
), |
|
url="http://www.openslr.org/12", |
|
data_url="http://www.openslr.org/resources/12/", |
|
) |
|
] |
|
|
|
DEFAULT_CONFIG_NAME = "asr" |
|
|
|
def _info(self): |
|
return datasets.DatasetInfo( |
|
description=_DESCRIPTION, |
|
features=datasets.Features( |
|
{ |
|
"file": datasets.Value("string"), |
|
"text": datasets.Value("string"), |
|
"speaker_id": datasets.Value("int64"), |
|
"chapter_id": datasets.Value("int64"), |
|
"id": datasets.Value("string"), |
|
} |
|
), |
|
supervised_keys=("file", "text"), |
|
homepage=self.config.url, |
|
citation=_CITATION, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
_DL_URLS = { |
|
"test": self.config.data_url + "test-clean.tar.gz", |
|
} |
|
archive_path = dl_manager.download_and_extract(_DL_URLS) |
|
|
|
return [ |
|
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"archive_path": archive_path["test"]}), |
|
] |
|
|
|
def _generate_examples(self, archive_path): |
|
"""Generate examples.""" |
|
transcripts_glob = os.path.join(archive_path, "LibriSpeech", "*/*/*/*.txt") |
|
for transcript_file in sorted(glob.glob(transcripts_glob)): |
|
path = os.path.dirname(transcript_file) |
|
with open(os.path.join(path, transcript_file), "r", encoding="utf-8") as f: |
|
for line in f: |
|
line = line.strip() |
|
key, transcript = line.split(" ", 1) |
|
audio_file = f"{key}.flac" |
|
speaker_id, chapter_id = [int(el) for el in key.split("-")[:2]] |
|
example = { |
|
"id": key, |
|
"speaker_id": speaker_id, |
|
"chapter_id": chapter_id, |
|
"file": os.path.join(path, audio_file), |
|
"text": transcript, |
|
} |
|
yield key, example |
|
|