Update nsynth-script.py
Browse files- nsynth-script.py +27 -8
nsynth-script.py
CHANGED
|
@@ -41,7 +41,19 @@ class Nsynth(datasets.GeneratorBasedBuilder):
|
|
| 41 |
"label": datasets.ClassLabel(names=CLASSES),
|
| 42 |
}
|
| 43 |
),
|
| 44 |
-
name="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
description='',
|
| 46 |
),
|
| 47 |
]
|
|
@@ -89,10 +101,17 @@ class Nsynth(datasets.GeneratorBasedBuilder):
|
|
| 89 |
for filename in os.listdir(audio_path):
|
| 90 |
audio_filename = os.path.join(audio_path, filename)
|
| 91 |
guid = filename.replace('.wav', '')
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
"label": datasets.ClassLabel(names=CLASSES),
|
| 42 |
}
|
| 43 |
),
|
| 44 |
+
name="instrument",
|
| 45 |
+
description='',
|
| 46 |
+
),
|
| 47 |
+
NsynthConfig(
|
| 48 |
+
features=datasets.Features(
|
| 49 |
+
{
|
| 50 |
+
"file": datasets.Value("string"),
|
| 51 |
+
"audio": datasets.Audio(sampling_rate=SAMPLE_RATE),
|
| 52 |
+
"pitch": datasets.Value("string"),
|
| 53 |
+
"label": datasets.ClassLabel(names=[str(idx) for idx in range(128)]),
|
| 54 |
+
}
|
| 55 |
+
),
|
| 56 |
+
name="pitch",
|
| 57 |
description='',
|
| 58 |
),
|
| 59 |
]
|
|
|
|
| 101 |
for filename in os.listdir(audio_path):
|
| 102 |
audio_filename = os.path.join(audio_path, filename)
|
| 103 |
guid = filename.replace('.wav', '')
|
| 104 |
+
if self.config.name == 'instrument':
|
| 105 |
+
yield guid, {
|
| 106 |
+
"id": str(guid),
|
| 107 |
+
"audio": audio_filename,
|
| 108 |
+
"instrument": examples[guid]["instrument_family_str"],
|
| 109 |
+
"label": examples[guid]["instrument_family_str"],
|
| 110 |
+
}
|
| 111 |
+
elif self.config.name == 'pitch':
|
| 112 |
+
yield guid, {
|
| 113 |
+
"id": str(guid),
|
| 114 |
+
"audio": audio_filename,
|
| 115 |
+
"pitch": examples[guid]["pitch"],
|
| 116 |
+
"label": examples[guid]["instrument_family_str"],
|
| 117 |
+
}
|