admin commited on
Commit
5823503
·
1 Parent(s): 663772c

2 arrows base

Browse files
README.md CHANGED
@@ -12,14 +12,81 @@ tags:
12
  pretty_name: Music Genre Dataset
13
  size_categories:
14
  - 10K<n<100K
15
- viewer: false
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  ---
17
 
18
  # Dataset Card for Music Genre
19
  The Default dataset comprises approximately 1,700 musical pieces in .mp3 format, sourced from the NetEase music. The lengths of these pieces range from 270 to 300 seconds. All are sampled at the rate of 22,050 Hz. As the website providing the audio music includes style labels for the downloaded music, there are no specific annotators involved. Validation is achieved concurrently with the downloading process. They are categorized into a total of 16 genres.
20
 
21
  ## Dataset Structure
22
- <https://www.modelscope.cn/datasets/ccmusic-database/music_genre/dataPeview>
23
  <style>
24
  .genres td {
25
  vertical-align: middle !important;
@@ -123,21 +190,6 @@ Audio classification
123
  Multilingual
124
 
125
  ## Usage
126
- ### Default Subset
127
- ```python
128
- from datasets import load_dataset
129
-
130
- ds = load_dataset("ccmusic-database/music_genre")
131
- for item in ds["train"]:
132
- print(item)
133
-
134
- for item in ds["validation"]:
135
- print(item)
136
-
137
- for item in ds["test"]:
138
- print(item)
139
- ```
140
-
141
  ### Eval Subset
142
  ```python
143
  from datasets import load_dataset
@@ -155,7 +207,7 @@ for item in ds["test"]:
155
 
156
  ## Maintenance
157
  ```bash
158
- git clone [email protected]:datasets/ccmusic-database/music_genre
159
  cd music_genre
160
  ```
161
 
 
12
  pretty_name: Music Genre Dataset
13
  size_categories:
14
  - 10K<n<100K
15
+ dataset_info:
16
+ - config_name: eval
17
+ features:
18
+ - name: mel
19
+ dtype: image
20
+ - name: cqt
21
+ dtype: image
22
+ - name: chroma
23
+ dtype: image
24
+ - name: fst_level_label
25
+ dtype:
26
+ class_label:
27
+ names:
28
+ '0': Classic
29
+ '1': Non_classic
30
+ - name: sec_level_label
31
+ dtype:
32
+ class_label:
33
+ names:
34
+ '0': Symphony
35
+ '1': Opera
36
+ '2': Solo
37
+ '3': Chamber
38
+ '4': Pop
39
+ '5': Dance_and_house
40
+ '6': Indie
41
+ '7': Soul_or_RnB
42
+ '8': Rock
43
+ - name: thr_level_label
44
+ dtype:
45
+ class_label:
46
+ names:
47
+ '0': Symphony
48
+ '1': Opera
49
+ '2': Solo
50
+ '3': Chamber
51
+ '4': Pop_vocal_ballad
52
+ '5': Adult_contemporary
53
+ '6': Teen_pop
54
+ '7': Contemporary_dance_pop
55
+ '8': Dance_pop
56
+ '9': Classic_indie_pop
57
+ '10': Chamber_cabaret_and_art_pop
58
+ '11': Soul_or_RnB
59
+ '12': Adult_alternative_rock
60
+ '13': Uplifting_anthemic_rock
61
+ '14': Soft_rock
62
+ '15': Acoustic_pop
63
+ splits:
64
+ - name: train
65
+ num_bytes: 19661943
66
+ num_examples: 29100
67
+ - name: validation
68
+ num_bytes: 2453757
69
+ num_examples: 3637
70
+ - name: test
71
+ num_bytes: 2456508
72
+ num_examples: 3638
73
+ download_size: 4436653005
74
+ dataset_size: 24572208
75
+ configs:
76
+ - config_name: eval
77
+ data_files:
78
+ - split: train
79
+ path: eval/train/data-*.arrow
80
+ - split: validation
81
+ path: eval/validation/data-*.arrow
82
+ - split: test
83
+ path: eval/test/data-*.arrow
84
  ---
85
 
86
  # Dataset Card for Music Genre
87
  The Default dataset comprises approximately 1,700 musical pieces in .mp3 format, sourced from the NetEase music. The lengths of these pieces range from 270 to 300 seconds. All are sampled at the rate of 22,050 Hz. As the website providing the audio music includes style labels for the downloaded music, there are no specific annotators involved. Validation is achieved concurrently with the downloading process. They are categorized into a total of 16 genres.
88
 
89
  ## Dataset Structure
 
90
  <style>
91
  .genres td {
92
  vertical-align: middle !important;
 
190
  Multilingual
191
 
192
  ## Usage
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
  ### Eval Subset
194
  ```python
195
  from datasets import load_dataset
 
207
 
208
  ## Maintenance
209
  ```bash
210
+ GIT_LFS_SKIP_SMUDGE=1 git clone [email protected]:datasets/ccmusic-database/music_genre
211
  cd music_genre
212
  ```
213
 
eval/dataset_dict.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"splits": ["train", "validation", "test"]}
eval/test/dataset_info.json ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "builder_name": "music_genre",
3
+ "citation": "",
4
+ "config_name": "eval",
5
+ "dataset_name": "music_genre",
6
+ "dataset_size": 24572208,
7
+ "description": "",
8
+ "download_checksums": {
9
+ "https://www.modelscope.cn/datasets/ccmusic-database/music_genre/resolve/master/data/eval.zip": {
10
+ "num_bytes": 4436653005,
11
+ "checksum": null
12
+ }
13
+ },
14
+ "download_size": 4436653005,
15
+ "features": {
16
+ "mel": {
17
+ "_type": "Image"
18
+ },
19
+ "cqt": {
20
+ "_type": "Image"
21
+ },
22
+ "chroma": {
23
+ "_type": "Image"
24
+ },
25
+ "fst_level_label": {
26
+ "names": [
27
+ "Classic",
28
+ "Non_classic"
29
+ ],
30
+ "_type": "ClassLabel"
31
+ },
32
+ "sec_level_label": {
33
+ "names": [
34
+ "Symphony",
35
+ "Opera",
36
+ "Solo",
37
+ "Chamber",
38
+ "Pop",
39
+ "Dance_and_house",
40
+ "Indie",
41
+ "Soul_or_RnB",
42
+ "Rock"
43
+ ],
44
+ "_type": "ClassLabel"
45
+ },
46
+ "thr_level_label": {
47
+ "names": [
48
+ "Symphony",
49
+ "Opera",
50
+ "Solo",
51
+ "Chamber",
52
+ "Pop_vocal_ballad",
53
+ "Adult_contemporary",
54
+ "Teen_pop",
55
+ "Contemporary_dance_pop",
56
+ "Dance_pop",
57
+ "Classic_indie_pop",
58
+ "Chamber_cabaret_and_art_pop",
59
+ "Soul_or_RnB",
60
+ "Adult_alternative_rock",
61
+ "Uplifting_anthemic_rock",
62
+ "Soft_rock",
63
+ "Acoustic_pop"
64
+ ],
65
+ "_type": "ClassLabel"
66
+ }
67
+ },
68
+ "homepage": "https://www.modelscope.cn/datasets/ccmusic-database/music_genre",
69
+ "license": "CC-BY-NC-ND",
70
+ "size_in_bytes": 4461225213,
71
+ "splits": {
72
+ "train": {
73
+ "name": "train",
74
+ "num_bytes": 19661943,
75
+ "num_examples": 29100,
76
+ "dataset_name": "music_genre"
77
+ },
78
+ "validation": {
79
+ "name": "validation",
80
+ "num_bytes": 2453757,
81
+ "num_examples": 3637,
82
+ "dataset_name": "music_genre"
83
+ },
84
+ "test": {
85
+ "name": "test",
86
+ "num_bytes": 2456508,
87
+ "num_examples": 3638,
88
+ "dataset_name": "music_genre"
89
+ }
90
+ },
91
+ "supervised_keys": {
92
+ "input": "mel",
93
+ "output": "sec_level_label"
94
+ },
95
+ "task_templates": [
96
+ {
97
+ "task": "image-classification",
98
+ "image_column": "mel",
99
+ "label_column": "sec_level_label"
100
+ }
101
+ ],
102
+ "version": {
103
+ "version_str": "0.0.0",
104
+ "major": 0,
105
+ "minor": 0,
106
+ "patch": 0
107
+ }
108
+ }
eval/test/state.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_data_files": [
3
+ {
4
+ "filename": "data-00000-of-00001.arrow"
5
+ }
6
+ ],
7
+ "_fingerprint": "39a75b20be049dd1",
8
+ "_format_columns": null,
9
+ "_format_kwargs": {},
10
+ "_format_type": null,
11
+ "_output_all_columns": false,
12
+ "_split": "test"
13
+ }
eval/train/dataset_info.json ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "builder_name": "music_genre",
3
+ "citation": "",
4
+ "config_name": "eval",
5
+ "dataset_name": "music_genre",
6
+ "dataset_size": 24572208,
7
+ "description": "",
8
+ "download_checksums": {
9
+ "https://www.modelscope.cn/datasets/ccmusic-database/music_genre/resolve/master/data/eval.zip": {
10
+ "num_bytes": 4436653005,
11
+ "checksum": null
12
+ }
13
+ },
14
+ "download_size": 4436653005,
15
+ "features": {
16
+ "mel": {
17
+ "_type": "Image"
18
+ },
19
+ "cqt": {
20
+ "_type": "Image"
21
+ },
22
+ "chroma": {
23
+ "_type": "Image"
24
+ },
25
+ "fst_level_label": {
26
+ "names": [
27
+ "Classic",
28
+ "Non_classic"
29
+ ],
30
+ "_type": "ClassLabel"
31
+ },
32
+ "sec_level_label": {
33
+ "names": [
34
+ "Symphony",
35
+ "Opera",
36
+ "Solo",
37
+ "Chamber",
38
+ "Pop",
39
+ "Dance_and_house",
40
+ "Indie",
41
+ "Soul_or_RnB",
42
+ "Rock"
43
+ ],
44
+ "_type": "ClassLabel"
45
+ },
46
+ "thr_level_label": {
47
+ "names": [
48
+ "Symphony",
49
+ "Opera",
50
+ "Solo",
51
+ "Chamber",
52
+ "Pop_vocal_ballad",
53
+ "Adult_contemporary",
54
+ "Teen_pop",
55
+ "Contemporary_dance_pop",
56
+ "Dance_pop",
57
+ "Classic_indie_pop",
58
+ "Chamber_cabaret_and_art_pop",
59
+ "Soul_or_RnB",
60
+ "Adult_alternative_rock",
61
+ "Uplifting_anthemic_rock",
62
+ "Soft_rock",
63
+ "Acoustic_pop"
64
+ ],
65
+ "_type": "ClassLabel"
66
+ }
67
+ },
68
+ "homepage": "https://www.modelscope.cn/datasets/ccmusic-database/music_genre",
69
+ "license": "CC-BY-NC-ND",
70
+ "size_in_bytes": 4461225213,
71
+ "splits": {
72
+ "train": {
73
+ "name": "train",
74
+ "num_bytes": 19661943,
75
+ "num_examples": 29100,
76
+ "dataset_name": "music_genre"
77
+ },
78
+ "validation": {
79
+ "name": "validation",
80
+ "num_bytes": 2453757,
81
+ "num_examples": 3637,
82
+ "dataset_name": "music_genre"
83
+ },
84
+ "test": {
85
+ "name": "test",
86
+ "num_bytes": 2456508,
87
+ "num_examples": 3638,
88
+ "dataset_name": "music_genre"
89
+ }
90
+ },
91
+ "supervised_keys": {
92
+ "input": "mel",
93
+ "output": "sec_level_label"
94
+ },
95
+ "task_templates": [
96
+ {
97
+ "task": "image-classification",
98
+ "image_column": "mel",
99
+ "label_column": "sec_level_label"
100
+ }
101
+ ],
102
+ "version": {
103
+ "version_str": "0.0.0",
104
+ "major": 0,
105
+ "minor": 0,
106
+ "patch": 0
107
+ }
108
+ }
eval/train/state.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_data_files": [
3
+ {
4
+ "filename": "data-00000-of-00008.arrow"
5
+ },
6
+ {
7
+ "filename": "data-00001-of-00008.arrow"
8
+ },
9
+ {
10
+ "filename": "data-00002-of-00008.arrow"
11
+ },
12
+ {
13
+ "filename": "data-00003-of-00008.arrow"
14
+ },
15
+ {
16
+ "filename": "data-00004-of-00008.arrow"
17
+ },
18
+ {
19
+ "filename": "data-00005-of-00008.arrow"
20
+ },
21
+ {
22
+ "filename": "data-00006-of-00008.arrow"
23
+ },
24
+ {
25
+ "filename": "data-00007-of-00008.arrow"
26
+ }
27
+ ],
28
+ "_fingerprint": "cf206ff81eed2816",
29
+ "_format_columns": null,
30
+ "_format_kwargs": {},
31
+ "_format_type": null,
32
+ "_output_all_columns": false,
33
+ "_split": "train"
34
+ }
eval/validation/dataset_info.json ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "builder_name": "music_genre",
3
+ "citation": "",
4
+ "config_name": "eval",
5
+ "dataset_name": "music_genre",
6
+ "dataset_size": 24572208,
7
+ "description": "",
8
+ "download_checksums": {
9
+ "https://www.modelscope.cn/datasets/ccmusic-database/music_genre/resolve/master/data/eval.zip": {
10
+ "num_bytes": 4436653005,
11
+ "checksum": null
12
+ }
13
+ },
14
+ "download_size": 4436653005,
15
+ "features": {
16
+ "mel": {
17
+ "_type": "Image"
18
+ },
19
+ "cqt": {
20
+ "_type": "Image"
21
+ },
22
+ "chroma": {
23
+ "_type": "Image"
24
+ },
25
+ "fst_level_label": {
26
+ "names": [
27
+ "Classic",
28
+ "Non_classic"
29
+ ],
30
+ "_type": "ClassLabel"
31
+ },
32
+ "sec_level_label": {
33
+ "names": [
34
+ "Symphony",
35
+ "Opera",
36
+ "Solo",
37
+ "Chamber",
38
+ "Pop",
39
+ "Dance_and_house",
40
+ "Indie",
41
+ "Soul_or_RnB",
42
+ "Rock"
43
+ ],
44
+ "_type": "ClassLabel"
45
+ },
46
+ "thr_level_label": {
47
+ "names": [
48
+ "Symphony",
49
+ "Opera",
50
+ "Solo",
51
+ "Chamber",
52
+ "Pop_vocal_ballad",
53
+ "Adult_contemporary",
54
+ "Teen_pop",
55
+ "Contemporary_dance_pop",
56
+ "Dance_pop",
57
+ "Classic_indie_pop",
58
+ "Chamber_cabaret_and_art_pop",
59
+ "Soul_or_RnB",
60
+ "Adult_alternative_rock",
61
+ "Uplifting_anthemic_rock",
62
+ "Soft_rock",
63
+ "Acoustic_pop"
64
+ ],
65
+ "_type": "ClassLabel"
66
+ }
67
+ },
68
+ "homepage": "https://www.modelscope.cn/datasets/ccmusic-database/music_genre",
69
+ "license": "CC-BY-NC-ND",
70
+ "size_in_bytes": 4461225213,
71
+ "splits": {
72
+ "train": {
73
+ "name": "train",
74
+ "num_bytes": 19661943,
75
+ "num_examples": 29100,
76
+ "dataset_name": "music_genre"
77
+ },
78
+ "validation": {
79
+ "name": "validation",
80
+ "num_bytes": 2453757,
81
+ "num_examples": 3637,
82
+ "dataset_name": "music_genre"
83
+ },
84
+ "test": {
85
+ "name": "test",
86
+ "num_bytes": 2456508,
87
+ "num_examples": 3638,
88
+ "dataset_name": "music_genre"
89
+ }
90
+ },
91
+ "supervised_keys": {
92
+ "input": "mel",
93
+ "output": "sec_level_label"
94
+ },
95
+ "task_templates": [
96
+ {
97
+ "task": "image-classification",
98
+ "image_column": "mel",
99
+ "label_column": "sec_level_label"
100
+ }
101
+ ],
102
+ "version": {
103
+ "version_str": "0.0.0",
104
+ "major": 0,
105
+ "minor": 0,
106
+ "patch": 0
107
+ }
108
+ }
eval/validation/state.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_data_files": [
3
+ {
4
+ "filename": "data-00000-of-00001.arrow"
5
+ }
6
+ ],
7
+ "_fingerprint": "1af7cf18053a82fb",
8
+ "_format_columns": null,
9
+ "_format_kwargs": {},
10
+ "_format_type": null,
11
+ "_output_all_columns": false,
12
+ "_split": "validation"
13
+ }
music_genre.py DELETED
@@ -1,195 +0,0 @@
1
- import os
2
- import random
3
- import datasets
4
- from datasets.tasks import ImageClassification
5
-
6
- _NAMES_1 = {
7
- 1: "Classic",
8
- 2: "Non_classic",
9
- }
10
-
11
- _NAMES_2 = {
12
- 3: "Symphony",
13
- 4: "Opera",
14
- 5: "Solo",
15
- 6: "Chamber",
16
- 7: "Pop",
17
- 8: "Dance_and_house",
18
- 9: "Indie",
19
- 10: "Soul_or_RnB",
20
- 11: "Rock",
21
- }
22
-
23
- _NAMES_3 = {
24
- 3: "Symphony",
25
- 4: "Opera",
26
- 5: "Solo",
27
- 6: "Chamber",
28
- 12: "Pop_vocal_ballad",
29
- 13: "Adult_contemporary",
30
- 14: "Teen_pop",
31
- 15: "Contemporary_dance_pop",
32
- 16: "Dance_pop",
33
- 17: "Classic_indie_pop",
34
- 18: "Chamber_cabaret_and_art_pop",
35
- 10: "Soul_or_RnB",
36
- 19: "Adult_alternative_rock",
37
- 20: "Uplifting_anthemic_rock",
38
- 21: "Soft_rock",
39
- 22: "Acoustic_pop",
40
- }
41
-
42
- _HOMEPAGE = f"https://www.modelscope.cn/datasets/ccmusic-database/{os.path.basename(__file__)[:-3]}"
43
-
44
- _DOMAIN = f"{_HOMEPAGE}/resolve/master/data"
45
-
46
- _URLS = {
47
- "audio": f"{_DOMAIN}/audio.zip",
48
- "mel": f"{_DOMAIN}/mel.zip",
49
- "eval": f"{_DOMAIN}/eval.zip",
50
- }
51
-
52
-
53
- class music_genre(datasets.GeneratorBasedBuilder):
54
- def _info(self):
55
- return datasets.DatasetInfo(
56
- features=(
57
- datasets.Features(
58
- {
59
- "audio": datasets.Audio(sampling_rate=22050),
60
- "mel": datasets.Image(),
61
- "fst_level_label": datasets.features.ClassLabel(
62
- names=list(_NAMES_1.values())
63
- ),
64
- "sec_level_label": datasets.features.ClassLabel(
65
- names=list(_NAMES_2.values())
66
- ),
67
- "thr_level_label": datasets.features.ClassLabel(
68
- names=list(_NAMES_3.values())
69
- ),
70
- }
71
- )
72
- if self.config.name == "raw"
73
- else datasets.Features(
74
- {
75
- "mel": datasets.Image(),
76
- "cqt": datasets.Image(),
77
- "chroma": datasets.Image(),
78
- "fst_level_label": datasets.features.ClassLabel(
79
- names=list(_NAMES_1.values())
80
- ),
81
- "sec_level_label": datasets.features.ClassLabel(
82
- names=list(_NAMES_2.values())
83
- ),
84
- "thr_level_label": datasets.features.ClassLabel(
85
- names=list(_NAMES_3.values())
86
- ),
87
- }
88
- )
89
- ),
90
- supervised_keys=("mel", "sec_level_label"),
91
- homepage=_HOMEPAGE,
92
- license="CC-BY-NC-ND",
93
- version="1.2.0",
94
- task_templates=[
95
- ImageClassification(
96
- task="image-classification",
97
- image_column="mel",
98
- label_column="sec_level_label",
99
- )
100
- ],
101
- )
102
-
103
- def _split_generators(self, dl_manager):
104
- dataset = []
105
- if self.config.name == "raw":
106
- files = {}
107
- audio_files = dl_manager.download_and_extract(_URLS["audio"])
108
- mel_files = dl_manager.download_and_extract(_URLS["mel"])
109
- for path in dl_manager.iter_files([audio_files]):
110
- fname: str = os.path.basename(path)
111
- if fname.endswith(".mp3"):
112
- files[fname.split(".mp")[0]] = {"audio": path}
113
-
114
- for path in dl_manager.iter_files([mel_files]):
115
- fname = os.path.basename(path)
116
- if fname.endswith(".jpg"):
117
- files[fname.split(".jp")[0]]["mel"] = path
118
-
119
- dataset = list(files.values())
120
-
121
- else:
122
- data_files = dl_manager.download_and_extract(_URLS["eval"])
123
- for path in dl_manager.iter_files([data_files]):
124
- if os.path.basename(path).endswith(".jpg") and "mel" in path:
125
- dataset.append(
126
- {
127
- "mel": path,
128
- "cqt": path.replace("\\mel\\", "\\cqt\\").replace(
129
- "/mel/", "/cqt/"
130
- ),
131
- "chroma": path.replace("\\mel\\", "\\chroma\\").replace(
132
- "/mel/", "/chroma/"
133
- ),
134
- }
135
- )
136
-
137
- random.shuffle(dataset)
138
- data_count = len(dataset)
139
- p80 = int(data_count * 0.8)
140
- p90 = int(data_count * 0.9)
141
- return [
142
- datasets.SplitGenerator(
143
- name=datasets.Split.TRAIN,
144
- gen_kwargs={"files": dataset[:p80]},
145
- ),
146
- datasets.SplitGenerator(
147
- name=datasets.Split.VALIDATION,
148
- gen_kwargs={"files": dataset[p80:p90]},
149
- ),
150
- datasets.SplitGenerator(
151
- name=datasets.Split.TEST,
152
- gen_kwargs={"files": dataset[p90:]},
153
- ),
154
- ]
155
-
156
- def _calc_label(self, path, depth, substr="/mel/"):
157
- spect = substr
158
- dirpath: str = os.path.dirname(path)
159
- substr_index = dirpath.find(spect)
160
- if substr_index < 0:
161
- spect = spect.replace("/", "\\")
162
- substr_index = dirpath.find(spect)
163
-
164
- labstr = dirpath[substr_index + len(spect) :]
165
- labs = labstr.split("/")
166
- if len(labs) < 2:
167
- labs = labstr.split("\\")
168
-
169
- if depth <= len(labs):
170
- return int(labs[depth - 1].split("_")[0])
171
-
172
- else:
173
- return int(labs[-1].split("_")[0])
174
-
175
- def _generate_examples(self, files):
176
- if self.config.name == "raw":
177
- for i, path in enumerate(files):
178
- yield i, {
179
- "audio": path["audio"],
180
- "mel": path["mel"],
181
- "fst_level_label": _NAMES_1[self._calc_label(path["mel"], 1)],
182
- "sec_level_label": _NAMES_2[self._calc_label(path["mel"], 2)],
183
- "thr_level_label": _NAMES_3[self._calc_label(path["mel"], 3)],
184
- }
185
-
186
- else:
187
- for i, path in enumerate(files):
188
- yield i, {
189
- "mel": path["mel"],
190
- "cqt": path["cqt"],
191
- "chroma": path["chroma"],
192
- "fst_level_label": _NAMES_1[self._calc_label(path["mel"], 1)],
193
- "sec_level_label": _NAMES_2[self._calc_label(path["mel"], 2)],
194
- "thr_level_label": _NAMES_3[self._calc_label(path["mel"], 3)],
195
- }