File size: 6,374 Bytes
d62f361
e9df96f
d62f361
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5ecde28
d62f361
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# 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.
#------------------------------------------------------------------------------
# Standard Libraries
import datasets
import os
#------------------------------------------------------------------------------
"""Acted Emotional Speech Dynamic Database v1.0"""

_CITATION = """\
@article{vryzas2018speech,
  title={Speech emotion recognition for performance interaction},
  author={Vryzas, Nikolaos and Kotsakis, Rigas and Liatsou, Aikaterini and Dimoulas, Charalampos A and Kalliris, George},
  journal={Journal of the Audio Engineering Society},
  volume={66},
  number={6},
  pages={457--467},
  year={2018},
  publisher={Audio Engineering Society}
}
"""

_DESCRIPTION = """\
AESDD v1.0 was created on October 2017 in the Laboratory of Electronic Media, 
School of Journalism and Mass Communications, Aristotle University of Thessaloniki, 
for the needs of Speech Emotion Recognition research of the Multidisciplinary Media & 
Mediated Communication Research Group (M3C, http://m3c.web.auth.gr/).

For the creation of v.1 of the database, 5 (3 female and 2 male) professional actors were recorded. 
19 utterances of ambiguous out of context emotional content were chosen. 
The actors acted these 19 utterances in every one of the 5 chosen emotions. 
One extra improvised utterance was added for every actor and emotion. 
The guidance of the actors and the choice of the final recordings were supervised by 
a scientific expert in dramatology. For some of the utterances, more that one takes were qualified. 
Consequently, around 500 utterances occured in the final database.
"""

_HOMEPAGE = "http://m3c.web.auth.gr/research/aesdd-speech-emotion-recognition/"

_LICENSE = "CC BY 4.0"

_DATA_URL = "https://drive.google.com/uc?export=download&id=1-pelMaCrfwoUCmwxUtlacRUBwbFnXlXA"

#------------------------------------------------------------------------------
# Define Dataset Configuration (e.g., subset of dataset, but it is not used here.)
class AESDDConfig(datasets.BuilderConfig):
    #--------------------------------------------------------------------------
    def __init__(self, name, description, homepage, data_url):
        
        super(AESDDConfig, self).__init__(
            name = self.name,
            version = datasets.Version("1.0.0"),
            description = self.description,
        )
        self.name = name
        self.description = description
        self.homepage = homepage
        self.data_url = data_url
#------------------------------------------------------------------------------
# Define Dataset Class
class AESDD(datasets.GeneratorBasedBuilder):
    #--------------------------------------------------------------------------
    BUILDER_CONFIGS = [AESDDConfig(
        name = "AESDD",
        description = _DESCRIPTION,
        homepage = _HOMEPAGE,
        data_url = _DATA_URL
        )]
    #--------------------------------------------------------------------------
    '''
        Define the "column header" (feature) of a datum.
        3 Features:
            1) path_to_file
            2) audio samples
            3) emotion label
            4) utterance: 1,2,...,20
            5) speaker id
    '''
    def _info(self):
        
        features = datasets.Features(
                {
                    "path": datasets.Value("string"),
                    "audio": datasets.Audio(sampling_rate = 44100),
                    "label": datasets.ClassLabel(
                        names = [
                            "anger",
                            "disgust",
                            "fear",
                            "happiness",
                            "sadness",
                        ]),
                    "utterance": datasets.Value("float"),
                    "speaker": datasets.Value("float")
                }
            )
        
        # return dataset info and data feature info
        return datasets.DatasetInfo(
            description = _DESCRIPTION,
            features = features,
            homepage = _HOMEPAGE,
            citation = _CITATION,
        )
    #--------------------------------------------------------------------------
    def _split_generators(self, dl_manager):
        
        dataset_path = dl_manager.download_and_extract(self.config.data_url)
        
        return [
            datasets.SplitGenerator(
                # set the whole dataset as "training set". No worry, can split later! 
                name = datasets.Split.TRAIN,
                # _generate_examples()'s parameters, thus name must match!
                gen_kwargs = {
                    "dataset_path": dataset_path
                },
            )
        ]
    #--------------------------------------------------------------------------   
    def _generate_examples(self, dataset_path):
        '''
            Get the audio file and set the corresponding labels
        '''
        key = 0
        for dir_name in ["anger", "disgust", "fear", "happiness", "sadness"]:
            dir_path = dataset_path + "/AESDD/" + dir_name
            for file_name in os.listdir(dir_path):
                if file_name.endswith(".wav"):
                    yield key, {
                        "path": dir_path + "/" + file_name,
                        # huggingface dataset's will use soundfile to read the audio file
                        "audio": dir_path + "/" + file_name,
                        "label": dir_name,
                        "utterance": float(file_name[1:3]),
                        "speaker": float(file_name[file_name.find("(")+1:file_name.find(")")]),
                    }
                    key += 1    
#------------------------------------------------------------------------------