EdwardHayashi-2023 commited on
Commit
d62f361
1 Parent(s): 749f4ae

Create AESDD.py

Browse files
Files changed (1) hide show
  1. AESDD.py +151 -0
AESDD.py ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2022 The PolyAI and 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
+ # Standard Libraries
17
+ import datasets
18
+ import os
19
+ #------------------------------------------------------------------------------
20
+ """Acted Emotional Speech Dynamic Database v1.0"""
21
+
22
+ _CITATION = """\
23
+ @article{vryzas2018speech,
24
+ title={Speech emotion recognition for performance interaction},
25
+ author={Vryzas, Nikolaos and Kotsakis, Rigas and Liatsou, Aikaterini and Dimoulas, Charalampos A and Kalliris, George},
26
+ journal={Journal of the Audio Engineering Society},
27
+ volume={66},
28
+ number={6},
29
+ pages={457--467},
30
+ year={2018},
31
+ publisher={Audio Engineering Society}
32
+ }
33
+ """
34
+
35
+ _DESCRIPTION = """\
36
+ AESDD v1.0 was created on October 2017 in the Laboratory of Electronic Media,
37
+ School of Journalism and Mass Communications, Aristotle University of Thessaloniki,
38
+ for the needs of Speech Emotion Recognition research of the Multidisciplinary Media &
39
+ Mediated Communication Research Group (M3C, http://m3c.web.auth.gr/).
40
+
41
+ For the creation of v.1 of the database, 5 (3 female and 2 male) professional actors were recorded.
42
+ 19 utterances of ambiguous out of context emotional content were chosen.
43
+ The actors acted these 19 utterances in every one of the 5 chosen emotions.
44
+ One extra improvised utterance was added for every actor and emotion.
45
+ The guidance of the actors and the choice of the final recordings were supervised by
46
+ a scientific expert in dramatology. For some of the utterances, more that one takes were qualified.
47
+ Consequently, around 500 utterances occured in the final database.
48
+ """
49
+
50
+ _HOMEPAGE = "http://m3c.web.auth.gr/research/aesdd-speech-emotion-recognition/"
51
+
52
+ _LICENSE = "CC BY 4.0"
53
+
54
+ _DATA_URL = "https://drive.google.com/uc?export=download&id=1-pelMaCrfwoUCmwxUtlacRUBwbFnXlXA"
55
+
56
+ #------------------------------------------------------------------------------
57
+ # Define Dataset Configuration (e.g., subset of dataset, but it is not used here.)
58
+ class AESDDConfig(datasets.BuilderConfig):
59
+ #--------------------------------------------------------------------------
60
+ def __init__(self, name, description, homepage, data_url):
61
+
62
+ super(AESDDConfig, self).__init__(
63
+ name = self.name,
64
+ version = datasets.Version("1.0.0"),
65
+ description = self.description,
66
+ )
67
+ self.name = name
68
+ self.description = description
69
+ self.homepage = homepage
70
+ self.data_url = data_url
71
+ #------------------------------------------------------------------------------
72
+ # Define Dataset Class
73
+ class AESDD(datasets.GeneratorBasedBuilder):
74
+ #--------------------------------------------------------------------------
75
+ BUILDER_CONFIGS = [AESDDConfig(
76
+ name = "AESDD",
77
+ description = _DESCRIPTION,
78
+ homepage = _HOMEPAGE,
79
+ data_url = _DATA_URL
80
+ )]
81
+ #--------------------------------------------------------------------------
82
+ '''
83
+ Define the "column header" (feature) of a datum.
84
+ 3 Features:
85
+ 1) path_to_file
86
+ 2) audio samples
87
+ 3) emotion label
88
+ 4) utterance: 1,2,...,20
89
+ 5) speaker id
90
+ '''
91
+ def _info(self):
92
+
93
+ features = datasets.Features(
94
+ {
95
+ "path": datasets.Value("string"),
96
+ "audio": datasets.Audio(sampling_rate = 441000),
97
+ "label": datasets.ClassLabel(
98
+ names = [
99
+ "anger",
100
+ "disgust",
101
+ "fear",
102
+ "happiness",
103
+ "sadness",
104
+ ]),
105
+ "utterance": datasets.Value("float"),
106
+ "speaker": datasets.Value("float")
107
+ }
108
+ )
109
+
110
+ # return dataset info and data feature info
111
+ return datasets.DatasetInfo(
112
+ description = _DESCRIPTION,
113
+ features = features,
114
+ homepage = _HOMEPAGE,
115
+ citation = _CITATION,
116
+ )
117
+ #--------------------------------------------------------------------------
118
+ def _split_generators(self, dl_manager):
119
+
120
+ dataset_path = dl_manager.download_and_extract(self.config.data_url)
121
+
122
+ return [
123
+ datasets.SplitGenerator(
124
+ # set the whole dataset as "training set". No worry, can split later!
125
+ name = datasets.Split.TRAIN,
126
+ # _generate_examples()'s parameters, thus name must match!
127
+ gen_kwargs = {
128
+ "dataset_path": dataset_path
129
+ },
130
+ )
131
+ ]
132
+ #--------------------------------------------------------------------------
133
+ def _generate_examples(self, dataset_path):
134
+ '''
135
+ Get the audio file and set the corresponding labels
136
+ '''
137
+ key = 0
138
+ for dir_name in ["anger", "disgust", "fear", "happiness", "sadness"]:
139
+ dir_path = dataset_path + "/AESDD/" + dir_name
140
+ for file_name in os.listdir(dir_path):
141
+ if file_name.endswith(".wav"):
142
+ yield key, {
143
+ "path": dir_path + "/" + file_name,
144
+ # huggingface dataset's will use soundfile to read the audio file
145
+ "audio": dir_path + "/" + file_name,
146
+ "label": dir_name,
147
+ "utterance": float(file_name[1:3]),
148
+ "speaker": float(file_name[file_name.find("(")+1:file_name.find(")")]),
149
+ }
150
+ key += 1
151
+ #------------------------------------------------------------------------------