Update superb_demo.py
Browse files- superb_demo.py +19 -6
superb_demo.py
CHANGED
|
@@ -135,6 +135,7 @@ class Superb(datasets.GeneratorBasedBuilder):
|
|
| 135 |
features=datasets.Features(
|
| 136 |
{
|
| 137 |
"file": datasets.Value("string"),
|
|
|
|
| 138 |
"text": datasets.Value("string"),
|
| 139 |
"speaker_id": datasets.Value("int64"),
|
| 140 |
"chapter_id": datasets.Value("int64"),
|
|
@@ -159,6 +160,7 @@ class Superb(datasets.GeneratorBasedBuilder):
|
|
| 159 |
features=datasets.Features(
|
| 160 |
{
|
| 161 |
"file": datasets.Value("string"),
|
|
|
|
| 162 |
"label": datasets.ClassLabel(
|
| 163 |
names=[
|
| 164 |
"yes",
|
|
@@ -192,6 +194,7 @@ class Superb(datasets.GeneratorBasedBuilder):
|
|
| 192 |
features=datasets.Features(
|
| 193 |
{
|
| 194 |
"file": datasets.Value("string"),
|
|
|
|
| 195 |
"speaker_id": datasets.Value("string"),
|
| 196 |
"text": datasets.Value("string"),
|
| 197 |
"action": datasets.ClassLabel(
|
|
@@ -234,6 +237,7 @@ class Superb(datasets.GeneratorBasedBuilder):
|
|
| 234 |
features=datasets.Features(
|
| 235 |
{
|
| 236 |
"file": datasets.Value("string"),
|
|
|
|
| 237 |
"label": datasets.ClassLabel(names=[f"id{i + 10001}" for i in range(1251)]),
|
| 238 |
}
|
| 239 |
),
|
|
@@ -253,6 +257,7 @@ class Superb(datasets.GeneratorBasedBuilder):
|
|
| 253 |
features=datasets.Features(
|
| 254 |
{
|
| 255 |
"file": datasets.Value("string"),
|
|
|
|
| 256 |
"label": datasets.ClassLabel(names=['neu', 'hap', 'ang', 'sad']),
|
| 257 |
}
|
| 258 |
),
|
|
@@ -327,11 +332,13 @@ class Superb(datasets.GeneratorBasedBuilder):
|
|
| 327 |
id_, transcript = line.split(" ", 1)
|
| 328 |
audio_file = f"{id_}.flac"
|
| 329 |
speaker_id, chapter_id = [int(el) for el in id_.split("-")[:2]]
|
|
|
|
| 330 |
yield key, {
|
| 331 |
"id": id_,
|
| 332 |
"speaker_id": speaker_id,
|
| 333 |
"chapter_id": chapter_id,
|
| 334 |
-
"file":
|
|
|
|
| 335 |
"text": transcript,
|
| 336 |
}
|
| 337 |
key += 1
|
|
@@ -347,7 +354,7 @@ class Superb(datasets.GeneratorBasedBuilder):
|
|
| 347 |
label = "_silence_"
|
| 348 |
else:
|
| 349 |
label = "_unknown_"
|
| 350 |
-
yield key, {"file": audio_file, "label": label}
|
| 351 |
elif self.config.name == "ic":
|
| 352 |
root_path = os.path.join(archive_path, "fluent_speech_commands_dataset/")
|
| 353 |
csv_path = os.path.join(root_path, f"data/{split}_data.csv")
|
|
@@ -356,8 +363,10 @@ class Superb(datasets.GeneratorBasedBuilder):
|
|
| 356 |
next(csv_reader)
|
| 357 |
for row in csv_reader:
|
| 358 |
key, file_path, speaker_id, text, action, object_, location = row
|
|
|
|
| 359 |
yield key, {
|
| 360 |
-
"file":
|
|
|
|
| 361 |
"speaker_id": speaker_id,
|
| 362 |
"text": text,
|
| 363 |
"action": action,
|
|
@@ -373,8 +382,10 @@ class Superb(datasets.GeneratorBasedBuilder):
|
|
| 373 |
if int(split_id) != split:
|
| 374 |
continue
|
| 375 |
speaker_id = file_path.split("/")[0]
|
|
|
|
| 376 |
yield key, {
|
| 377 |
-
"file":
|
|
|
|
| 378 |
"label": speaker_id,
|
| 379 |
}
|
| 380 |
elif self.config.name == "er":
|
|
@@ -393,9 +404,11 @@ class Superb(datasets.GeneratorBasedBuilder):
|
|
| 393 |
continue
|
| 394 |
wav_subdir = filename.rsplit("_", 1)[0]
|
| 395 |
filename = f"{filename}.wav"
|
|
|
|
| 396 |
yield key, {
|
| 397 |
-
"file":
|
| 398 |
-
"
|
|
|
|
| 399 |
}
|
| 400 |
key += 1
|
| 401 |
|
|
|
|
| 135 |
features=datasets.Features(
|
| 136 |
{
|
| 137 |
"file": datasets.Value("string"),
|
| 138 |
+
"audio": datasets.features.Audio(sampling_rate=16_000),
|
| 139 |
"text": datasets.Value("string"),
|
| 140 |
"speaker_id": datasets.Value("int64"),
|
| 141 |
"chapter_id": datasets.Value("int64"),
|
|
|
|
| 160 |
features=datasets.Features(
|
| 161 |
{
|
| 162 |
"file": datasets.Value("string"),
|
| 163 |
+
"audio": datasets.features.Audio(sampling_rate=16_000),
|
| 164 |
"label": datasets.ClassLabel(
|
| 165 |
names=[
|
| 166 |
"yes",
|
|
|
|
| 194 |
features=datasets.Features(
|
| 195 |
{
|
| 196 |
"file": datasets.Value("string"),
|
| 197 |
+
"audio": datasets.features.Audio(sampling_rate=16_000),
|
| 198 |
"speaker_id": datasets.Value("string"),
|
| 199 |
"text": datasets.Value("string"),
|
| 200 |
"action": datasets.ClassLabel(
|
|
|
|
| 237 |
features=datasets.Features(
|
| 238 |
{
|
| 239 |
"file": datasets.Value("string"),
|
| 240 |
+
"audio": datasets.features.Audio(sampling_rate=16_000),
|
| 241 |
"label": datasets.ClassLabel(names=[f"id{i + 10001}" for i in range(1251)]),
|
| 242 |
}
|
| 243 |
),
|
|
|
|
| 257 |
features=datasets.Features(
|
| 258 |
{
|
| 259 |
"file": datasets.Value("string"),
|
| 260 |
+
"audio": datasets.features.Audio(sampling_rate=16_000),
|
| 261 |
"label": datasets.ClassLabel(names=['neu', 'hap', 'ang', 'sad']),
|
| 262 |
}
|
| 263 |
),
|
|
|
|
| 332 |
id_, transcript = line.split(" ", 1)
|
| 333 |
audio_file = f"{id_}.flac"
|
| 334 |
speaker_id, chapter_id = [int(el) for el in id_.split("-")[:2]]
|
| 335 |
+
audio_path = os.path.join(transcript_dir_path, audio_file)
|
| 336 |
yield key, {
|
| 337 |
"id": id_,
|
| 338 |
"speaker_id": speaker_id,
|
| 339 |
"chapter_id": chapter_id,
|
| 340 |
+
"file": audio_path,
|
| 341 |
+
"audio": audio_path,
|
| 342 |
"text": transcript,
|
| 343 |
}
|
| 344 |
key += 1
|
|
|
|
| 354 |
label = "_silence_"
|
| 355 |
else:
|
| 356 |
label = "_unknown_"
|
| 357 |
+
yield key, {"file": audio_file, "audio": audio_file, "label": label}
|
| 358 |
elif self.config.name == "ic":
|
| 359 |
root_path = os.path.join(archive_path, "fluent_speech_commands_dataset/")
|
| 360 |
csv_path = os.path.join(root_path, f"data/{split}_data.csv")
|
|
|
|
| 363 |
next(csv_reader)
|
| 364 |
for row in csv_reader:
|
| 365 |
key, file_path, speaker_id, text, action, object_, location = row
|
| 366 |
+
audio_path = os.path.join(root_path, file_path)
|
| 367 |
yield key, {
|
| 368 |
+
"file": audio_path,
|
| 369 |
+
"audio": audio_path,
|
| 370 |
"speaker_id": speaker_id,
|
| 371 |
"text": text,
|
| 372 |
"action": action,
|
|
|
|
| 382 |
if int(split_id) != split:
|
| 383 |
continue
|
| 384 |
speaker_id = file_path.split("/")[0]
|
| 385 |
+
audio_path = os.path.join(wav_path, file_path)
|
| 386 |
yield key, {
|
| 387 |
+
"file": audio_path,
|
| 388 |
+
"audio": audio_path,
|
| 389 |
"label": speaker_id,
|
| 390 |
}
|
| 391 |
elif self.config.name == "er":
|
|
|
|
| 404 |
continue
|
| 405 |
wav_subdir = filename.rsplit("_", 1)[0]
|
| 406 |
filename = f"{filename}.wav"
|
| 407 |
+
audio_path = os.path.join(wav_path, wav_subdir, filename)
|
| 408 |
yield key, {
|
| 409 |
+
"file": audio_path,
|
| 410 |
+
"audio": audio_path,
|
| 411 |
+
"label": emo.replace("exc", "hap"),
|
| 412 |
}
|
| 413 |
key += 1
|
| 414 |
|