admin
commited on
Commit
•
f54b245
1
Parent(s):
b4c9293
add sscript
Browse files- README.md +143 -1
- song_structure.py +117 -0
README.md
CHANGED
@@ -1,3 +1,145 @@
|
|
1 |
---
|
2 |
-
license:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
license: cc-by-nc-nd-4.0
|
3 |
+
task_categories:
|
4 |
+
- time-series-forecasting
|
5 |
+
language:
|
6 |
+
- en
|
7 |
+
tags:
|
8 |
+
- music
|
9 |
+
- art
|
10 |
+
pretty_name: Song Structure Annotation Database
|
11 |
+
size_categories:
|
12 |
+
- n<1K
|
13 |
+
viewer: false
|
14 |
---
|
15 |
+
|
16 |
+
# Dataset Card for Song Structure
|
17 |
+
The raw dataset comprises 300 pop songs in .mp3 format, sourced from the NetEase music, accompanied by a structure annotation file for each song in .txt format. The annotator for music structure is a professional musician and teacher from the China Conservatory of Music. For the statistics of the dataset, there are 208 Chinese songs, 87 English songs, three Korean songs and two Japanese songs. The song structures are labeled as follows: intro, re-intro, verse, chorus, pre-chorus, post-chorus, bridge, interlude and ending. Fig. 7 shows the frequency of each segment label that appears in the set. The labels chorus and verse are the two most prevalent segment labels in the dataset and they are the most common segment in Western popular music. Among them, the number of “Postchorus” tags is the least, with only two present.
|
18 |
+
|
19 |
+
## Viewer
|
20 |
+
<https://www.modelscope.cn/datasets/ccmusic-database/song_structure/dataPeview>
|
21 |
+
|
22 |
+
## Dataset Structure
|
23 |
+
<style>
|
24 |
+
.datastructure td {
|
25 |
+
vertical-align: middle !important;
|
26 |
+
text-align: center;
|
27 |
+
}
|
28 |
+
.datastructure th {
|
29 |
+
text-align: center;
|
30 |
+
}
|
31 |
+
</style>
|
32 |
+
<table class="datastructure">
|
33 |
+
<tr>
|
34 |
+
<th>audio(.mp3, 22050Hz)</th>
|
35 |
+
<th>mel(.jpg, 22050Hz)</th>
|
36 |
+
<th>label</th>
|
37 |
+
</tr>
|
38 |
+
<tr>
|
39 |
+
<td><audio controls src="https://huggingface.co/datasets/ccmusic-database/song_structure/resolve/main/data/Pentatonix%20-%20Valentine.mp3"></td>
|
40 |
+
<td><img src="./data/Pentatonix - Valentine.jpg"></td>
|
41 |
+
<td>{onset_time:uint32,offset_time:uint32,structure:string}</td>
|
42 |
+
</tr>
|
43 |
+
<tr>
|
44 |
+
<td>...</td>
|
45 |
+
<td>...</td>
|
46 |
+
<td>...</td>
|
47 |
+
</tr>
|
48 |
+
</table>
|
49 |
+
|
50 |
+
## Maintenance
|
51 |
+
```bash
|
52 |
+
GIT_LFS_SKIP_SMUDGE=1 git clone git@hf.co:datasets/ccmusic-database/song_structure
|
53 |
+
cd song_structure
|
54 |
+
```
|
55 |
+
|
56 |
+
### Data Instances
|
57 |
+
.zip(.mp3), .txt
|
58 |
+
|
59 |
+
### Data Fields
|
60 |
+
```txt
|
61 |
+
intro, chorus, verse, pre-chorus, post-chorus, bridge, ending
|
62 |
+
```
|
63 |
+
<img src="https://www.modelscope.cn/api/v1/datasets/ccmusic-database/song_structure/repo?Revision=master&FilePath=.%2Fdata%2Fmsa.png&View=true">
|
64 |
+
|
65 |
+
### Data Splits
|
66 |
+
train
|
67 |
+
|
68 |
+
## Dataset Description
|
69 |
+
- **Homepage:** <https://ccmusic-database.github.io>
|
70 |
+
- **Repository:** <https://huggingface.co/datasets/ccmusic-database/song_structure>
|
71 |
+
- **Paper:** <https://doi.org/10.5281/zenodo.5676893>
|
72 |
+
- **Leaderboard:** <https://ccmusic-database.github.io/team.html>
|
73 |
+
- **Point of Contact:** <https://www.modelscope.cn/datasets/ccmusic-database/song_structure>
|
74 |
+
|
75 |
+
### Dataset Summary
|
76 |
+
Unlike the above three datasets for classification, this one has not undergone pre-processing such as spectrogram transform. Thus we provide the original content only. The integrated version of the dataset is organized based on audio files, with each item structured into three columns: The first column contains the audio of the song in .mp3 format, sampled at 22,050 Hz. The second column consists of lists indicating the time points that mark the boundaries of different song sections, while the third column contains lists corresponding to the labels of the song structures listed in the second column. Strictly speaking, the first column represents the data, while the subsequent two columns represent the label.
|
77 |
+
|
78 |
+
### Supported Tasks and Leaderboards
|
79 |
+
time-series-forecasting
|
80 |
+
|
81 |
+
### Languages
|
82 |
+
Chinese, English
|
83 |
+
|
84 |
+
## Usage
|
85 |
+
```python
|
86 |
+
from datasets import load_dataset
|
87 |
+
|
88 |
+
dataset = load_dataset("ccmusic-database/song_structure", split="train")
|
89 |
+
for item in ds:
|
90 |
+
print(item)
|
91 |
+
```
|
92 |
+
|
93 |
+
## Dataset Creation
|
94 |
+
### Curation Rationale
|
95 |
+
Lack of a dataset for song structure
|
96 |
+
|
97 |
+
### Source Data
|
98 |
+
#### Initial Data Collection and Normalization
|
99 |
+
Zhaorui Liu, Monan Zhou
|
100 |
+
|
101 |
+
#### Who are the source language producers?
|
102 |
+
Students from CCMUSIC
|
103 |
+
|
104 |
+
### Annotations
|
105 |
+
#### Annotation process
|
106 |
+
Students from CCMUSIC collected 300 pop songs, as well as a structure annotation file for each song
|
107 |
+
|
108 |
+
#### Who are the annotators?
|
109 |
+
Students from CCMUSIC
|
110 |
+
|
111 |
+
### Personal and Sensitive Information
|
112 |
+
Due to copyright issues with the original music, only features of audio by frame are provided in the dataset
|
113 |
+
|
114 |
+
## Considerations for Using the Data
|
115 |
+
### Social Impact of Dataset
|
116 |
+
Promoting the development of the AI music industry
|
117 |
+
|
118 |
+
### Discussion of Biases
|
119 |
+
Only for mp3
|
120 |
+
|
121 |
+
### Other Known Limitations
|
122 |
+
Most are Chinese songs
|
123 |
+
|
124 |
+
## Additional Information
|
125 |
+
### Dataset Curators
|
126 |
+
Zijin Li
|
127 |
+
|
128 |
+
### Evaluation
|
129 |
+
<https://www.modelscope.cn/models/ccmusic-database/song_structure>
|
130 |
+
|
131 |
+
### Citation Information
|
132 |
+
```bibtex
|
133 |
+
@dataset{zhaorui_liu_2021_5676893,
|
134 |
+
author = {Monan Zhou, Shenyang Xu, Zhaorui Liu, Zhaowen Wang, Feng Yu, Wei Li and Baoqiang Han},
|
135 |
+
title = {CCMusic: an Open and Diverse Database for Chinese and General Music Information Retrieval Research},
|
136 |
+
month = {mar},
|
137 |
+
year = {2024},
|
138 |
+
publisher = {HuggingFace},
|
139 |
+
version = {1.2},
|
140 |
+
url = {https://huggingface.co/ccmusic-database}
|
141 |
+
}
|
142 |
+
```
|
143 |
+
|
144 |
+
### Contributions
|
145 |
+
Provide a dataset for song structure
|
song_structure.py
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import csv
|
3 |
+
import random
|
4 |
+
import hashlib
|
5 |
+
import datasets
|
6 |
+
|
7 |
+
_DBNAME = os.path.basename(__file__).split(".")[0]
|
8 |
+
|
9 |
+
_HOMEPAGE = f"https://www.modelscope.cn/datasets/ccmusic-database/{_DBNAME}"
|
10 |
+
|
11 |
+
_DOMAIN = f"https://www.modelscope.cn/api/v1/datasets/ccmusic-database/{_DBNAME}/repo?Revision=master&FilePath=data"
|
12 |
+
|
13 |
+
_CITATION = """\
|
14 |
+
@dataset{zhaorui_liu_2021_5676893,
|
15 |
+
author = {Monan Zhou, Shenyang Xu, Zhaorui Liu, Zhaowen Wang, Feng Yu, Wei Li and Baoqiang Han},
|
16 |
+
title = {CCMusic: an Open and Diverse Database for Chinese and General Music Information Retrieval Research},
|
17 |
+
month = {mar},
|
18 |
+
year = {2024},
|
19 |
+
publisher = {HuggingFace},
|
20 |
+
version = {1.2},
|
21 |
+
url = {https://huggingface.co/ccmusic-database}
|
22 |
+
}
|
23 |
+
"""
|
24 |
+
|
25 |
+
_DESCRIPTION = """\
|
26 |
+
The raw dataset comprises 300 pop songs in .mp3 format, sourced from the NetEase music, accompanied by a structure annotation file for each song in .txt format. The annotator for music structure is a professional musician and teacher from the China Conservatory of Music. For the statistics of the dataset, there are 208 Chinese songs, 87 English songs, three Korean songs and two Japanese songs. The song structures are labeled as follows: intro, re-intro, verse, chorus, pre-chorus, post-chorus, bridge, interlude and ending. Fig. 7 shows the frequency of each segment label that appears in the set. The labels chorus and verse are the two most prevalent segment labels in the dataset and they are the most common segment in Western popular music. Among them, the number of “Postchorus” tags is the least, with only two present.
|
27 |
+
|
28 |
+
Unlike the above three datasets for classification, this one has not undergone pre-processing such as spectrogram transform. Thus we provide the original content only. The integrated version of the dataset is organized based on audio files, with each item structured into three columns: The first column contains the audio of the song in .mp3 format, sampled at 44,100 Hz. The second column consists of lists indicating the time points that mark the boundaries of different song sections, while the third column contains lists corresponding to the labels of the song structures listed in the second column. Strictly speaking, the first column represents the data, while the subsequent two columns represent the label.
|
29 |
+
"""
|
30 |
+
|
31 |
+
_URLS = {
|
32 |
+
"audio": f"{_DOMAIN}/audio.zip",
|
33 |
+
"mel": f"{_DOMAIN}/mel.zip",
|
34 |
+
"label": f"{_DOMAIN}/label.zip",
|
35 |
+
}
|
36 |
+
|
37 |
+
|
38 |
+
class song_structure(datasets.GeneratorBasedBuilder):
|
39 |
+
def _info(self):
|
40 |
+
return datasets.DatasetInfo(
|
41 |
+
features=datasets.Features(
|
42 |
+
{
|
43 |
+
"audio": datasets.Audio(sampling_rate=22050),
|
44 |
+
"mel": datasets.Image(),
|
45 |
+
"label": datasets.Sequence(
|
46 |
+
feature={
|
47 |
+
"onset_time": datasets.Value("uint32"),
|
48 |
+
"offset_time": datasets.Value("uint32"),
|
49 |
+
"structure": datasets.Value("string"),
|
50 |
+
}
|
51 |
+
),
|
52 |
+
}
|
53 |
+
),
|
54 |
+
supervised_keys=("audio", "label"),
|
55 |
+
homepage=_HOMEPAGE,
|
56 |
+
license="CC-BY-NC-ND",
|
57 |
+
version="1.2.0",
|
58 |
+
citation=_CITATION,
|
59 |
+
description=_DESCRIPTION,
|
60 |
+
)
|
61 |
+
|
62 |
+
def _parse_txt_label(self, txt_file):
|
63 |
+
label = []
|
64 |
+
with open(txt_file, mode="r", encoding="utf-8") as file:
|
65 |
+
reader = csv.reader(file, delimiter="\t")
|
66 |
+
for row in reader:
|
67 |
+
if len(row) == 3:
|
68 |
+
label.append(
|
69 |
+
{
|
70 |
+
"onset_time": int(row[0]),
|
71 |
+
"offset_time": int(row[1]),
|
72 |
+
"structure": str(row[2]),
|
73 |
+
}
|
74 |
+
)
|
75 |
+
|
76 |
+
return label
|
77 |
+
|
78 |
+
def _str2md5(self, original_string: str):
|
79 |
+
md5_obj = hashlib.md5()
|
80 |
+
md5_obj.update(original_string.encode("utf-8"))
|
81 |
+
return md5_obj.hexdigest()
|
82 |
+
|
83 |
+
def _split_generators(self, dl_manager):
|
84 |
+
audio_files = dl_manager.download_and_extract(_URLS["audio"])
|
85 |
+
mel_files = dl_manager.download_and_extract(_URLS["mel"])
|
86 |
+
txt_files = dl_manager.download_and_extract(_URLS["label"])
|
87 |
+
files = {}
|
88 |
+
for path in dl_manager.iter_files([audio_files]):
|
89 |
+
fname: str = os.path.basename(path)
|
90 |
+
if fname.endswith(".mp3"):
|
91 |
+
item_id = self._str2md5(fname.split(".mp")[0])
|
92 |
+
files[item_id] = {"audio": path}
|
93 |
+
|
94 |
+
for path in dl_manager.iter_files([mel_files]):
|
95 |
+
fname: str = os.path.basename(path)
|
96 |
+
if fname.endswith(".jpg"):
|
97 |
+
item_id = self._str2md5(fname.split(".jp")[0])
|
98 |
+
files[item_id]["mel"] = path
|
99 |
+
|
100 |
+
for path in dl_manager.iter_files([txt_files]):
|
101 |
+
fname: str = os.path.basename(path)
|
102 |
+
if fname.endswith(".txt"):
|
103 |
+
item_id = self._str2md5(fname.split(".tx")[0])
|
104 |
+
files[item_id]["label"] = self._parse_txt_label(path)
|
105 |
+
|
106 |
+
dataset = list(files.values())
|
107 |
+
random.shuffle(dataset)
|
108 |
+
|
109 |
+
return [
|
110 |
+
datasets.SplitGenerator(
|
111 |
+
name=datasets.Split.TRAIN, gen_kwargs={"files": dataset}
|
112 |
+
),
|
113 |
+
]
|
114 |
+
|
115 |
+
def _generate_examples(self, files):
|
116 |
+
for i, path in enumerate(files):
|
117 |
+
yield i, path
|