EdwardHayashi-2023
commited on
Commit
•
a7c4bc5
1
Parent(s):
ec8fc1b
Update aesdd.py
Browse files
aesdd.py
CHANGED
@@ -12,7 +12,11 @@
|
|
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 |
"""Acted Emotional Speech Dynamic Database v1.0"""
|
17 |
|
18 |
_CITATION = """\
|
@@ -45,6 +49,103 @@ Consequently, around 500 utterances occured in the final database.
|
|
45 |
|
46 |
_HOMEPAGE = "http://m3c.web.auth.gr/research/aesdd-speech-emotion-recognition/"
|
47 |
|
|
|
48 |
|
|
|
49 |
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 = """\
|
|
|
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 |
+
#------------------------------------------------------------------------------
|