EdwardHayashi-2023 commited on
Commit ·
fd950f4
1
Parent(s): 28d14c9
Update MELD-Audio.py
Browse files- MELD-Audio.py +15 -13
MELD-Audio.py
CHANGED
|
@@ -111,38 +111,40 @@ class MELD_Audio(datasets.GeneratorBasedBuilder):
|
|
| 111 |
return [
|
| 112 |
datasets.SplitGenerator(
|
| 113 |
name = datasets.Split.TRAIN,
|
| 114 |
-
gen_kwargs = {"
|
|
|
|
|
|
|
| 115 |
),
|
| 116 |
datasets.SplitGenerator(
|
| 117 |
name=datasets.Split.VALIDATION,
|
| 118 |
-
gen_kwargs={"
|
|
|
|
|
|
|
| 119 |
),
|
| 120 |
datasets.SplitGenerator(
|
| 121 |
name=datasets.Split.TEST,
|
| 122 |
-
gen_kwargs={"
|
| 123 |
-
|
|
|
|
|
|
|
| 124 |
]
|
| 125 |
#--------------------------------------------------------------------------
|
| 126 |
-
def _generate_examples(self,
|
| 127 |
'''
|
| 128 |
Get the audio file and set the corresponding labels
|
| 129 |
'''
|
| 130 |
key = 0
|
| 131 |
-
|
| 132 |
-
with open(text_path, encoding = "utf-8") as csv_file:
|
| 133 |
csv_reader = csv.reader(csv_file, delimiter = ",", skipinitialspace=True)
|
| 134 |
next(csv_reader)
|
| 135 |
for row in csv_reader:
|
| 136 |
_, _, _, emotion, _, dialogue_id, utterance_id, _, _, _, _ = row
|
| 137 |
-
filename = "
|
| 138 |
yield key, {
|
| 139 |
-
"path":
|
| 140 |
# huggingface dataset's will use soundfile to read the audio file
|
| 141 |
-
"audio":
|
| 142 |
"label": emotion,
|
| 143 |
}
|
| 144 |
key += 1
|
| 145 |
#------------------------------------------------------------------------------
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
|
|
|
| 111 |
return [
|
| 112 |
datasets.SplitGenerator(
|
| 113 |
name = datasets.Split.TRAIN,
|
| 114 |
+
gen_kwargs = {"audio_path": dataset_path + "/MELD-Audio/train/",
|
| 115 |
+
"csv_path": dataset_path + "/MELD-Audio/train.csv"
|
| 116 |
+
},
|
| 117 |
),
|
| 118 |
datasets.SplitGenerator(
|
| 119 |
name=datasets.Split.VALIDATION,
|
| 120 |
+
gen_kwargs = {"audio_path": dataset_path + "/MELD-Audio/dev/",
|
| 121 |
+
"csv_path": dataset_path + "/MELD-Audio/dev.csv"
|
| 122 |
+
},
|
| 123 |
),
|
| 124 |
datasets.SplitGenerator(
|
| 125 |
name=datasets.Split.TEST,
|
| 126 |
+
gen_kwargs = {"audio_path": dataset_path + "/MELD-Audio/test/",
|
| 127 |
+
"csv_path": dataset_path + "/MELD-Audio/test.csv"
|
| 128 |
+
},
|
| 129 |
+
),
|
| 130 |
]
|
| 131 |
#--------------------------------------------------------------------------
|
| 132 |
+
def _generate_examples(self, audio_path, csv_path):
|
| 133 |
'''
|
| 134 |
Get the audio file and set the corresponding labels
|
| 135 |
'''
|
| 136 |
key = 0
|
| 137 |
+
with open(csv_path, encoding = "utf-8") as csv_file:
|
|
|
|
| 138 |
csv_reader = csv.reader(csv_file, delimiter = ",", skipinitialspace=True)
|
| 139 |
next(csv_reader)
|
| 140 |
for row in csv_reader:
|
| 141 |
_, _, _, emotion, _, dialogue_id, utterance_id, _, _, _, _ = row
|
| 142 |
+
filename = "dia" + dialogue_id + "_utt" + utterance_id + ".mp3"
|
| 143 |
yield key, {
|
| 144 |
+
"path": audio_path + filename,
|
| 145 |
# huggingface dataset's will use soundfile to read the audio file
|
| 146 |
+
"audio": audio_path + filename,
|
| 147 |
"label": emotion,
|
| 148 |
}
|
| 149 |
key += 1
|
| 150 |
#------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|