danilotpnta
commited on
Commit
·
8dfc1d1
1
Parent(s):
30362fd
update
Browse files
GTZAN_genre_classification.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
import os
|
2 |
import csv
|
3 |
import datasets
|
4 |
-
import librosa
|
5 |
|
6 |
logger = datasets.logging.get_logger(__name__)
|
7 |
|
@@ -46,7 +45,6 @@ class GTZAN(datasets.GeneratorBasedBuilder):
|
|
46 |
"tempo": datasets.Value("float"),
|
47 |
"keys": datasets.Value("string"),
|
48 |
"loudness": datasets.Value("float"),
|
49 |
-
"embeddings": datasets.Value("string"),
|
50 |
"sorted_pred_genres": datasets.Value("string"),
|
51 |
"x_tsne": datasets.Value("float"),
|
52 |
"y_tsne": datasets.Value("float"),
|
@@ -57,10 +55,9 @@ class GTZAN(datasets.GeneratorBasedBuilder):
|
|
57 |
"album_cover_path": datasets.Value("string"),
|
58 |
"key": datasets.Value("string"),
|
59 |
"filepath": datasets.Value("string"),
|
60 |
-
"audio": datasets.Audio(sampling_rate=44100),
|
61 |
}
|
62 |
),
|
63 |
-
supervised_keys=("
|
64 |
homepage=_HOMEPAGE_URL,
|
65 |
citation=_CITATION,
|
66 |
)
|
@@ -96,13 +93,6 @@ class GTZAN(datasets.GeneratorBasedBuilder):
|
|
96 |
if not os.path.exists(file_path):
|
97 |
logger.error(f"File not found: {file_path}")
|
98 |
|
99 |
-
# Use librosa to load the audio file
|
100 |
-
try:
|
101 |
-
audio, sr = librosa.load(file_path, sr=44100)
|
102 |
-
except Exception as e:
|
103 |
-
logger.error(f"Error loading audio file {file_path}: {e}")
|
104 |
-
continue
|
105 |
-
|
106 |
yield id_, {
|
107 |
"id": int(row["id"]),
|
108 |
"genre": row["genre"],
|
@@ -111,7 +101,6 @@ class GTZAN(datasets.GeneratorBasedBuilder):
|
|
111 |
"tempo": float(row["tempo"]),
|
112 |
"keys": row["keys"],
|
113 |
"loudness": float(row["loudness"]),
|
114 |
-
"embeddings": row["embeddings"],
|
115 |
"sorted_pred_genres": row["sorted_pred_genres"],
|
116 |
"x_tsne": float(row["x_tsne"]),
|
117 |
"y_tsne": float(row["y_tsne"]),
|
@@ -122,8 +111,4 @@ class GTZAN(datasets.GeneratorBasedBuilder):
|
|
122 |
"album_cover_path": album_cover_path,
|
123 |
"key": row["key"],
|
124 |
"filepath": file_path,
|
125 |
-
"audio": {
|
126 |
-
"array": audio,
|
127 |
-
"sampling_rate": sr,
|
128 |
-
},
|
129 |
}
|
|
|
1 |
import os
|
2 |
import csv
|
3 |
import datasets
|
|
|
4 |
|
5 |
logger = datasets.logging.get_logger(__name__)
|
6 |
|
|
|
45 |
"tempo": datasets.Value("float"),
|
46 |
"keys": datasets.Value("string"),
|
47 |
"loudness": datasets.Value("float"),
|
|
|
48 |
"sorted_pred_genres": datasets.Value("string"),
|
49 |
"x_tsne": datasets.Value("float"),
|
50 |
"y_tsne": datasets.Value("float"),
|
|
|
55 |
"album_cover_path": datasets.Value("string"),
|
56 |
"key": datasets.Value("string"),
|
57 |
"filepath": datasets.Value("string"),
|
|
|
58 |
}
|
59 |
),
|
60 |
+
supervised_keys=("genre", "title"),
|
61 |
homepage=_HOMEPAGE_URL,
|
62 |
citation=_CITATION,
|
63 |
)
|
|
|
93 |
if not os.path.exists(file_path):
|
94 |
logger.error(f"File not found: {file_path}")
|
95 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
yield id_, {
|
97 |
"id": int(row["id"]),
|
98 |
"genre": row["genre"],
|
|
|
101 |
"tempo": float(row["tempo"]),
|
102 |
"keys": row["keys"],
|
103 |
"loudness": float(row["loudness"]),
|
|
|
104 |
"sorted_pred_genres": row["sorted_pred_genres"],
|
105 |
"x_tsne": float(row["x_tsne"]),
|
106 |
"y_tsne": float(row["y_tsne"]),
|
|
|
111 |
"album_cover_path": album_cover_path,
|
112 |
"key": row["key"],
|
113 |
"filepath": file_path,
|
|
|
|
|
|
|
|
|
114 |
}
|