andybi7676 commited on
Commit
9a466db
1 Parent(s): c945bbf

add metadata and load script

Browse files
.gitattributes CHANGED
@@ -53,3 +53,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
53
  *.jpg filter=lfs diff=lfs merge=lfs -text
54
  *.jpeg filter=lfs diff=lfs merge=lfs -text
55
  *.webp filter=lfs diff=lfs merge=lfs -text
 
 
53
  *.jpg filter=lfs diff=lfs merge=lfs -text
54
  *.jpeg filter=lfs diff=lfs merge=lfs -text
55
  *.webp filter=lfs diff=lfs merge=lfs -text
56
+ train_100hr.tsv filter=lfs diff=lfs merge=lfs -text
metadata/dutch/dev.tsv ADDED
The diff for this file is too large to render. See raw diff
 
metadata/dutch/dev_small.tsv ADDED
The diff for this file is too large to render. See raw diff
 
metadata/dutch/test.tsv ADDED
The diff for this file is too large to render. See raw diff
 
metadata/dutch/train_100hr.tsv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3a7477ded2b8c1061a3a3fb7c7e5a5d2ec97f38a3fd95a5040bbcf44d126e2c8
3
+ size 14551683
metadata/french/dev.tsv ADDED
The diff for this file is too large to render. See raw diff
 
metadata/french/dev_small.tsv ADDED
The diff for this file is too large to render. See raw diff
 
metadata/french/test.tsv ADDED
The diff for this file is too large to render. See raw diff
 
metadata/french/train_100hr.tsv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:90b08e06ac50cc2ac32c32205ffcc90cc0d2df5fd7e3bf2141b7615a0765de3a
3
+ size 13320499
metadata/german/dev.tsv ADDED
The diff for this file is too large to render. See raw diff
 
metadata/german/dev_small.tsv ADDED
The diff for this file is too large to render. See raw diff
 
metadata/german/test.tsv ADDED
The diff for this file is too large to render. See raw diff
 
metadata/german/train_100hr.tsv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:64294c3711cbba9cd4f32e6f790980a90358f86bdc033205e5230feee974a833
3
+ size 14940901
metadata/italian/dev.tsv ADDED
The diff for this file is too large to render. See raw diff
 
metadata/italian/dev_small.tsv ADDED
The diff for this file is too large to render. See raw diff
 
metadata/italian/test.tsv ADDED
The diff for this file is too large to render. See raw diff
 
metadata/italian/train_100hr.tsv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8ecd6d4f3ccf75a947ffe8fb8b6a4ca1fae3f1daa5280ed25a4e8676c197b750
3
+ size 12983245
metadata/portuguese/dev.tsv ADDED
The diff for this file is too large to render. See raw diff
 
metadata/portuguese/dev_small.tsv ADDED
The diff for this file is too large to render. See raw diff
 
metadata/portuguese/test.tsv ADDED
The diff for this file is too large to render. See raw diff
 
metadata/portuguese/train_100hr.tsv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a79c049d8cd9da97fb8cad25a1d5d1a8d0b26673bcd9bd33031279bccc1000ea
3
+ size 13808013
metadata/spanish/dev.tsv ADDED
The diff for this file is too large to render. See raw diff
 
metadata/spanish/dev_small.tsv ADDED
The diff for this file is too large to render. See raw diff
 
metadata/spanish/test.tsv ADDED
The diff for this file is too large to render. See raw diff
 
