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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# coding=utf-8
|
| 2 |
+
# Copyright 2022 The HuggingFace Datasets Authors and the current dataset script contributor.
|
| 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 |
+
import os
|
| 17 |
+
import datasets # type: ignore
|
| 18 |
+
|
| 19 |
+
logger = datasets.logging.get_logger(__name__)
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
"""CREMA-D (Crowd-sourced Emotional Multimodal Actors Dataset)"""
|
| 23 |
+
|
| 24 |
+
_CITATION = """\
|
| 25 |
+
@article{cao2014crema,
|
| 26 |
+
title={CREMA-D: Crowd-sourced Emotional Multimodal Actors Dataset},
|
| 27 |
+
author={Cao, H. and Cooper, D. G. and Keutmann, M. K. and Gur, R. C. and Nenkova, A. and Verma, R.},
|
| 28 |
+
journal={IEEE transactions on affective computing},
|
| 29 |
+
volume={5},
|
| 30 |
+
number={4},
|
| 31 |
+
pages={377--390},
|
| 32 |
+
year={2014},
|
| 33 |
+
doi={10.1109/TAFFC.2014.2336244},
|
| 34 |
+
url={https://doi.org/10.1109/TAFFC.2014.2336244}
|
| 35 |
+
}
|
| 36 |
+
"""
|
| 37 |
+
|
| 38 |
+
_DESCRIPTION = """\
|
| 39 |
+
CREMA-D is a data set of 7,442 original clips from 91 actors.
|
| 40 |
+
These clips were from 48 male and 43 female actors between the ages of 20 and 74
|
| 41 |
+
coming from a variety of races and ethnicities (African America, Asian, Caucasian, Hispanic, and Unspecified).
|
| 42 |
+
Actors spoke from a selection of 12 sentences.
|
| 43 |
+
The sentences were presented using one of six different emotions (Anger, Disgust, Fear, Happy, Neutral and Sad)
|
| 44 |
+
and four different emotion levels (Low, Medium, High and Unspecified).
|
| 45 |
+
Participants rated the emotion and emotion levels based on the combined audiovisual presentation,
|
| 46 |
+
the video alone, and the audio alone. Due to the large number of ratings needed, this effort was crowd-sourced
|
| 47 |
+
and a total of 2443 participants each rated 90 unique clips, 30 audio, 30 visual, and 30 audio-visual.
|
| 48 |
+
95% of the clips have more than 7 rating.
|
| 49 |
+
"""
|
| 50 |
+
|
| 51 |
+
_HOMEPAGE = "https://github.com/CheyneyComputerScience/CREMA-D"
|
| 52 |
+
_LICENSE = "ODbL"
|
| 53 |
+
|
| 54 |
+
_ROOT_DIR = "crema_d"
|
| 55 |
+
_DATA_URL = f"data/{_ROOT_DIR}.tar.gz"
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
_SENTENCE_MAP = {
|
| 59 |
+
"IEO": "It's eleven o'clock",
|
| 60 |
+
"TIE": "That is exactly what happened",
|
| 61 |
+
"IOM": "I'm on my way to the meeting",
|
| 62 |
+
"IWW": "I wonder what this is about",
|
| 63 |
+
"TAI": "The airplane is almost full",
|
| 64 |
+
"MTI": "Maybe tomorrow it will be cold",
|
| 65 |
+
"IWL": "I would like a new alarm clock",
|
| 66 |
+
"ITH": "I think I have a doctor's appointment",
|
| 67 |
+
"DFA": "Don't forget a jacket",
|
| 68 |
+
"ITS": "I think I've seen this before",
|
| 69 |
+
"TSI": "The surface is slick",
|
| 70 |
+
"WSI": "We'll stop in a couple of minutes",
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
_EMOTION_MAP = {
|
| 75 |
+
"ANG": "anger",
|
| 76 |
+
"DIS": "disgust",
|
| 77 |
+
"FEA": "fear",
|
| 78 |
+
"HAP": "happy",
|
| 79 |
+
"NEU": "neutral",
|
| 80 |
+
"SAD": "sad",
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
_INTENSITY_MAP = {
|
| 84 |
+
"LO": "Low",
|
| 85 |
+
"MD": "Medium",
|
| 86 |
+
"HI": "High",
|
| 87 |
+
"XX": "Unspecified",
|
| 88 |
+
## on stray file
|
| 89 |
+
"X": "Unspecified",
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
_CLASS_NAMES = list(_EMOTION_MAP.values())
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
class CremaDDataset(datasets.GeneratorBasedBuilder):
|
| 96 |
+
"""The Crema-D dataset"""
|
| 97 |
+
|
| 98 |
+
VERSION = datasets.Version("1.0.0")
|
| 99 |
+
|
| 100 |
+
def _info(self):
|
| 101 |
+
sampling_rate = 16_000
|
| 102 |
+
features = datasets.Features(
|
| 103 |
+
{
|
| 104 |
+
# "path": datasets.Value("string"),
|
| 105 |
+
"audio": datasets.Audio(sampling_rate=sampling_rate),
|
| 106 |
+
"actor_id": datasets.Value("string"),
|
| 107 |
+
"sentence": datasets.Value("string"),
|
| 108 |
+
# "emotion": datasets.Value("string"),
|
| 109 |
+
"emotion_intensity": datasets.Value("string"),
|
| 110 |
+
"label": datasets.ClassLabel(names=_CLASS_NAMES),
|
| 111 |
+
}
|
| 112 |
+
)
|
| 113 |
+
|
| 114 |
+
return datasets.DatasetInfo(
|
| 115 |
+
description=_DESCRIPTION,
|
| 116 |
+
features=features,
|
| 117 |
+
homepage=_HOMEPAGE,
|
| 118 |
+
citation=_CITATION,
|
| 119 |
+
license=_LICENSE,
|
| 120 |
+
# task_templates=[datasets.TaskTemplate("audio-classification")],
|
| 121 |
+
)
|
| 122 |
+
|
| 123 |
+
def _split_generators(self, dl_manager):
|
| 124 |
+
|
| 125 |
+
archive = dl_manager.download(_DATA_URL)
|
| 126 |
+
local_extracted_archive = (
|
| 127 |
+
dl_manager.extract(archive) if not dl_manager.is_streaming else None
|
| 128 |
+
)
|
| 129 |
+
|
| 130 |
+
return [
|
| 131 |
+
datasets.SplitGenerator(
|
| 132 |
+
name=datasets.Split.TRAIN,
|
| 133 |
+
gen_kwargs={
|
| 134 |
+
# "archive_path": _ROOT_DIR,
|
| 135 |
+
"local_extracted_archive": local_extracted_archive,
|
| 136 |
+
"audio_files": dl_manager.iter_archive(archive),
|
| 137 |
+
},
|
| 138 |
+
)
|
| 139 |
+
]
|
| 140 |
+
|
| 141 |
+
def _generate_examples(self, local_extracted_archive, audio_files):
|
| 142 |
+
"4digitActorId_sentenceId_emotionId_emotionLevel"
|
| 143 |
+
|
| 144 |
+
id_ = 0
|
| 145 |
+
for path, f in audio_files:
|
| 146 |
+
path = os.path.join(
|
| 147 |
+
local_extracted_archive, path
|
| 148 |
+
) # if local_extracted_archive else path
|
| 149 |
+
filename = os.path.basename(path)
|
| 150 |
+
with open(path, "rb") as f:
|
| 151 |
+
audio_bytes = f.read()
|
| 152 |
+
actor_id, sentence_id, emotion_id, emotion_level = filename.split(".")[
|
| 153 |
+
0
|
| 154 |
+
].split("_")
|
| 155 |
+
base = {
|
| 156 |
+
"path": path,
|
| 157 |
+
"actor_id": actor_id,
|
| 158 |
+
"sentence": _SENTENCE_MAP[sentence_id],
|
| 159 |
+
"label": _EMOTION_MAP[emotion_id],
|
| 160 |
+
"emotion_intensity": _INTENSITY_MAP[emotion_level],
|
| 161 |
+
}
|
| 162 |
+
audio = {"path": path, "bytes": audio_bytes}
|
| 163 |
+
yield id_, {**base, "audio": audio}
|
| 164 |
+
id_ += 1
|
data/crema_d.tar.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:87b9dcce1fdcad68f8769201e047b505ff31cb38c782a6757aa2fb59c31e5590
|
| 3 |
+
size 470756748
|