Datasets:
Size:
10K<n<100K
License:
Add urls of track files
Browse files- mtg_jamendo.py +12 -12
mtg_jamendo.py
CHANGED
@@ -41,21 +41,20 @@ _HOMEPAGE = "https://github.com/MTG/mtg-jamendo-dataset"
|
|
41 |
_LICENSE = "Apache License 2.0"
|
42 |
|
43 |
# The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
|
44 |
-
|
45 |
"train": {
|
46 |
-
"df": "https://huggingface.co/datasets/rkstgr/mtg-jamendo/resolve/main/data/train.tsv",
|
47 |
-
**{
|
48 |
i: f"https://huggingface.co/datasets/rkstgr/mtg-jamendo/resolve/main/data/train/{i}.tar" for i in range(200)
|
49 |
-
}
|
50 |
},
|
51 |
"val": {
|
52 |
-
"df": "https://huggingface.co/datasets/rkstgr/mtg-jamendo/resolve/main/data/valid.tsv",
|
53 |
-
**{
|
54 |
i: f"https://huggingface.co/datasets/rkstgr/mtg-jamendo/resolve/main/data/val/{i}.tar" for i in range(22)
|
55 |
-
}
|
56 |
}
|
57 |
}
|
58 |
|
|
|
|
|
|
|
|
|
|
|
59 |
|
60 |
class MtgJamendo(datasets.GeneratorBasedBuilder):
|
61 |
"""
|
@@ -89,7 +88,8 @@ class MtgJamendo(datasets.GeneratorBasedBuilder):
|
|
89 |
)
|
90 |
|
91 |
def _split_generators(self, dl_manager):
|
92 |
-
archive_path = dl_manager.download(
|
|
|
93 |
|
94 |
# (Optional) In non-streaming mode, we can extract the archive locally to have actual local audio files:
|
95 |
local_extracted_archive = dl_manager.extract(archive_path) if not dl_manager.is_streaming else {}
|
@@ -98,10 +98,10 @@ class MtgJamendo(datasets.GeneratorBasedBuilder):
|
|
98 |
return {x["id"]: x for x in xs}
|
99 |
|
100 |
train_tracks = to_dict(
|
101 |
-
pd.read_csv(
|
102 |
)
|
103 |
valid_tracks = to_dict(
|
104 |
-
pd.read_csv(
|
105 |
)
|
106 |
|
107 |
train_splits = [
|
@@ -147,11 +147,11 @@ class MtgJamendo(datasets.GeneratorBasedBuilder):
|
|
147 |
"instruments": eval(tracks[_id]["instruments"]),
|
148 |
"moods": eval(tracks[_id]["moods"]),
|
149 |
"chunk_nr": tracks[_id]["chunk_nr"],
|
150 |
-
"audio": audio_path
|
151 |
}
|
152 |
yield _id, data
|
153 |
|
154 |
|
155 |
if __name__ == '__main__':
|
156 |
mtg = MtgJamendo()
|
157 |
-
mtg.download_and_prepare()
|
|
|
41 |
_LICENSE = "Apache License 2.0"
|
42 |
|
43 |
# The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
|
44 |
+
_URLS_DATA = {
|
45 |
"train": {
|
|
|
|
|
46 |
i: f"https://huggingface.co/datasets/rkstgr/mtg-jamendo/resolve/main/data/train/{i}.tar" for i in range(200)
|
|
|
47 |
},
|
48 |
"val": {
|
|
|
|
|
49 |
i: f"https://huggingface.co/datasets/rkstgr/mtg-jamendo/resolve/main/data/val/{i}.tar" for i in range(22)
|
|
|
50 |
}
|
51 |
}
|
52 |
|
53 |
+
_URLS_TRACKS = {
|
54 |
+
"train": "https://huggingface.co/datasets/rkstgr/mtg-jamendo/raw/main/train.tsv",
|
55 |
+
"valid": "https://huggingface.co/datasets/rkstgr/mtg-jamendo/raw/main/valid.tsv"
|
56 |
+
}
|
57 |
+
|
58 |
|
59 |
class MtgJamendo(datasets.GeneratorBasedBuilder):
|
60 |
"""
|
|
|
88 |
)
|
89 |
|
90 |
def _split_generators(self, dl_manager):
|
91 |
+
archive_path = dl_manager.download(_URLS_DATA)
|
92 |
+
tracks_path = dl_manager.download(_URLS_TRACKS)
|
93 |
|
94 |
# (Optional) In non-streaming mode, we can extract the archive locally to have actual local audio files:
|
95 |
local_extracted_archive = dl_manager.extract(archive_path) if not dl_manager.is_streaming else {}
|
|
|
98 |
return {x["id"]: x for x in xs}
|
99 |
|
100 |
train_tracks = to_dict(
|
101 |
+
pd.read_csv(tracks_path["train"], sep="\t").to_dict("records")
|
102 |
)
|
103 |
valid_tracks = to_dict(
|
104 |
+
pd.read_csv(tracks_path["valid"], sep="\t").to_dict("records")
|
105 |
)
|
106 |
|
107 |
train_splits = [
|
|
|
147 |
"instruments": eval(tracks[_id]["instruments"]),
|
148 |
"moods": eval(tracks[_id]["moods"]),
|
149 |
"chunk_nr": tracks[_id]["chunk_nr"],
|
150 |
+
"audio": audio_path
|
151 |
}
|
152 |
yield _id, data
|
153 |
|
154 |
|
155 |
if __name__ == '__main__':
|
156 |
mtg = MtgJamendo()
|
157 |
+
mtg.download_and_prepare(ignore_verifications=True)
|