Datasets:
Size:
10K<n<100K
License:
Rename to mtg_jamendo
Browse files- .gitignore +3 -0
- genres.py +252 -0
- mtg_jamendo.py +156 -0
- mtg_jamendo_opus.py +0 -0
.gitignore
CHANGED
@@ -1 +1,4 @@
|
|
1 |
/.idea
|
|
|
|
|
|
|
|
1 |
/.idea
|
2 |
+
/venv/
|
3 |
+
/**/.DS_Store
|
4 |
+
/**/__pycache__
|
genres.py
CHANGED
@@ -0,0 +1,252 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
ABSTRACTHIPHOP = "abstracthiphop"
|
2 |
+
ACID = "acid"
|
3 |
+
ACIDHOUSE = "acidhouse"
|
4 |
+
ACIDJAZZ = "acidjazz"
|
5 |
+
ACIDROCK = "acidrock"
|
6 |
+
ACOUSTICROCK = "acousticrock"
|
7 |
+
AFRICAN = "african"
|
8 |
+
ALTERNATIVE = "alternative"
|
9 |
+
ALTERNATIVEROCK = "alternativerock"
|
10 |
+
AMBIANT = "ambiant"
|
11 |
+
AMBIENT = "ambient"
|
12 |
+
AMBIENTE = "ambiente"
|
13 |
+
AMBIENTMUSIC = "ambientmusic"
|
14 |
+
AMERICANA = "americana"
|
15 |
+
ARTROCK = "artrock"
|
16 |
+
ASIAN = "asian"
|
17 |
+
ATMOSPHERIC = "atmospheric"
|
18 |
+
AVANTGARDE = "avantgarde"
|
19 |
+
BAROQUE = "baroque"
|
20 |
+
BEBOP = "bebop"
|
21 |
+
BLACKMETAL = "blackmetal"
|
22 |
+
BLUES = "blues"
|
23 |
+
BLUESROCK = "bluesrock"
|
24 |
+
BOSSANOVA = "bossanova"
|
25 |
+
BREAKBEAT = "breakbeat"
|
26 |
+
BREAKCORE = "breakcore"
|
27 |
+
BRITPOP = "britpop"
|
28 |
+
CABARET = "cabaret"
|
29 |
+
CELTIC = "celtic"
|
30 |
+
CHANSON = "chanson"
|
31 |
+
CHANSONATEXTE = "chansonatexte"
|
32 |
+
CHANSONFRANCAISE = "chansonfrancaise"
|
33 |
+
CHILLOUT = "chillout"
|
34 |
+
CHILLOUTLOUNGE = "chilloutlounge"
|
35 |
+
CHIPTUNE = "chiptune"
|
36 |
+
CHOIR = "choir"
|
37 |
+
CHORAL = "choral"
|
38 |
+
CHRISTIAN = "christian"
|
39 |
+
CHRISTIANRAP = "christianrap"
|
40 |
+
CLASSICAL = "classical"
|
41 |
+
CLASSICALMUSIC = "classicalmusic"
|
42 |
+
CLASSICROCK = "classicrock"
|
43 |
+
CLUB = "club"
|
44 |
+
COMPUTERMUSIC = "computermusic"
|
45 |
+
CONTEMPORARY = "contemporary"
|
46 |
+
COUNTRY = "country"
|
47 |
+
COUNTRYROCK = "countryrock"
|
48 |
+
DANCE = "dance"
|
49 |
+
DANCEHALL = "dancehall"
|
50 |
+
DANCEHOUSE = "dancehouse"
|
51 |
+
DANCEMUSIC = "dancemusic"
|
52 |
+
DANCEPOP = "dancepop"
|
53 |
+
DARKAMBIENT = "darkambient"
|
54 |
+
DARKELECTRO = "darkelectro"
|
55 |
+
DARKWAVE = "darkwave"
|
56 |
+
DEATH = "death"
|
57 |
+
DEATHMETAL = "deathmetal"
|
58 |
+
DEEPHOUSE = "deephouse"
|
59 |
+
DEUTSCHROCK = "deutschrock"
|
60 |
+
DISCO = "disco"
|
61 |
+
DOOM = "doom"
|
62 |
+
DOWNBEAT = "downbeat"
|
63 |
+
DOWNTEMPO = "downtempo"
|
64 |
+
DREAMPOP = "dreampop"
|
65 |
+
DRONE = "drone"
|
66 |
+
DRONEAMBIENT = "droneambient"
|
67 |
+
DRUMNBASS = "drumnbass"
|
68 |
+
DUB = "dub"
|
69 |
+
DUBELECTRO = "dubelectro"
|
70 |
+
DUBSTEP = "dubstep"
|
71 |
+
EASYLISTENING = "easylistening"
|
72 |
+
EBM = "ebm"
|
73 |
+
EDM = "edm"
|
74 |
+
ELECTROAMBIENT = "electroambient"
|
75 |
+
ELECTRODANCE = "electrodance"
|
76 |
+
ELECTROHOUSE = "electrohouse"
|
77 |
+
ELECTROJAZZ = "electrojazz"
|
78 |
+
ELECTRONIC = "electronic"
|
79 |
+
ELECTRONICAL = "electronical"
|
80 |
+
ELECTRONICAMBIENT = "electronicambient"
|
81 |
+
ELECTRONICMUSIC = "electronicmusic"
|
82 |
+
ELECTRONIK = "electronik"
|
83 |
+
ELECTRONIKA = "electronika"
|
84 |
+
ELECTROPOP = "electropop"
|
85 |
+
ELECTROPUNK = "electropunk"
|
86 |
+
ELECTROROCK = "electrorock"
|
87 |
+
ELEKTRO = "elektro"
|
88 |
+
ELETRONICA = "eletronica"
|
89 |
+
EMO = "emo"
|
90 |
+
EMOCORE = "emocore"
|
91 |
+
ETHNICROCK = "ethnicrock"
|
92 |
+
ETHNO = "ethno"
|
93 |
+
EURODANCE = "eurodance"
|
94 |
+
EXPERIMENTAL = "experimental"
|
95 |
+
EXPERIMENTALROCK = "experimentalrock"
|
96 |
+
FLAMENCO = "flamenco"
|
97 |
+
FOLK = "folk"
|
98 |
+
FOLKPOP = "folkpop"
|
99 |
+
FREEJAZZ = "freejazz"
|
100 |
+
FUNK = "funk"
|
101 |
+
FUSION = "fusion"
|
102 |
+
GANGSTA = "gangsta"
|
103 |
+
GANGSTARAP = "gangstarap"
|
104 |
+
GARAGE = "garage"
|
105 |
+
GIPSY = "gipsy"
|
106 |
+
GLAM = "glam"
|
107 |
+
GLITCH = "glitch"
|
108 |
+
GOSPEL = "gospel"
|
109 |
+
GOTH = "goth"
|
110 |
+
GOTHIC = "gothic"
|
111 |
+
GRINDCORE = "grindcore"
|
112 |
+
GROOVE = "groove"
|
113 |
+
GRUNGE = "grunge"
|
114 |
+
GUITARRAS = "guitarras"
|
115 |
+
GUITARROCK = "guitarrock"
|
116 |
+
HARD = "hard"
|
117 |
+
HARDCORE = "hardcore"
|
118 |
+
HARDROCK = "hardrock"
|
119 |
+
HARDSTYLE = "hardstyle"
|
120 |
+
HARDTEK = "hardtek"
|
121 |
+
HARDTRANCE = "hardtrance"
|
122 |
+
HEAVYMETAL = "heavymetal"
|
123 |
+
HIPHOP = "hiphop"
|
124 |
+
HIPHOPINSTRUMENTAL = "hiphopinstrumental"
|
125 |
+
HOUSE = "house"
|
126 |
+
HOUSEELECTRO = "houseelectro"
|
127 |
+
HOUSEMUSIC = "housemusic"
|
128 |
+
IDM = "idm"
|
129 |
+
IMPROVISATION = "improvisation"
|
130 |
+
INDIE = "indie"
|
131 |
+
INDIEPOP = "indiepop"
|
132 |
+
INDIEROCK = "indierock"
|
133 |
+
INDIEROCKPOP = "indierockpop"
|
134 |
+
INDIETRONICA = "indietronica"
|
135 |
+
INDUSTRIAL = "industrial"
|
136 |
+
INSTRUMENTALHIPHOP = "instrumentalhiphop"
|
137 |
+
INSTRUMENTALPOP = "instrumentalpop"
|
138 |
+
INSTRUMENTALROCK = "instrumentalrock"
|
139 |
+
ISLAND = "island"
|
140 |
+
JAZZ = "jazz"
|
141 |
+
JAZZFUNK = "jazzfunk"
|
142 |
+
JAZZFUSION = "jazzfusion"
|
143 |
+
JAZZROCK = "jazzrock"
|
144 |
+
JROCK = "jrock"
|
145 |
+
JUNGLE = "jungle"
|
146 |
+
KRAUTROCK = "krautrock"
|
147 |
+
LATIN = "latin"
|
148 |
+
LATINO = "latino"
|
149 |
+
LOFI = "lofi"
|
150 |
+
LOUNGE = "lounge"
|
151 |
+
LOUNGEMUSIC = "loungemusic"
|
152 |
+
MANOUCHE = "manouche"
|
153 |
+
MARCH = "march"
|
154 |
+
MEDIEVAL = "medieval"
|
155 |
+
METAL = "metal"
|
156 |
+
METALCORE = "metalcore"
|
157 |
+
MIDDLEEASTERN = "middleeastern"
|
158 |
+
MINIMAL = "minimal"
|
159 |
+
MINIMALISM = "minimalism"
|
160 |
+
MINIMALTECHNO = "minimaltechno"
|
161 |
+
NEOCLASSICAL = "neoclassical"
|
162 |
+
NEWAGE = "newage"
|
163 |
+
NEWWAVE = "newwave"
|
164 |
+
NOISE = "noise"
|
165 |
+
NUJAZZ = "nujazz"
|
166 |
+
NUMETAL = "numetal"
|
167 |
+
OPERA = "opera"
|
168 |
+
ORCHESTRAL = "orchestral"
|
169 |
+
ORIENTAL = "oriental"
|
170 |
+
POP = "pop"
|
171 |
+
POPELECTRO = "popelectro"
|
172 |
+
POPFOLK = "popfolk"
|
173 |
+
POPFUNK = "popfunk"
|
174 |
+
POPPUNK = "poppunk"
|
175 |
+
POPROCK = "poprock"
|
176 |
+
POSTPUNK = "postpunk"
|
177 |
+
POSTROCK = "postrock"
|
178 |
+
POWERMETAL = "powermetal"
|
179 |
+
POWERPOP = "powerpop"
|
180 |
+
PROG = "prog"
|
181 |
+
PROGRESSIVE = "progressive"
|
182 |
+
PROGRESSIVEHOUSE = "progressivehouse"
|
183 |
+
PROGRESSIVEMETAL = "progressivemetal"
|
184 |
+
PROGRESSIVEROCK = "progressiverock"
|
185 |
+
PSYCHEDELIC = "psychedelic"
|
186 |
+
PSYTRANCE = "psytrance"
|
187 |
+
PUNK = "punk"
|
188 |
+
PUNKROCK = "punkrock"
|
189 |
+
RAGGA = "ragga"
|
190 |
+
RAGTIME = "ragtime"
|
191 |
+
RAP = "rap"
|
192 |
+
RAPCORE = "rapcore"
|
193 |
+
RAPFRANCAIS = "rapfrancais"
|
194 |
+
RAPS = "raps"
|
195 |
+
RAVE = "rave"
|
196 |
+
REGGAE = "reggae"
|
197 |
+
REGGAETON = "reggaeton"
|
198 |
+
RHYTHMANDBLUES = "rhythmandblues"
|
199 |
+
RNB = "rnb"
|
200 |
+
ROCK = "rock"
|
201 |
+
ROCKALTERNATIF = "rockalternatif"
|
202 |
+
ROCKANDROLL = "rockandroll"
|
203 |
+
ROCKFRANCAIS = "rockfrancais"
|
204 |
+
ROCKNROLL = "rocknroll"
|
205 |
+
ROCKPOP = "rockpop"
|
206 |
+
ROCKSTEADY = "rocksteady"
|
207 |
+
SALSA = "salsa"
|
208 |
+
SAMBA = "samba"
|
209 |
+
SCORE = "score"
|
210 |
+
SHOEGAZE = "shoegaze"
|
211 |
+
SINGERSONGWRITER = "singersongwriter"
|
212 |
+
SKA = "ska"
|
213 |
+
SMOOTHJAZZ = "smoothjazz"
|
214 |
+
SOUL = "soul"
|
215 |
+
SOULJAZZ = "souljazz"
|
216 |
+
SOUNDSCAPES = "soundscapes"
|
217 |
+
SOUNDTRACK = "soundtrack"
|
218 |
+
SOUNDTRACKS = "soundtracks"
|
219 |
+
SOUTHERNROCK = "southernrock"
|
220 |
+
SPACEROCK = "spacerock"
|
221 |
+
STONER = "stoner"
|
222 |
+
SWING = "swing"
|
223 |
+
SYMPHONIC = "symphonic"
|
224 |
+
SYNTHPOP = "synthpop"
|
225 |
+
SYNTHWAVE = "synthwave"
|
226 |
+
TANGO = "tango"
|
227 |
+
TECHHOUSE = "techhouse"
|
228 |
+
TECHNO = "techno"
|
229 |
+
TECHNOHOUSE = "technohouse"
|
230 |
+
TECHNOINDUSTRIAL = "technoindustrial"
|
231 |
+
TECHNOPOP = "technopop"
|
232 |
+
TECNO = "tecno"
|
233 |
+
TEKNO = "tekno"
|
234 |
+
THRASHMETAL = "thrashmetal"
|
235 |
+
TRANCE = "trance"
|
236 |
+
TRANCEMELODIQUE = "trancemelodique"
|
237 |
+
TRANCEMUSIC = "trancemusic"
|
238 |
+
TRANCETECHNO = "trancetechno"
|
239 |
+
TRAP = "trap"
|
240 |
+
TRIBAL = "tribal"
|
241 |
+
TRIP = "trip"
|
242 |
+
TRIPHOP = "triphop"
|
243 |
+
VARIETE = "variete"
|
244 |
+
WALTZ = "waltz"
|
245 |
+
WORLD = "world"
|
246 |
+
WORLDFUSION = "worldfusion"
|
247 |
+
WORLDMUSIK = "worldmusik"
|
248 |
+
_60S = "60s"
|
249 |
+
_70S = "70s"
|
250 |
+
_80S = "80s"
|
251 |
+
_8BIT = "8bit"
|
252 |
+
_90S = "90s"
|
mtg_jamendo.py
ADDED
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
2 |
+
#
|
3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
+
# you may not use this file except in compliance with the License.
|
5 |
+
# You may obtain a copy of the License at
|
6 |
+
#
|
7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
+
#
|
9 |
+
# Unless required by applicable law or agreed to in writing, software
|
10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
+
# See the License for the specific language governing permissions and
|
13 |
+
# limitations under the License.
|
14 |
+
|
15 |
+
import csv
|
16 |
+
import json
|
17 |
+
import os
|
18 |
+
from pathlib import Path
|
19 |
+
|
20 |
+
import pandas as pd
|
21 |
+
|
22 |
+
import genres
|
23 |
+
import datasets
|
24 |
+
|
25 |
+
# Find for instance the citation on arxiv or on the dataset repo/website
|
26 |
+
_CITATION = """
|
27 |
+
@conference {bogdanov2019mtg,
|
28 |
+
author = "Bogdanov, Dmitry and Won, Minz and Tovstogan, Philip and Porter, Alastair and Serra, Xavier",
|
29 |
+
title = "The MTG-Jamendo Dataset for Automatic Music Tagging",
|
30 |
+
booktitle = "Machine Learning for Music Discovery Workshop, International Conference on Machine Learning (ICML 2019)",
|
31 |
+
year = "2019",
|
32 |
+
address = "Long Beach, CA, United States",
|
33 |
+
url = "http://hdl.handle.net/10230/42015"
|
34 |
+
}
|
35 |
+
"""
|
36 |
+
|
37 |
+
_DESCRIPTION = """
|
38 |
+
Repackaging of the MTG Jamendo dataset.
|
39 |
+
|
40 |
+
We present the MTG-Jamendo Dataset, a new open dataset for music auto-tagging.
|
41 |
+
It is built using music available at Jamendo under Creative Commons licenses and tags provided by content creators.
|
42 |
+
The dataset contains over 55,000 full audio tracks with 195 tags from genre, instrument, and mood/theme categories.
|
43 |
+
"""
|
44 |
+
|
45 |
+
_HOMEPAGE = "https://github.com/MTG/mtg-jamendo-dataset"
|
46 |
+
_LICENSE = "Apache License 2.0"
|
47 |
+
|
48 |
+
# The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
|
49 |
+
_URLS = {
|
50 |
+
"train": {
|
51 |
+
i: f"https://huggingface.co/datasets/rkstgr/mtg-jamendo/resolve/main/data/train/{i}.tar" for i in range(200)
|
52 |
+
},
|
53 |
+
"val": {
|
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 |
+
class MtgJamendo(datasets.GeneratorBasedBuilder):
|
60 |
+
"""
|
61 |
+
Audio dataset containing over 55,000 full audio tracks with
|
62 |
+
195 tags from genre, instrument, and mood/theme categories
|
63 |
+
"""
|
64 |
+
|
65 |
+
VERSION = datasets.Version("1.1.0")
|
66 |
+
|
67 |
+
def _info(self):
|
68 |
+
features = datasets.Features(
|
69 |
+
{
|
70 |
+
"id": datasets.Value("int32"),
|
71 |
+
"artist_id": datasets.Value("int32"),
|
72 |
+
"album_id": datasets.Value("int32"),
|
73 |
+
"durationInSec": datasets.Value("float"),
|
74 |
+
"genres": datasets.Sequence(datasets.Value("string")),
|
75 |
+
"instruments": datasets.Sequence(datasets.Value("string")),
|
76 |
+
"moods": datasets.Sequence(datasets.Value("string")),
|
77 |
+
"chunk_nr": datasets.Value("int32"),
|
78 |
+
"audio": datasets.Audio(sampling_rate=22_050),
|
79 |
+
}
|
80 |
+
)
|
81 |
+
|
82 |
+
return datasets.DatasetInfo(
|
83 |
+
description=_DESCRIPTION,
|
84 |
+
features=features,
|
85 |
+
homepage=_HOMEPAGE,
|
86 |
+
license=_LICENSE,
|
87 |
+
citation=_CITATION,
|
88 |
+
)
|
89 |
+
|
90 |
+
def _split_generators(self, dl_manager):
|
91 |
+
archive_path = dl_manager.download(_URLS)
|
92 |
+
|
93 |
+
# (Optional) In non-streaming mode, we can extract the archive locally to have actual local audio files:
|
94 |
+
local_extracted_archive = dl_manager.extract(archive_path) if not dl_manager.is_streaming else {}
|
95 |
+
|
96 |
+
def to_dict(xs: list) -> dict:
|
97 |
+
return {x["id"]: x for x in xs}
|
98 |
+
|
99 |
+
train_tracks = to_dict(
|
100 |
+
pd.read_csv(Path(__file__).parent / "train.tsv", sep="\t").to_dict("records")
|
101 |
+
)
|
102 |
+
valid_tracks = to_dict(
|
103 |
+
pd.read_csv(Path(__file__).parent / "valid.tsv", sep="\t").to_dict("records")
|
104 |
+
)
|
105 |
+
|
106 |
+
train_splits = [
|
107 |
+
datasets.SplitGenerator(
|
108 |
+
name=datasets.Split.TRAIN,
|
109 |
+
gen_kwargs={
|
110 |
+
"local_extracted_archive": local_extracted_archive.get("train"),
|
111 |
+
"files": dl_manager.iter_archive(archive_path["train"]),
|
112 |
+
"tracks": train_tracks,
|
113 |
+
},
|
114 |
+
)
|
115 |
+
]
|
116 |
+
val_splits = [
|
117 |
+
datasets.SplitGenerator(
|
118 |
+
name=datasets.Split.VALIDATION,
|
119 |
+
gen_kwargs={
|
120 |
+
"local_extracted_archive": local_extracted_archive.get("val"),
|
121 |
+
"files": dl_manager.iter_archive(archive_path["val"]),
|
122 |
+
"tracks": valid_tracks,
|
123 |
+
},
|
124 |
+
)
|
125 |
+
]
|
126 |
+
|
127 |
+
return train_splits + val_splits
|
128 |
+
|
129 |
+
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
130 |
+
def _generate_examples(self, files, local_extracted_archive, tracks):
|
131 |
+
"""Generate examples from archive_path."""
|
132 |
+
audio_paths = {}
|
133 |
+
for _, directory in local_extracted_archive.items():
|
134 |
+
for f in Path(directory).iterdir():
|
135 |
+
if f.suffix == ".opus":
|
136 |
+
_id = int(f.stem)
|
137 |
+
audio_paths[_id] = str(f)
|
138 |
+
|
139 |
+
for _id, audio_path in audio_paths.items():
|
140 |
+
data = {
|
141 |
+
"id": _id,
|
142 |
+
"artist_id": tracks[_id]["artist_id"],
|
143 |
+
"album_id": tracks[_id]["album_id"],
|
144 |
+
"durationInSec": tracks[_id]["durationInSec"],
|
145 |
+
"genres": eval(tracks[_id]["genres"]),
|
146 |
+
"instruments": eval(tracks[_id]["instruments"]),
|
147 |
+
"moods": eval(tracks[_id]["moods"]),
|
148 |
+
"chunk_nr": tracks[_id]["chunk_nr"],
|
149 |
+
"audio": audio_path,
|
150 |
+
}
|
151 |
+
yield _id, data
|
152 |
+
|
153 |
+
|
154 |
+
if __name__ == '__main__':
|
155 |
+
mtg = MtgJamendo()
|
156 |
+
mtg.download_and_prepare()
|
mtg_jamendo_opus.py
DELETED
File without changes
|