maxardito commited on
Commit
99b9f80
1 Parent(s): 9ff8ad3

Template initialization file

Browse files
Files changed (3) hide show
  1. README.md +1 -1
  2. beatbox.py +122 -0
  3. dataset/metadata.csv +1 -1
README.md CHANGED
@@ -10,7 +10,7 @@ arxiv: https://doi.org/10.1007/978-3-031-05981-0_14
10
 
11
  # Beatbox Dataset
12
 
13
- Dataset consisting of isolated beatbox samples from the paper **[BaDumTss: Multi-task
14
  Learning for Beatbox
15
  Transcription](https://link.springer.com/chapter/10.1007/978-3-031-05981-0_14])**
16
 
 
10
 
11
  # Beatbox Dataset
12
 
13
+ Dataset consisting of isolated beatbox samples. Reimplementation of a dataset from the paper **[BaDumTss: Multi-task
14
  Learning for Beatbox
15
  Transcription](https://link.springer.com/chapter/10.1007/978-3-031-05981-0_14])**
16
 
beatbox.py ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import datasets
2
+ import csv
3
+ import os
4
+
5
+ # For a future citation perhaps?
6
+ # _CITATION = """\
7
+ # @inproceedings{luong-vu-2016-non,
8
+ # title = "A non-expert {K}aldi recipe for {V}ietnamese Speech Recognition System",
9
+ # author = "Luong, Hieu-Thi and
10
+ # Vu, Hai-Quan",
11
+ # booktitle = "Proceedings of the Third International Workshop on Worldwide Language Service Infrastructure and Second Workshop on Open Infrastructures and Analysis Frameworks for Human Language Technologies ({WLSI}/{OIAF}4{HLT}2016)",
12
+ # month = dec,
13
+ # year = "2016",
14
+ # address = "Osaka, Japan",
15
+ # publisher = "The COLING 2016 Organizing Committee",
16
+ # url = "https://aclanthology.org/W16-5207",
17
+ # pages = "51--55",
18
+ # }
19
+ # """
20
+
21
+ _DESCRIPTION = """\
22
+ Dataset consisting of isolated beatbox samples ,
23
+ reimplementation of the dataset from the following
24
+ paper: BaDumTss: Multi-task Learning for Beatbox Transcription
25
+ """
26
+
27
+ _HOMEPAGE = "https://doi.org/10.1007/978-3-031-05981-0_14"
28
+
29
+ _LICENSE = "MIT"
30
+
31
+ _DATA_URL = "https://huggingface.co/datasets/maxardito/beatbox/tree/main/dataset/"
32
+
33
+
34
+ class BeatboxDataset(datasets.GeneratorBasedBuilder):
35
+
36
+ VERSION = datasets.Version("1.0.0")
37
+
38
+ def _info(self):
39
+ return datasets.DatasetInfo(
40
+ # This is the description that will appear on the datasets page.
41
+ description=_DESCRIPTION,
42
+ features=datasets.Features({
43
+ "path":
44
+ datasets.Value("string"),
45
+ "class":
46
+ datasets.Value("string"),
47
+ "audio":
48
+ datasets.Audio(sampling_rate=16_000),
49
+ }),
50
+ supervised_keys=None,
51
+ homepage=_HOMEPAGE,
52
+ license=_LICENSE,
53
+ # citation=_CITATION,
54
+ )
55
+
56
+ def _split_generators(self, dl_manager):
57
+ """Returns SplitGenerators."""
58
+ dl_manager.download_config.ignore_url_params = True
59
+ audio_path = {}
60
+ local_extracted_archive = {}
61
+ metadata_path = {}
62
+ split_type = {
63
+ "train": datasets.Split.TRAIN,
64
+ "test": datasets.Split.TEST
65
+ }
66
+ for split in split_type:
67
+ audio_path[split] = dl_manager.download(
68
+ f"{_DATA_URL}/audio_{split}.tgz")
69
+ local_extracted_archive[split] = dl_manager.extract(
70
+ audio_path[split]) if not dl_manager.is_streaming else None
71
+ metadata_path[split] = dl_manager.download_and_extract(
72
+ f"{_DATA_URL}/metadata_{split}.csv.gz")
73
+ path_to_clips = "beatbox"
74
+
75
+ return [
76
+ datasets.SplitGenerator(
77
+ name=split_type[split],
78
+ gen_kwargs={
79
+ "local_extracted_archive":
80
+ local_extracted_archive[split],
81
+ "audio_files":
82
+ dl_manager.iter_archive(audio_path[split]),
83
+ "metadata_path":
84
+ dl_manager.download_and_extract(metadata_path[split]),
85
+ "path_to_clips":
86
+ path_to_clips,
87
+ },
88
+ ) for split in split_type
89
+ ]
90
+
91
+ def _generate_examples(
92
+ self,
93
+ local_extracted_archive,
94
+ audio_files,
95
+ metadata_path,
96
+ path_to_clips,
97
+ ):
98
+ """Yields examples."""
99
+ data_fields = list(self._info().features.keys())
100
+ metadata = {}
101
+ with open(metadata_path, "r", encoding="utf-8") as f:
102
+ reader = csv.DictReader(f)
103
+ for row in reader:
104
+ if self.config.name == "_all_" or self.config.name == row[
105
+ "language"]:
106
+ row["path"] = os.path.join(path_to_clips, row["path"])
107
+ # if data is incomplete, fill with empty values
108
+ for field in data_fields:
109
+ if field not in row:
110
+ row[field] = ""
111
+ metadata[row["path"]] = row
112
+ id_ = 0
113
+ for path, f in audio_files:
114
+ if path in metadata:
115
+ result = dict(metadata[path])
116
+ # set the audio feature and the path to the extracted file
117
+ path = os.path.join(local_extracted_archive,
118
+ path) if local_extracted_archive else path
119
+ result["audio"] = {"path": path, "bytes": f.read()}
120
+ result["path"] = path
121
+ yield id_, result
122
+ id_ += 1
dataset/metadata.csv CHANGED
@@ -1,4 +1,4 @@
1
- file_name,class
2
  kick-001.wav,0
3
  kick-001-a-1.wav,0
4
  kick-001-a-2.wav,0
 
1
+ path,class
2
  kick-001.wav,0
3
  kick-001-a-1.wav,0
4
  kick-001-a-2.wav,0