fix: audio iteration
Browse files
speech-emotion-recognition-dataset.py
CHANGED
@@ -61,7 +61,7 @@ class SpeechEmotionRecognitionDataset(datasets.GeneratorBasedBuilder):
|
|
61 |
def _split_generators(self, dl_manager):
|
62 |
audio = dl_manager.download_and_extract(f"{_DATA}audio.zip")
|
63 |
annotations = dl_manager.download(f"{_DATA}{_NAME}.csv")
|
64 |
-
|
65 |
return [
|
66 |
datasets.SplitGenerator(name=datasets.Split.TRAIN,
|
67 |
gen_kwargs={
|
@@ -72,33 +72,33 @@ class SpeechEmotionRecognitionDataset(datasets.GeneratorBasedBuilder):
|
|
72 |
|
73 |
def _generate_examples(self, audio, annotations):
|
74 |
annotations_df = pd.read_csv(annotations, sep=';')
|
75 |
-
audio =
|
|
|
76 |
|
77 |
-
for idx,
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
for audio_file in sub_dir.iterdir():
|
82 |
-
if audio_file.name.startswith('euphoric'):
|
83 |
euphoric = audio_file
|
84 |
-
elif
|
85 |
joyfully = audio_file
|
86 |
-
elif
|
87 |
sad = audio_file
|
88 |
-
elif
|
89 |
surprised = audio_file
|
90 |
|
|
|
|
|
91 |
yield idx, {
|
92 |
'set_id':
|
93 |
set_id,
|
94 |
'euphoric':
|
95 |
-
|
96 |
'joyfully':
|
97 |
-
|
98 |
'sad':
|
99 |
-
|
100 |
'surprised':
|
101 |
-
|
102 |
'text':
|
103 |
annotations_df.loc[annotations_df['set_id'] == set_id]
|
104 |
['text'].values[0],
|
|
|
61 |
def _split_generators(self, dl_manager):
|
62 |
audio = dl_manager.download_and_extract(f"{_DATA}audio.zip")
|
63 |
annotations = dl_manager.download(f"{_DATA}{_NAME}.csv")
|
64 |
+
audio = dl_manager.iter_files(audio)
|
65 |
return [
|
66 |
datasets.SplitGenerator(name=datasets.Split.TRAIN,
|
67 |
gen_kwargs={
|
|
|
72 |
|
73 |
def _generate_examples(self, audio, annotations):
|
74 |
annotations_df = pd.read_csv(annotations, sep=';')
|
75 |
+
audio = list(audio)
|
76 |
+
audio = [audio[i:i + 4] for i in range(0, len(audio), 4)]
|
77 |
|
78 |
+
for idx, set in enumerate(audio):
|
79 |
+
for audio_file in set:
|
80 |
+
if 'euphoric' in audio_file:
|
|
|
|
|
|
|
81 |
euphoric = audio_file
|
82 |
+
elif 'joyfully' in audio_file:
|
83 |
joyfully = audio_file
|
84 |
+
elif 'sad' in audio_file:
|
85 |
sad = audio_file
|
86 |
+
elif 'surprised' in audio_file:
|
87 |
surprised = audio_file
|
88 |
|
89 |
+
set_id = Path(set[0]).parent.name
|
90 |
+
|
91 |
yield idx, {
|
92 |
'set_id':
|
93 |
set_id,
|
94 |
'euphoric':
|
95 |
+
euphoric,
|
96 |
'joyfully':
|
97 |
+
joyfully,
|
98 |
'sad':
|
99 |
+
sad,
|
100 |
'surprised':
|
101 |
+
surprised,
|
102 |
'text':
|
103 |
annotations_df.loc[annotations_df['set_id'] == set_id]
|
104 |
['text'].values[0],
|