Update esc50-script.py
Browse files- esc50-script.py +109 -108
esc50-script.py
CHANGED
|
@@ -6,6 +6,113 @@ from pathlib import Path
|
|
| 6 |
SAMPLE_RATE = 44_100
|
| 7 |
EXTENSION = '.wav'
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
class Esc50Config(datasets.BuilderConfig):
|
| 11 |
"""BuilderConfig for ESC50."""
|
|
@@ -30,9 +137,9 @@ class ESC50(datasets.GeneratorBasedBuilder):
|
|
| 30 |
"label": datasets.ClassLabel(names=ESC50_LABELS),
|
| 31 |
}
|
| 32 |
),
|
| 33 |
-
name="
|
| 34 |
description='',
|
| 35 |
-
),
|
| 36 |
]
|
| 37 |
|
| 38 |
def _info(self):
|
|
@@ -122,109 +229,3 @@ def fast_scandir(path: str, exts: tp.List[str], recursive: bool = False):
|
|
| 122 |
return subfolders, files
|
| 123 |
|
| 124 |
|
| 125 |
-
ESC50_LABELS = [
|
| 126 |
-
"airplane",
|
| 127 |
-
"breathing",
|
| 128 |
-
"brushing_teeth",
|
| 129 |
-
"can_opening",
|
| 130 |
-
"car_horn",
|
| 131 |
-
"cat",
|
| 132 |
-
"chainsaw",
|
| 133 |
-
"chirping_birds",
|
| 134 |
-
"church_bells",
|
| 135 |
-
"clapping",
|
| 136 |
-
"clock_alarm",
|
| 137 |
-
"clock_tick",
|
| 138 |
-
"coughing",
|
| 139 |
-
"cow",
|
| 140 |
-
"crackling_fire",
|
| 141 |
-
"crickets",
|
| 142 |
-
"crow",
|
| 143 |
-
"crying_baby",
|
| 144 |
-
"dog",
|
| 145 |
-
"door_wood_creaks",
|
| 146 |
-
"door_wood_knock",
|
| 147 |
-
"drinking_sipping",
|
| 148 |
-
"engine",
|
| 149 |
-
"fireworks",
|
| 150 |
-
"footsteps",
|
| 151 |
-
"frog",
|
| 152 |
-
"glass_breaking",
|
| 153 |
-
"hand_saw",
|
| 154 |
-
"helicopter",
|
| 155 |
-
"hen",
|
| 156 |
-
"insects",
|
| 157 |
-
"keyboard_typing",
|
| 158 |
-
"laughing",
|
| 159 |
-
"mouse_click",
|
| 160 |
-
"pig",
|
| 161 |
-
"pouring_water",
|
| 162 |
-
"rain",
|
| 163 |
-
"rooster",
|
| 164 |
-
"sea_waves",
|
| 165 |
-
"sheep",
|
| 166 |
-
"siren",
|
| 167 |
-
"sneezing",
|
| 168 |
-
"snoring",
|
| 169 |
-
"thunderstorm",
|
| 170 |
-
"toilet_flush",
|
| 171 |
-
"train",
|
| 172 |
-
"vacuum_cleaner",
|
| 173 |
-
"washing_machine",
|
| 174 |
-
"water_drops",
|
| 175 |
-
"wind",
|
| 176 |
-
]
|
| 177 |
-
|
| 178 |
-
ESC50_LABEL2ID = {
|
| 179 |
-
"dog": 0,
|
| 180 |
-
"rooster": 1,
|
| 181 |
-
"pig": 2,
|
| 182 |
-
"cow": 3,
|
| 183 |
-
"frog": 4,
|
| 184 |
-
"cat": 5,
|
| 185 |
-
"hen": 6,
|
| 186 |
-
"insects": 7,
|
| 187 |
-
"sheep": 8,
|
| 188 |
-
"crow": 9,
|
| 189 |
-
"rain": 10,
|
| 190 |
-
"sea_waves": 11,
|
| 191 |
-
"crackling_fire": 12,
|
| 192 |
-
"crickets": 13,
|
| 193 |
-
"chirping_birds": 14,
|
| 194 |
-
"water_drops": 15,
|
| 195 |
-
"wind": 16,
|
| 196 |
-
"pouring_water": 17,
|
| 197 |
-
"toilet_flush": 18,
|
| 198 |
-
"thunderstorm": 19,
|
| 199 |
-
"crying_baby": 20,
|
| 200 |
-
"sneezing": 21,
|
| 201 |
-
"clapping": 22,
|
| 202 |
-
"breathing": 23,
|
| 203 |
-
"coughing": 24,
|
| 204 |
-
"footsteps": 25,
|
| 205 |
-
"laughing": 26,
|
| 206 |
-
"brushing_teeth": 27,
|
| 207 |
-
"snoring": 28,
|
| 208 |
-
"drinking_sipping": 29,
|
| 209 |
-
"door_wood_knock": 30,
|
| 210 |
-
"mouse_click": 31,
|
| 211 |
-
"keyboard_typing": 32,
|
| 212 |
-
"door_wood_creaks": 33,
|
| 213 |
-
"can_opening": 34,
|
| 214 |
-
"washing_machine": 35,
|
| 215 |
-
"vacuum_cleaner": 36,
|
| 216 |
-
"clock_alarm": 37,
|
| 217 |
-
"clock_tick": 38,
|
| 218 |
-
"glass_breaking": 39,
|
| 219 |
-
"helicopter": 40,
|
| 220 |
-
"chainsaw": 41,
|
| 221 |
-
"siren": 42,
|
| 222 |
-
"car_horn": 43,
|
| 223 |
-
"engine": 44,
|
| 224 |
-
"train": 45,
|
| 225 |
-
"church_bells": 46,
|
| 226 |
-
"airplane": 47,
|
| 227 |
-
"fireworks": 48,
|
| 228 |
-
"hand_saw": 49
|
| 229 |
-
}
|
| 230 |
-
ESC50_ID2LABEL = {v:k for k, v in ESC50_LABEL2ID.items()}
|
|
|
|
| 6 |
SAMPLE_RATE = 44_100
|
| 7 |
EXTENSION = '.wav'
|
| 8 |
|
| 9 |
+
ESC50_LABELS = [
|
| 10 |
+
"airplane",
|
| 11 |
+
"breathing",
|
| 12 |
+
"brushing_teeth",
|
| 13 |
+
"can_opening",
|
| 14 |
+
"car_horn",
|
| 15 |
+
"cat",
|
| 16 |
+
"chainsaw",
|
| 17 |
+
"chirping_birds",
|
| 18 |
+
"church_bells",
|
| 19 |
+
"clapping",
|
| 20 |
+
"clock_alarm",
|
| 21 |
+
"clock_tick",
|
| 22 |
+
"coughing",
|
| 23 |
+
"cow",
|
| 24 |
+
"crackling_fire",
|
| 25 |
+
"crickets",
|
| 26 |
+
"crow",
|
| 27 |
+
"crying_baby",
|
| 28 |
+
"dog",
|
| 29 |
+
"door_wood_creaks",
|
| 30 |
+
"door_wood_knock",
|
| 31 |
+
"drinking_sipping",
|
| 32 |
+
"engine",
|
| 33 |
+
"fireworks",
|
| 34 |
+
"footsteps",
|
| 35 |
+
"frog",
|
| 36 |
+
"glass_breaking",
|
| 37 |
+
"hand_saw",
|
| 38 |
+
"helicopter",
|
| 39 |
+
"hen",
|
| 40 |
+
"insects",
|
| 41 |
+
"keyboard_typing",
|
| 42 |
+
"laughing",
|
| 43 |
+
"mouse_click",
|
| 44 |
+
"pig",
|
| 45 |
+
"pouring_water",
|
| 46 |
+
"rain",
|
| 47 |
+
"rooster",
|
| 48 |
+
"sea_waves",
|
| 49 |
+
"sheep",
|
| 50 |
+
"siren",
|
| 51 |
+
"sneezing",
|
| 52 |
+
"snoring",
|
| 53 |
+
"thunderstorm",
|
| 54 |
+
"toilet_flush",
|
| 55 |
+
"train",
|
| 56 |
+
"vacuum_cleaner",
|
| 57 |
+
"washing_machine",
|
| 58 |
+
"water_drops",
|
| 59 |
+
"wind",
|
| 60 |
+
]
|
| 61 |
+
|
| 62 |
+
ESC50_LABEL2ID = {
|
| 63 |
+
"dog": 0,
|
| 64 |
+
"rooster": 1,
|
| 65 |
+
"pig": 2,
|
| 66 |
+
"cow": 3,
|
| 67 |
+
"frog": 4,
|
| 68 |
+
"cat": 5,
|
| 69 |
+
"hen": 6,
|
| 70 |
+
"insects": 7,
|
| 71 |
+
"sheep": 8,
|
| 72 |
+
"crow": 9,
|
| 73 |
+
"rain": 10,
|
| 74 |
+
"sea_waves": 11,
|
| 75 |
+
"crackling_fire": 12,
|
| 76 |
+
"crickets": 13,
|
| 77 |
+
"chirping_birds": 14,
|
| 78 |
+
"water_drops": 15,
|
| 79 |
+
"wind": 16,
|
| 80 |
+
"pouring_water": 17,
|
| 81 |
+
"toilet_flush": 18,
|
| 82 |
+
"thunderstorm": 19,
|
| 83 |
+
"crying_baby": 20,
|
| 84 |
+
"sneezing": 21,
|
| 85 |
+
"clapping": 22,
|
| 86 |
+
"breathing": 23,
|
| 87 |
+
"coughing": 24,
|
| 88 |
+
"footsteps": 25,
|
| 89 |
+
"laughing": 26,
|
| 90 |
+
"brushing_teeth": 27,
|
| 91 |
+
"snoring": 28,
|
| 92 |
+
"drinking_sipping": 29,
|
| 93 |
+
"door_wood_knock": 30,
|
| 94 |
+
"mouse_click": 31,
|
| 95 |
+
"keyboard_typing": 32,
|
| 96 |
+
"door_wood_creaks": 33,
|
| 97 |
+
"can_opening": 34,
|
| 98 |
+
"washing_machine": 35,
|
| 99 |
+
"vacuum_cleaner": 36,
|
| 100 |
+
"clock_alarm": 37,
|
| 101 |
+
"clock_tick": 38,
|
| 102 |
+
"glass_breaking": 39,
|
| 103 |
+
"helicopter": 40,
|
| 104 |
+
"chainsaw": 41,
|
| 105 |
+
"siren": 42,
|
| 106 |
+
"car_horn": 43,
|
| 107 |
+
"engine": 44,
|
| 108 |
+
"train": 45,
|
| 109 |
+
"church_bells": 46,
|
| 110 |
+
"airplane": 47,
|
| 111 |
+
"fireworks": 48,
|
| 112 |
+
"hand_saw": 49
|
| 113 |
+
}
|
| 114 |
+
ESC50_ID2LABEL = {v:k for k, v in ESC50_LABEL2ID.items()}
|
| 115 |
+
|
| 116 |
|
| 117 |
class Esc50Config(datasets.BuilderConfig):
|
| 118 |
"""BuilderConfig for ESC50."""
|
|
|
|
| 137 |
"label": datasets.ClassLabel(names=ESC50_LABELS),
|
| 138 |
}
|
| 139 |
),
|
| 140 |
+
name=f"fold{f}",
|
| 141 |
description='',
|
| 142 |
+
) for f in range(1, 11)
|
| 143 |
]
|
| 144 |
|
| 145 |
def _info(self):
|
|
|
|
| 229 |
return subfolders, files
|
| 230 |
|
| 231 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|