Ahmed-ibn-Harun commited on
Commit
c7c6717
1 Parent(s): d21ac8b

Upload wake.py

Browse files
Files changed (1) hide show
  1. wake.py +148 -0
wake.py ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2023 The BizzAI and HuggingFace Datasets Authors and the current dataset script contributor.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+
11
+
12
+ import csv
13
+ import os
14
+
15
+ import datasets
16
+
17
+ logger = datasets.logging.get_logger(__name__)
18
+
19
+
20
+ """ BizzBuddy AI Dataset"""
21
+
22
+ _CITATION = """\
23
+ @article{gerz2021multilingual,
24
+ title={Wake word data for Voice assistant trigger in English from spoken data},
25
+ author={Ahmed, Nicholas},
26
+ year={2023}
27
+ }
28
+ """
29
+
30
+ _DESCRIPTION = """\
31
+ Wake is training and evaluation resource for wake word
32
+ detection task with spoken data. It covers the wake and not wake
33
+ intents collected from a multiple participants who agreed to contribute to the development
34
+ of the system on the wake word and the not wake words is a subset of the common voice and speech commands dataset.
35
+ """
36
+
37
+ _ALL_CONFIGS = sorted([
38
+ "en-US"
39
+ ])
40
+
41
+
42
+ _DESCRIPTION = "Wake is a dataset for the wake word detection task with spoken data."
43
+
44
+
45
+ _DATA_URL = "https://www.dropbox.com/scl/fi/s706vku3nhl0bebukkrbk/data.zip?rlkey=ju2hz6jvae5nmd3rfry27vzgx&dl=0"
46
+
47
+
48
+ class WakeConfig(datasets.BuilderConfig):
49
+ """BuilderConfig for xtreme-s"""
50
+
51
+ def __init__(
52
+ self, name, description, data_url
53
+ ):
54
+ super(WakeConfig, self).__init__(
55
+ name=self.name,
56
+ version=datasets.Version("1.0.0", ""),
57
+ description=self.description,
58
+ )
59
+ self.name = name
60
+ self.description = description
61
+ self.data_url = data_url
62
+
63
+
64
+ def _build_config(name):
65
+ return WakeConfig(
66
+ name=name,
67
+ description=_DESCRIPTION,
68
+ data_url=_DATA_URL,
69
+ )
70
+
71
+
72
+ class Minds14(datasets.GeneratorBasedBuilder):
73
+
74
+ DEFAULT_WRITER_BATCH_SIZE = 1000
75
+ BUILDER_CONFIGS = [_build_config(name) for name in _ALL_CONFIGS + ["all"]]
76
+
77
+ def _info(self):
78
+ task_templates = None
79
+ langs = _ALL_CONFIGS
80
+ features = datasets.Features(
81
+ {
82
+ "path": datasets.Value("string"),
83
+ "audio": datasets.Audio(sampling_rate=8_000),
84
+ "wake": datasets.ClassLabel(
85
+ names=[
86
+ 0,
87
+ 1,
88
+ ]
89
+ ),
90
+ "lang_id": datasets.ClassLabel(names=langs),
91
+ }
92
+ )
93
+
94
+ return datasets.DatasetInfo(
95
+ description=_DESCRIPTION,
96
+ features=features,
97
+ supervised_keys=("audio", "transcription"),
98
+ citation=_CITATION,
99
+ task_templates=task_templates,
100
+ )
101
+
102
+ def _split_generators(self, dl_manager):
103
+ langs = (
104
+ _ALL_CONFIGS
105
+ if self.config.name == "all"
106
+ else [self.config.name]
107
+ )
108
+
109
+ archive_path = dl_manager.download_and_extract(self.config.data_url)
110
+ audio_path = dl_manager.extract(
111
+ os.path.join(archive_path, "data", "data.rar")
112
+ )
113
+ text_path = dl_manager.extract(
114
+ os.path.join(archive_path, "data", "text.zip")
115
+ )
116
+
117
+ text_path = {l: os.path.join(text_path, f"{l}.csv") for l in langs}
118
+
119
+ return [
120
+ datasets.SplitGenerator(
121
+ name=datasets.Split.TRAIN,
122
+ gen_kwargs={
123
+ "audio_path": audio_path,
124
+ "text_paths": text_path,
125
+ },
126
+ )
127
+ ]
128
+
129
+
130
+ def _generate_examples(self, audio_path, text_paths):
131
+ key = 0
132
+ for lang in text_paths.keys():
133
+ text_path = text_paths[lang]
134
+ with open(text_path, encoding="utf-8") as csv_file:
135
+ csv_reader = csv.reader(csv_file, delimiter=",", skipinitialspace=True)
136
+ next(csv_reader)
137
+ for row in csv_reader:
138
+ file_path, intent_class = row
139
+
140
+ file_path = os.path.join(audio_path, *file_path.split("/"))
141
+ yield key, {
142
+ "path": file_path,
143
+ "audio": file_path,
144
+ "wake": intent_class,
145
+ "lang_id": _ALL_CONFIGS.index(lang),
146
+ }
147
+ key += 1
148
+