retineo commited on
Commit
8df0e31
·
verified ·
1 Parent(s): cf23fc4
Files changed (1) hide show
  1. jv_id_asr_split +154 -0
jv_id_asr_split ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2022 The 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
+ # 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
+ import csv
17
+ import os
18
+ from pathlib import Path
19
+ from typing import List
20
+
21
+ import datasets
22
+
23
+ from seacrowd.utils import schemas
24
+ from seacrowd.utils.configs import SEACrowdConfig
25
+ from seacrowd.utils.constants import Tasks
26
+
27
+ _CITATION = """\
28
+ @inproceedings{kjartansson-etal-sltu2018,
29
+ title = {{Crowd-Sourced Speech Corpora for Javanese, Sundanese, Sinhala, Nepali, and Bangladeshi Bengali}},
30
+ author = {Oddur Kjartansson and Supheakmungkol Sarin and Knot Pipatsrisawat and Martin Jansche and Linne Ha},
31
+ booktitle = {Proc. The 6th Intl. Workshop on Spoken Language Technologies for Under-Resourced Languages (SLTU)},
32
+ year = {2018},
33
+ address = {Gurugram, India},
34
+ month = aug,
35
+ pages = {52--55},
36
+ URL = {http://dx.doi.org/10.21437/SLTU.2018-11},
37
+ }
38
+ """
39
+
40
+ _DATASETNAME = "jv_id_asr"
41
+
42
+ _DESCRIPTION = """\
43
+ This data set contains transcribed audio data for Javanese. The data set consists of wave files, and a TSV file.
44
+ The file utt_spk_text.tsv contains a FileID, UserID and the transcription of audio in the file.
45
+ The data set has been manually quality checked, but there might still be errors.
46
+ This dataset was collected by Google in collaboration with Reykjavik University and Universitas Gadjah Mada in Indonesia.
47
+ """
48
+
49
+ _HOMEPAGE = "http://openslr.org/35/"
50
+ _LANGUAGES = ["jav"]
51
+ _LOCAL = False
52
+
53
+ _LICENSE = "Attribution-ShareAlike 4.0 International"
54
+
55
+ _URLS = {
56
+ _DATASETNAME: "https://www.openslr.org/resources/35/asr_javanese_{}.zip",
57
+ }
58
+
59
+ _SUPPORTED_TASKS = [Tasks.SPEECH_RECOGNITION] # example: [Tasks.TRANSLATION, Tasks.NAMED_ENTITY_RECOGNITION, Tasks.RELATION_EXTRACTION]
60
+
61
+ _SOURCE_VERSION = "1.0.0"
62
+
63
+ _SEACROWD_VERSION = "2024.06.20"
64
+
65
+
66
+ class JvIdASR(datasets.GeneratorBasedBuilder):
67
+ """Javanese ASR training data set containing ~185K utterances."""
68
+
69
+ SOURCE_VERSION = datasets.Version(_SOURCE_VERSION)
70
+ SEACROWD_VERSION = datasets.Version(_SEACROWD_VERSION)
71
+
72
+ BUILDER_CONFIGS = [
73
+ SEACrowdConfig(
74
+ name="jv_id_asr_source",
75
+ version=SOURCE_VERSION,
76
+ description="jv_id_asr source schema",
77
+ schema="source",
78
+ subset_id="jv_id_asr",
79
+ ),
80
+ SEACrowdConfig(
81
+ name="jv_id_asr_seacrowd_sptext",
82
+ version=SEACROWD_VERSION,
83
+ description="jv_id_asr Nusantara schema",
84
+ schema="seacrowd_sptext",
85
+ subset_id="jv_id_asr",
86
+ ),
87
+ ]
88
+
89
+ DEFAULT_CONFIG_NAME = "jv_id_asr_source"
90
+
91
+ def _info(self) -> datasets.DatasetInfo:
92
+ if self.config.schema == "source":
93
+ features = datasets.Features(
94
+ {
95
+ "id": datasets.Value("string"),
96
+ "speaker_id": datasets.Value("string"),
97
+ "path": datasets.Value("string"),
98
+ "audio": datasets.Audio(sampling_rate=16_000),
99
+ "text": datasets.Value("string"),
100
+ }
101
+ )
102
+ elif self.config.schema == "seacrowd_sptext":
103
+ features = schemas.speech_text_features
104
+
105
+ return datasets.DatasetInfo(
106
+ description=_DESCRIPTION,
107
+ features=features,
108
+ homepage=_HOMEPAGE,
109
+ license=_LICENSE,
110
+ citation=_CITATION,
111
+ )
112
+
113
+ def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
114
+ urls = _URLS[_DATASETNAME]
115
+
116
+ return [
117
+ datasets.SplitGenerator(
118
+ name=datasets.Split.TRAIN,
119
+ gen_kwargs={"filepath": dl_manager.download_and_extract(urls.format(str(0)))},
120
+ ),
121
+ ]
122
+
123
+ def _generate_examples(self, filepath: str):
124
+ tsv_file = os.path.join(filepath, "asr_javanese", "utt_spk_text.tsv")
125
+ with open(tsv_file, "r") as f:
126
+ tsv_file = csv.reader(f, delimiter="\t")
127
+ for line in tsv_file:
128
+ audio_id, sp_id, text = line[0], line[1], line[2]
129
+ wav_path = os.path.join(filepath, "asr_javanese", "data", "{}".format(audio_id[:2]), "{}.flac".format(audio_id))
130
+
131
+ if os.path.exists(wav_path):
132
+ if self.config.schema == "source":
133
+ ex = {
134
+ "id": audio_id,
135
+ "speaker_id": sp_id,
136
+ "path": wav_path,
137
+ "audio": wav_path,
138
+ "text": text,
139
+ }
140
+ yield audio_id, ex
141
+ elif self.config.schema == "seacrowd_sptext":
142
+ ex = {
143
+ "id": audio_id,
144
+ "speaker_id": sp_id,
145
+ "path": wav_path,
146
+ "audio": wav_path,
147
+ "text": text,
148
+ "metadata": {
149
+ "speaker_age": None,
150
+ "speaker_gender": None,
151
+ },
152
+ }
153
+ yield audio_id, ex
154
+ f.close()