Datasets:

Modalities:
Audio
Text
Size:
< 1K
ArXiv:
Libraries:
Datasets
License:
File size: 3,344 Bytes
c4115a4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
89
90
91
92
93
94
95
96
97
98
99
100
import os
import json
import numpy as np
import datasets
from datasets import Features, Value, Audio, Array2D, Sequence
from pathlib import Path
import librosa

_CITATION = """\
comming soon.
"""

_DESCRIPTION = """\
SongFormBench is a high-quality benchmark dataset for song structure analysis, consisting of 200 songs from HarmonixSet and 100 Chinese pop songs, aimed at establishing a unified evaluation standard in the MSA field, advancing the task, and addressing the lack of Chinese data.
"""

_HOMEPAGE = "https://huggingface.co/datasets/ASLP-lab/SongFormBench"
_LICENSE = "cc-by-4.0"


class SongFormBench(datasets.GeneratorBasedBuilder):
    """SongFormBench: A Benchmark for Song Structure Analysis (only test split)."""

    BUILDER_CONFIGS = [
        datasets.BuilderConfig(
            name="default",
            version=datasets.Version("1.0.0"),
            description="MSA Benchmark Test Set",
        ),
    ]

    DEFAULT_CONFIG_NAME = "default"

    def _info(self):
        features = Features(
            {
                "id": Value("string"),
                "youtube_url": Value("string"),
                "subset": Value("string"),
                "language": Value("string"),
                "audio": Audio(),
                "mel_path": Value("string"),
                "label_path": Value("string"),
                "labels": {
                    "segments": Sequence(
                        {
                            "start": Value("float32"),
                            "label": Value("string"),
                        }
                    ),
                },
            }
        )

        return datasets.DatasetInfo(
            description=_DESCRIPTION,
            features=features,
            citation=_CITATION,
            license=_LICENSE,
            homepage=_HOMEPAGE,
        )

    def _split_generators(self, dl_manager):
        test_path = os.path.join(dl_manager.manual_dir, "data/SongFormBench.jsonl")
        self.root_dir = dl_manager.manual_dir  # 保存根目录以供后续使用

        with open(test_path, "r", encoding="utf-8") as f:
            items = [json.loads(line) for line in f]

        self.items = items  # 将数据存储为实例变量,供 _generate_examples 使用

        return [
            datasets.SplitGenerator(
                name=datasets.Split.TEST,
                gen_kwargs={"items": self.items},  # 将数据传递给生成器
            ),
        ]

    def _generate_examples(self, items):
        """从内存数据生成样本"""
        for entry in items:
            raw_labels = entry.get("labels", [])
            yield (
                entry["id"],
                {
                    "id": entry["id"],
                    "youtube_url": entry.get("youtube_url", ""),
                    "subset": entry.get("subset", ""),
                    "language": entry.get("language", ""),
                    "audio": str(Path(self.root_dir) / entry["audio_path"]),
                    "mel_path": str(Path(self.root_dir) / entry.get("mel_path", "")),
                    "label_path": str(
                        Path(self.root_dir) / entry.get("label_path", "")
                    ),
                    "labels": {
                        "segments": raw_labels,
                    },
                },
            )