Update pianos.py
Browse files
pianos.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
# coding=utf-8
|
2 |
|
3 |
-
"""Pianos
|
4 |
|
5 |
|
6 |
import os
|
@@ -69,18 +69,6 @@ class pianos(datasets.GeneratorBasedBuilder):
|
|
69 |
name="sound",
|
70 |
description=textwrap.dedent(_DESCRIPTION),
|
71 |
),
|
72 |
-
PianosConfig(
|
73 |
-
features=datasets.Features(
|
74 |
-
{
|
75 |
-
"file": datasets.Value("string"),
|
76 |
-
"audio": datasets.Audio(sampling_rate=SAMPLE_RATE),
|
77 |
-
"pitch": datasets.Value("string"),
|
78 |
-
"label": datasets.ClassLabel(names=list(_PITCHES.values())),
|
79 |
-
}
|
80 |
-
),
|
81 |
-
name="pitch",
|
82 |
-
description=textwrap.dedent(_DESCRIPTION),
|
83 |
-
),
|
84 |
]
|
85 |
|
86 |
def _info(self):
|
@@ -100,24 +88,14 @@ class pianos(datasets.GeneratorBasedBuilder):
|
|
100 |
for path in dl_manager.iter_files([data_files]):
|
101 |
fname = os.path.basename(path)
|
102 |
if fname.endswith(".wav"):
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
)
|
112 |
-
elif self.config.name == "pitch":
|
113 |
-
dataset.append(
|
114 |
-
{
|
115 |
-
"file": path,
|
116 |
-
"audio": path,
|
117 |
-
"label": _PITCHES[fname.split("_")[0]],
|
118 |
-
"pitch": _PITCHES[fname.split("_")[0]],
|
119 |
-
}
|
120 |
-
)
|
121 |
|
122 |
random.shuffle(dataset)
|
123 |
count = len(dataset)
|
@@ -138,19 +116,10 @@ class pianos(datasets.GeneratorBasedBuilder):
|
|
138 |
|
139 |
def _generate_examples(self, files):
|
140 |
for guid, path in enumerate(files):
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
}
|
149 |
-
elif self.config.name == "pitch":
|
150 |
-
yield guid, {
|
151 |
-
"id": str(guid),
|
152 |
-
"file": path["file"],
|
153 |
-
"audio": path["audio"],
|
154 |
-
"label": path["label"],
|
155 |
-
"pitch": path["pitch"],
|
156 |
-
}
|
|
|
1 |
# coding=utf-8
|
2 |
|
3 |
+
"""Pianos sound classification dataset."""
|
4 |
|
5 |
|
6 |
import os
|
|
|
69 |
name="sound",
|
70 |
description=textwrap.dedent(_DESCRIPTION),
|
71 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
]
|
73 |
|
74 |
def _info(self):
|
|
|
88 |
for path in dl_manager.iter_files([data_files]):
|
89 |
fname = os.path.basename(path)
|
90 |
if fname.endswith(".wav"):
|
91 |
+
dataset.append(
|
92 |
+
{
|
93 |
+
"file": path,
|
94 |
+
"audio": path,
|
95 |
+
"label": os.path.basename(os.path.dirname(path)),
|
96 |
+
"sound": os.path.basename(os.path.dirname(path)),
|
97 |
+
}
|
98 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
|
100 |
random.shuffle(dataset)
|
101 |
count = len(dataset)
|
|
|
116 |
|
117 |
def _generate_examples(self, files):
|
118 |
for guid, path in enumerate(files):
|
119 |
+
yield guid, {
|
120 |
+
"id": str(guid),
|
121 |
+
"file": path["file"],
|
122 |
+
"audio": path["audio"],
|
123 |
+
"label": path["label"],
|
124 |
+
"sound": path["sound"],
|
125 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|