Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added genre to ballroom datataset loader #629

Merged
merged 11 commits into from
Oct 28, 2024
1 change: 1 addition & 0 deletions docs/source/table.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
- annotations: ✅
- - :ref:`beats`
- :ref:`tempo`
- :ref:`genre`
- 698
- .. image:: https://licensebuttons.net/l/zero/1.0/80x15.png
:target: http://creativecommons.org/publicdomain/zero/1.0/
Expand Down
3 changes: 3 additions & 0 deletions mirdata/datasets/ballroom.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class Track(core.Track):
audio_path (str): path to audio file
beats_path (str): path to beats file
tempo_path (str): path to tempo file
genre (str): genre of the track

Cached Properties:
beats (BeatData): human-labeled beat annotations
Expand Down Expand Up @@ -130,6 +131,8 @@ def __init__(
self.beats_path = self.get_path("beats")
self.tempo_path = self.get_path("tempo")

self.genre = os.path.basename(os.path.dirname(self.audio_path)).lower()

@core.cached_property
def beats(self) -> Optional[annotations.BeatData]:
return load_beats(self.beats_path)
Expand Down
2 changes: 2 additions & 0 deletions tests/datasets/test_ballroom.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ def test_track():
os.path.normpath("tests/resources/mir_datasets/ballroom/"),
"B_1.0/annotations/tempo/Media-105901.bpm",
),
"genre": "waltz",
}

expected_property_types = {
"tempo": float,
"beats": annotations.BeatData,
"audio": tuple,
"genre": str,
}

run_track_tests(track, expected_attributes, expected_property_types)
Expand Down
1 change: 1 addition & 0 deletions tests/test_loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
DATASETS = mirdata.DATASETS
CUSTOM_TEST_TRACKS = {
"beatles": "0111",
"ballroom": "Media-105901",
"cante100": "008",
"compmusic_carnatic_rhythm": "10003",
"compmusic_carnatic_varnam": "dharini_abhogi",
Expand Down
Loading