boooooook commited on
Commit
7d3c17d
·
verified ·
1 Parent(s): 5a5d0a9

Upload 3 files

Browse files
Files changed (3) hide show
  1. README.md +161 -0
  2. data/genres.tar.gz +3 -0
  3. gtzan.py +93 -0
README.md ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pretty_name: GTZAN
3
+ ---
4
+
5
+ # Dataset Card for GTZAN
6
+
7
+ ## Table of Contents
8
+ - [Dataset Card for GTZAN](#dataset-card-for-gtzan)
9
+ - [Table of Contents](#table-of-contents)
10
+ - [Dataset Description](#dataset-description)
11
+ - [Dataset Summary](#dataset-summary)
12
+ - [Languages](#languages)
13
+ - [Dataset Structure](#dataset-structure)
14
+ - [Data Instances](#data-instances)
15
+ - [Data Fields](#data-fields)
16
+ - [Data Splits](#data-splits)
17
+ - [Dataset Creation](#dataset-creation)
18
+ - [Curation Rationale](#curation-rationale)
19
+ - [Source Data](#source-data)
20
+ - [Initial Data Collection and Normalization](#initial-data-collection-and-normalization)
21
+ - [Who are the source language producers?](#who-are-the-source-language-producers)
22
+ - [Annotations](#annotations)
23
+ - [Annotation process](#annotation-process)
24
+ - [Who are the annotators?](#who-are-the-annotators)
25
+ - [Personal and Sensitive Information](#personal-and-sensitive-information)
26
+ - [Considerations for Using the Data](#considerations-for-using-the-data)
27
+ - [Social Impact of Dataset](#social-impact-of-dataset)
28
+ - [Discussion of Biases](#discussion-of-biases)
29
+ - [Other Known Limitations](#other-known-limitations)
30
+ - [Additional Information](#additional-information)
31
+ - [Dataset Curators](#dataset-curators)
32
+ - [Licensing Information](#licensing-information)
33
+ - [Citation Information](#citation-information)
34
+ - [Contributions](#contributions)
35
+
36
+ ## Dataset Description
37
+
38
+ - **Homepage:** [http://marsyas.info/downloads/datasets.html](http://marsyas.info/downloads/datasets.html)
39
+ - **Paper:** [http://ismir2001.ismir.net/pdf/tzanetakis.pdf](http://ismir2001.ismir.net/pdf/tzanetakis.pdf)
40
+ - **Point of Contact:**
41
+
42
+ ### Dataset Summary
43
+
44
+ GTZAN is a dataset for musical genre classification of audio signals. The dataset consists of 1,000 audio tracks, each of 30 seconds long. It contains 10 genres, each represented by 100 tracks. The tracks are all 22,050Hz Mono 16-bit audio files in WAV format. The genres are: blues, classical, country, disco, hiphop, jazz, metal, pop, reggae, and rock.
45
+
46
+ ### Languages
47
+
48
+ English
49
+
50
+ ## Dataset Structure
51
+
52
+ GTZAN is distributed as a single dataset without a predefined training and test split. The information below refers to the single `train` split that is assigned by default.
53
+
54
+ ### Data Instances
55
+
56
+ An example of GTZAN looks as follows:
57
+
58
+ ```python
59
+ {
60
+ "file": "/path/to/cache/genres/blues/blues.00000.wav",
61
+ "audio": {
62
+ "path": "/path/to/cache/genres/blues/blues.00000.wav",
63
+ "array": array(
64
+ [
65
+ 0.00732422,
66
+ 0.01660156,
67
+ 0.00762939,
68
+ ...,
69
+ -0.05560303,
70
+ -0.06106567,
71
+ -0.06417847,
72
+ ],
73
+ dtype=float32,
74
+ ),
75
+ "sampling_rate": 22050,
76
+ },
77
+ "genre": 0,
78
+ }
79
+ ```
80
+
81
+ ### Data Fields
82
+
83
+ The types associated with each of the data fields is as follows:
84
+
85
+ * `file`: a `string` feature.
86
+ * `audio`: an `Audio` feature containing the `path` of the sound file, the decoded waveform in the `array` field, and the `sampling_rate`.
87
+ * `genre`: a `ClassLabel` feature.
88
+
89
+ ### Data Splits
90
+
91
+ [More Information Needed]
92
+
93
+ ## Dataset Creation
94
+
95
+ ### Curation Rationale
96
+
97
+ [More Information Needed]
98
+
99
+ ### Source Data
100
+
101
+ #### Initial Data Collection and Normalization
102
+
103
+ [More Information Needed]
104
+
105
+ #### Who are the source language producers?
106
+
107
+ [More Information Needed]
108
+
109
+ ### Annotations
110
+
111
+ #### Annotation process
112
+
113
+ [More Information Needed]
114
+
115
+ #### Who are the annotators?
116
+
117
+ [More Information Needed]
118
+
119
+ ### Personal and Sensitive Information
120
+
121
+ [More Information Needed]
122
+
123
+ ## Considerations for Using the Data
124
+
125
+ ### Social Impact of Dataset
126
+
127
+ [More Information Needed]
128
+
129
+ ### Discussion of Biases
130
+
131
+ [More Information Needed]
132
+
133
+ ### Other Known Limitations
134
+
135
+ [More Information Needed]
136
+
137
+ ## Additional Information
138
+
139
+ ### Dataset Curators
140
+
141
+ [More Information Needed]
142
+
143
+ ### Licensing Information
144
+
145
+ [More Information Needed]
146
+
147
+ ### Citation Information
148
+
149
+ ```
150
+ @misc{tzanetakis_essl_cook_2001,
151
+ author = "Tzanetakis, George and Essl, Georg and Cook, Perry",
152
+ title = "Automatic Musical Genre Classification Of Audio Signals",
153
+ url = "http://ismir2001.ismir.net/pdf/tzanetakis.pdf",
154
+ publisher = "The International Society for Music Information Retrieval",
155
+ year = "2001"
156
+ }
157
+ ```
158
+
159
+ ### Contributions
160
+
161
+ Thanks to [@lewtun](https://github.com/lewtun) for adding this dataset.
data/genres.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2cfa9620967a29a123d5cf4f268f1d2ad26fb870ad68cda5cfe5ce9f1ad8ff40
3
+ size 1242498731
gtzan.py ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ """The GTZAN dataset."""
15
+
16
+
17
+ from pathlib import Path
18
+
19
+ import datasets
20
+ import pandas as pd
21
+
22
+ _CITATION = """\
23
+ @misc{tzanetakis_essl_cook_2001,
24
+ author = "Tzanetakis, George and Essl, Georg and Cook, Perry",
25
+ title = "Automatic Musical Genre Classification Of Audio Signals",
26
+ url = "http://ismir2001.ismir.net/pdf/tzanetakis.pdf",
27
+ publisher = "The International Society for Music Information Retrieval",
28
+ year = "2001"
29
+ }
30
+ """
31
+
32
+
33
+ _DESCRIPTION = """\
34
+ GTZAN is a dataset for musical genre classification of audio signals. The dataset consists of 1,000 audio tracks, each of 30 seconds long. It contains 10 genres, each represented by 100 tracks. The tracks are all 22,050Hz Mono 16-bit audio files in WAV format. The genres are: blues, classical, country, disco, hiphop, jazz, metal, pop, reggae, and rock.
35
+ """
36
+
37
+ _HOMEPAGE = "http://marsyas.info/downloads/datasets.html"
38
+
39
+ # TODO: Add the licence for the dataset here if you can find it
40
+ _LICENSE = ""
41
+
42
+ _URL = "http://opihi.cs.uvic.ca/sound/genres.tar.gz"
43
+
44
+ GENRES = ["blues", "classical", "country", "disco", "hiphop", "jazz", "metal", "pop", "reggae", "rock"]
45
+ CORRUPTED_FILES = ["jazz.00054.wav"]
46
+
47
+
48
+ class Gtzan(datasets.GeneratorBasedBuilder):
49
+ """The GTZAn dataset"""
50
+
51
+ def _info(self):
52
+ return datasets.DatasetInfo(
53
+ description=_DESCRIPTION,
54
+ features=datasets.Features(
55
+ {
56
+ "file": datasets.Value("string"),
57
+ "audio": datasets.Audio(sampling_rate=22_050),
58
+ "genre": datasets.ClassLabel(names=GENRES),
59
+ }
60
+ ),
61
+ homepage=_HOMEPAGE,
62
+ license=_LICENSE,
63
+ citation=_CITATION,
64
+ )
65
+
66
+ def _split_generators(self, dl_manager):
67
+ local_extracted_archive = dl_manager.download_and_extract("data/genres.tar.gz")
68
+ return [
69
+ datasets.SplitGenerator(
70
+ name=datasets.Split.TRAIN,
71
+ gen_kwargs={
72
+ "local_extracted_archive": local_extracted_archive,
73
+ },
74
+ )
75
+ ]
76
+
77
+ def _generate_examples(self, local_extracted_archive):
78
+ paths = list(Path(local_extracted_archive).glob("**/*.wav"))
79
+ paths = [p for p in paths if "._" not in p.name]
80
+ data = []
81
+
82
+ for path in paths:
83
+ label = path.parts[-2]
84
+ name = path.parts[-1]
85
+ if name in CORRUPTED_FILES:
86
+ continue
87
+
88
+ data.append({"file": str(path), "genre": label})
89
+ df = pd.DataFrame(data)
90
+ df.sort_values("file", inplace=True)
91
+
92
+ for idx_, row in df.iterrows():
93
+ yield idx_, {"file": row["file"], "audio": row["file"], "genre": row["genre"]}