|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import os |
|
import datasets |
|
|
|
logger = datasets.logging.get_logger(__name__) |
|
|
|
|
|
""" Toronto emotional speech set (TESS) Dataset""" |
|
|
|
_CITATION = """\ |
|
@data{SP2/E8H2MF_2020, |
|
author = {Pichora-Fuller, M. Kathleen and Dupuis, Kate}, |
|
publisher = {Borealis}, |
|
title = {{Toronto emotional speech set (TESS)}}, |
|
year = {2020}, |
|
version = {DRAFT VERSION}, |
|
doi = {10.5683/SP2/E8H2MF}, |
|
url = {https://doi.org/10.5683/SP2/E8H2MF} |
|
} |
|
""" |
|
|
|
_DESCRIPTION = """\ |
|
These stimuli were modeled on the Northwestern University Auditory |
|
Test No. 6 (NU-6; Tillman & Carhart, 1966). |
|
A set of 200 target words were spoken in the carrier phrase |
|
"Say the word _____' by two actresses (aged 26 and 64 years) and |
|
recordings were made of the set portraying each of seven emotions |
|
(anger, disgust, fear, happiness, pleasant surprise, sadness, and neutral). |
|
There are 2800 stimuli in total. Two actresses were recruited from |
|
the Toronto area. Both actresses speak English as their first language, |
|
are university educated, and have musical training. Audiometric testing |
|
indicated that both actresses have thresholds within the normal range. (2010-06-21) |
|
""" |
|
|
|
_HOMEPAGE = "https://doi.org/10.5683/SP2/E8H2MF" |
|
_LICENSE = "CC BY-NC 4.0" |
|
|
|
_ROOT_DIR = "tess" |
|
_DATA_URL = f"data/{_ROOT_DIR}.zip" |
|
|
|
_CLASS_NAMES = [ |
|
"neutral", |
|
"happy", |
|
"sad", |
|
"angry", |
|
"fear", |
|
"disgust", |
|
"ps", |
|
] |
|
|
|
|
|
class TessDataset(datasets.GeneratorBasedBuilder): |
|
"""The Tess dataset""" |
|
|
|
VERSION = datasets.Version("1.0.0") |
|
|
|
def _info(self): |
|
sampling_rate = 24_400 |
|
features = datasets.Features( |
|
{ |
|
"path": datasets.Value("string"), |
|
"audio": datasets.Audio(sampling_rate=sampling_rate), |
|
"speaker_id": datasets.Value("string"), |
|
"speaker_age": datasets.Value("int8"), |
|
"text": datasets.Value("string"), |
|
"word": datasets.Value("string"), |
|
"label": datasets.ClassLabel(names=_CLASS_NAMES), |
|
} |
|
) |
|
|
|
return datasets.DatasetInfo( |
|
description=_DESCRIPTION, |
|
features=features, |
|
homepage=_HOMEPAGE, |
|
citation=_CITATION, |
|
license=_LICENSE, |
|
|
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
|
|
archive_path = dl_manager.download_and_extract(_DATA_URL) |
|
|
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TRAIN, |
|
gen_kwargs={"archive_path": archive_path}, |
|
) |
|
] |
|
|
|
def _generate_examples(self, archive_path): |
|
"speaker_word_label.wav (audio/wav) num bytes." |
|
|
|
filepath = os.path.join(archive_path, _ROOT_DIR, "MANIFEST.TXT") |
|
|
|
examples = {} |
|
with open(filepath, encoding="utf-8") as f: |
|
for row in f: |
|
filename = row.split()[0] |
|
speakerId, word, label = filename.split(".")[0].split("_") |
|
audio_path = os.path.join(archive_path, _ROOT_DIR, filename) |
|
examples[audio_path] = { |
|
"path": audio_path, |
|
"speaker_id": speakerId, |
|
"speaker_age": 64 if speakerId == "OAF" else 26, |
|
"text": f"Say the word {word}", |
|
"word": word, |
|
"label": label, |
|
} |
|
|
|
id_ = 0 |
|
for path in list(examples.keys()): |
|
with open(path, "rb") as f: |
|
audio_bytes = f.read() |
|
audio = {"path": path, "bytes": audio_bytes} |
|
yield id_, {**examples[path], "audio": audio} |
|
id_ += 1 |
|
|