Datasets:
Tasks:
Audio Classification
Modalities:
Audio
Languages:
English
Tags:
audio
music-classification
meter-classification
multi-class-classification
multi-label-classification
License:
File size: 3,632 Bytes
bb7db63 442eaea 3df2755 442eaea 5e05c06 442eaea 5772aad 442eaea bb7db63 5e05c06 442eaea 5772aad 442eaea 5772aad 442eaea 3df2755 5772aad 3df2755 ec015f3 3df2755 5772aad 3df2755 442eaea 3df2755 5772aad 3df2755 442eaea 3df2755 bb7db63 5e05c06 5772aad bb7db63 5e05c06 bb7db63 5772aad 3df2755 bb7db63 3df2755 5772aad 3df2755 bb7db63 3df2755 5a6497d bb7db63 de731d3 442eaea |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# meter2800.py
from pathlib import Path
import datasets
import pandas as pd
_CITATION = """\
@misc{meter2800_dataset,
author = {PianistProgrammer},
title = {{Meter2800}: A Dataset for Music Time signature detection / Meter Classification},
year = {2025},
publisher = {Hugging Face},
url = {https://huggingface.co/datasets/pianistprogrammer/meter2800}
}
"""
_DESCRIPTION = """\
Meter2800 is a dataset of 2,800 music audio samples for automatic meter classification.
Each audio file is annotated with a primary meter class label and an alternative meter.
It is split into training, validation, and test sets, each available in two class configurations:
2-class and 4-class. All audio is 16-bit WAV format.
"""
_HOMEPAGE = "https://huggingface.co/datasets/pianistprogrammer/meter2800"
_LICENSE = "mit"
LABELS_4 = ["three", "four", "five", "seven"]
LABELS_2 = ["three", "four"]
class Meter2800Config(datasets.BuilderConfig):
def __init__(self, name, **kwargs):
super().__init__(name=name, version=datasets.Version("1.0.0"), **kwargs)
class Meter2800(datasets.GeneratorBasedBuilder):
BUILDER_CONFIGS = [
Meter2800Config(name="4_classes", description="4‑class meter classification"),
Meter2800Config(name="2_classes", description="2‑class meter classification"),
]
DEFAULT_CONFIG_NAME = "4_classes"
def _info(self):
labels = LABELS_4 if self.config.name == "4_classes" else LABELS_2
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=datasets.Features({
"filename": datasets.Value("string"),
"audio": datasets.Audio(sampling_rate=22050),
"label": datasets.ClassLabel(names=labels),
"meter": datasets.Value("string"),
"alt_meter": datasets.Value("string"),
}),
supervised_keys=("audio", "label"),
homepage=_HOMEPAGE,
license=_LICENSE,
citation=_CITATION,
)
def _split_generators(self, dl_manager):
csv_links = {
split: f"https://huggingface.co/datasets/pianistprogrammer/meter2800/resolve/main/data_{split}_{self.config.name}.csv"
for split in ["train", "val", "test"]
}
csv_files = dl_manager.download(csv_links)
archive = dl_manager.download_and_extract(
"https://huggingface.co/datasets/pianistprogrammer/meter2800/resolve/main/data.tar.gz"
)
return [
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"csv_path": csv_files["train"], "root": archive}),
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"csv_path": csv_files["val"], "root": archive}),
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"csv_path": csv_files["test"], "root": archive}),
]
def _generate_examples(self, csv_path, root):
df = pd.read_csv(csv_path).dropna(subset=["filename", "label", "meter"]).reset_index(drop=True)
for idx, row in df.iterrows():
rel = row["filename"].lstrip("/") # ensure relative path, not absolute
audio_path = Path(root) / rel
if not audio_path.is_file():
raise FileNotFoundError(f"Missing audio file: {audio_path}")
yield idx, {
"filename": rel,
"audio": str(audio_path),
"label": row["label"],
"meter": str(row["meter"]),
"alt_meter": str(row.get("alt_meter", row["meter"])),
}
|