metadata/spanish/train_100hr.tsv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1780f6326c50ad1da2608deeff0a1427a827f33f6740b5e9f11cd765b24938cf
3
+ size 13508394
reborn_uasr-mls_no_silence_100h.py ADDED
@@ -0,0 +1,243 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2022 The TensorFlow Datasets Authors and the HuggingFace Datasets Authors.
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
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ # Lint as: python3
17
+ """
18
+ Librispeech automatic speech recognition dataset for reproducing Reborn UASR results.
19
+ Note that the silence in each audio has been removed by performing unsupervised VAD (https://github.com/zhenghuatan/rVADfast).
20
+ We only process the 100-hour split from LibriSpeech 'train-clean-100' as the training split.
21
+ """
22
+
23
+ import os
24
+
25
+ import datasets
26
+
27
+
28
+ _CITATION = """\
29
+ @article{Pratap2020MLSAL,
30
+ title={MLS: A Large-Scale Multilingual Dataset for Speech Research},
31
+ author={Vineel Pratap and Qiantong Xu and Anuroop Sriram and Gabriel Synnaeve and Ronan Collobert},
32
+ journal={ArXiv},
33
+ year={2020},
34
+ volume={abs/2012.03411}
35
+ }
36
+ @article{tan2020rvad,
37
+ title={rVAD: An unsupervised segment-based robust voice activity detection method},
38
+ author={Tan, Zheng-Hua and Dehak, Najim and others},
39
+ journal={Computer speech \& language},
40
+ volume={59},
41
+ pages={1--21},
42
+ year={2020},
43
+ publisher={Elsevier}
44
+ }
45
+ @article{tseng2024reborn,
46
+ title={REBORN: Reinforcement-Learned Boundary Segmentation with Iterative Training for Unsupervised ASR},
47
+ author={Tseng, Liang-Hsuan and Hu, En-Pei and Chiang, Cheng-Han and Tseng, Yuan and Lee, Hung-yi and Lee, Lin-shan and Sun, Shao-Hua},
48
+ journal={arXiv preprint arXiv:2402.03988},
49
+ year={2024}
50
+ }
51
+ """
52
+
53
+ _DESCRIPTION = """\
54
+ LibriSpeech is a corpus of approximately 1000 hours of read English speech with sampling rate of 16 kHz,
55
+ prepared by Vassil Panayotov with the assistance of Daniel Povey. The data is derived from read
56
+ audiobooks from the LibriVox project, and has been carefully segmented and aligned
57
+
58
+ This dataset is the 100-hour subset of LibriSpeech 'train-clean-100' split, with silence removed.
59
+ Additionally, all the dev and test sets are included for fair comparison and evaluation if needed.
60
+ The dataset is prepared by the Reborn UASR team.
61
+ Arxiv paper link: https://arxiv.org/abs/2402.03988
62
+ """
63
+
64
+ _URL = "http://www.openslr.org/12"
65
+
66
+ _DL_URL_FORMAT = "data/{name}"
67
+
68
+
69
+ class RebornLibrispeechConfig(datasets.BuilderConfig):
70
+ """BuilderConfig for Reborn-Librispeech."""
71
+
72
+ def __init__(self, name, **kwargs):
73
+ """
74
+ Args:
75
+ name: `string`, name of dataset config (=language)
76
+ **kwargs: keyword arguments forwarded to super.
77
+ """
78
+ super(RebornLibrispeechConfig, self).__init__(
79
+ version=datasets.Version("2.12.0", ""), name=name, **kwargs
80
+ )
81
+ # relative path to full data inside a repo (for example `data/train-clean-100`)
82
+ self.data_root_url = _DL_URL_FORMAT.format(name=name)
83
+
84
+
85
+ class RebornLibrispeech(datasets.GeneratorBasedBuilder):
86
+ """Multilingual Librispeech dataset."""
87
+
88
+ BUILDER_CONFIGS = [
89
+ RebornLibrispeechConfig(name="german", description="MLS 100hr German dataset without silence"),
90
+ RebornLibrispeechConfig(name="french", description="MLS 100hr French dataset without silence"),
91
+ RebornLibrispeechConfig(name="dutch", description="MLS 100hr Dutch dataset without silence"),
92
+ RebornLibrispeechConfig(name="spanish", description="MLS 100hr Spanish dataset without silence"),
93
+ RebornLibrispeechConfig(name="italian", description="MLS 100hr Italian dataset without silence"),
94
+ RebornLibrispeechConfig(name="portuguese", description="MLS 100hr Portuguese dataset without silence"),
95
+ ]
96
+
97
+ def _info(self):
98
+ return datasets.DatasetInfo(
99
+ description=_DESCRIPTION,
100
+ features=datasets.Features(
101
+ {
102
+ "file": datasets.Value("string"),
103
+ "audio": datasets.features.Audio(sampling_rate=16_000),
104
+ "word": datasets.Value("string"),
105
+ "phoneme": datasets.Value("string"),
106
+ "speaker_id": datasets.Value("int64"),
107
+ "chapter_id": datasets.Value("int64"),
108
+ "id": datasets.Value("string"),
109
+ }
110
+ ),
111
+ supervised_keys=("file", "phone"),
112
+ homepage=_URL,
113
+ citation=_CITATION,
114
+ task_templates=None,
115
+ )
116
+
117
+ def _split_generators(self, dl_manager):
118
+
119
+ metadata = dl_manager.download({
120
+ "train_100hr": "metadata/train_100hr.tsv",
121
+ "dev": "metadata/dev.tsv",
122
+ "test": "metadata/test.tsv",
123
+ "dev_small": "metadata/dev_small.tsv",
124
+ })
125
+
126
+ all_splits = [
127
+ "train_100hr",
128
+ "dev",
129
+ "test",
130
+ ]
131
+
132
+ audio_archives = {}
133
+ for split in all_splits:
134
+ audio_archives[split] = dl_manager.download(
135
+ os.path.join(self.config.data_root_url, f"{split}.tar.gz")
136
+ )
137
+
138
+ # (Optional) In non-streaming mode, we can extract the archive locally to have actual local audio files:
139
+ local_extracted_archives = dl_manager.extract(audio_archives) if not dl_manager.is_streaming else {}
140
+
141
+ train_splits = [
142
+ datasets.SplitGenerator(
143
+ name=datasets.Split.TRAIN,
144
+ gen_kwargs={
145
+ "metadata_fpaths": [metadata["train_100hr"]],
146
+ "audio_archives": [dl_manager.iter_archive(audio_archives["train_100hr"])],
147
+ "local_extracted_archives": [local_extracted_archives.get("train_100hr")],
148
+ }
149
+ ),
150
+ datasets.SplitGenerator(
151
+ name="train.100hr",
152
+ gen_kwargs={
153
+ "metadata_fpaths": [metadata["train_100hr"]],
154
+ "audio_archives": [dl_manager.iter_archive(audio_archives["train_100hr"])],
155
+ "local_extracted_archives": [local_extracted_archives.get("train_100hr")],
156
+ }
157
+ ),
158
+ ]
159
+
160
+ dev_splits = [
161
+ datasets.SplitGenerator(
162
+ name=datasets.Split.VALIDATION,
163
+ gen_kwargs={
164
+ "metadata_fpath": [metadata["dev"]],
165
+ "audio_archives": [dl_manager.iter_archive(audio_archives["dev"])],
166
+ "local_extracted_archives": [local_extracted_archives.get("dev")],
167
+ }
168
+ ),
169
+ datasets.SplitGenerator(
170
+ name="dev",
171
+ gen_kwargs={
172
+ "metadata_fpath": [metadata["dev"]],
173
+ "audio_archives": [dl_manager.iter_archive(audio_archives["dev"])],
174
+ "local_extracted_archives": [local_extracted_archives.get("dev")],
175
+ }
176
+ ),
177
+ datasets.SplitGenerator(
178
+ name="valid",
179
+ gen_kwargs={
180
+ "metadata_fpath": [metadata["dev"]],
181
+ "audio_archives": [dl_manager.iter_archive(audio_archives["dev"])],
182
+ "local_extracted_archives": [local_extracted_archives.get("dev")],
183
+ }
184
+ ),
185
+ datasets.SplitGenerator(
186
+ name="dev.small",
187
+ gen_kwargs={
188
+ "metadata_fpaths": [metadata["dev_small"]],
189
+ "audio_archives": [dl_manager.iter_archive(audio_archives["dev"])],
190
+ "local_extracted_archives": [local_extracted_archives.get("dev")],
191
+ },
192
+ ),
193
+ ]
194
+
195
+ test_splits = [
196
+ datasets.SplitGenerator(
197
+ name=datasets.Split.TEST,
198
+ gen_kwargs={
199
+ "metadata_fpaths": [metadata["test"]],
200
+ "audio_archives": [dl_manager.iter_archive(audio_archives["test"])],
201
+ "local_extracted_archives": [local_extracted_archives.get("test")],
202
+ }
203
+ ),
204
+ ]
205
+
206
+ return train_splits + dev_splits + test_splits
207
+
208
+ def _generate_examples(self, metadata_fpaths, audio_archives, local_extracted_archives):
209
+ """Generate examples from a Multilingual LibriSpeech data dir."""
210
+ words, phones = dict(), dict()
211
+ for metadata_fpath in metadata_fpaths:
212
+ with open(metadata_fpath, "r", encoding="utf-8") as file:
213
+ for line in file:
214
+ audio_fpath, word, phone = line.strip().split("\t")
215
+ audio_id = audio_fpath.split('/')[-1].split(".flac")[0]
216
+ words[audio_id] = word
217
+ phones[audio_id] = phone
218
+
219
+ for archive_idx, audio_archive in enumerate(audio_archives):
220
+
221
+ for audio_filename, file in audio_archive:
222
+ audio_id = audio_filename.split('/')[-1].split(".flac")[0]
223
+ speaker_id, chapter_id = (int(item) for item in audio_id.split("-")[:2])
224
+ word = words.get(audio_id, None)
225
+ if word == None:
226
+ continue
227
+
228
+ local_audio_file_path = os.path.join(
229
+ local_extracted_archives[archive_idx], audio_filename
230
+ ) if local_extracted_archives[archive_idx] else None
231
+
232
+ yield audio_filename, {
233
+ "file": local_audio_file_path,
234
+ "audio": {
235
+ "path": local_audio_file_path if local_audio_file_path else audio_filename,
236
+ "bytes": file.read()
237
+ },
238
+ "word": word,
239
+ "phoneme": phones.get(audio_id, None),
240
+ "speaker_id": speaker_id,
241
+ "chapter_id": chapter_id,
242
+ "id": audio_id
243
+ }