File size: 4,342 Bytes
4301d8d 3110f4b 4301d8d 3110f4b 4301d8d 05bff36 4301d8d 05bff36 4301d8d 05bff36 4301d8d 05bff36 4301d8d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# coding=utf-8
# Copyright 2022 The HuggingFace Datasets Authors and the current dataset script contributor.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import datasets # type: ignore
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,
# task_templates=[datasets.TaskTemplate("audio-classification")],
)
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
|