Bagas Shalahuddin Wahid commited on
Commit
a59ece3
·
1 Parent(s): ad43f0c

fix: full dataset

Browse files
Files changed (4) hide show
  1. README.md +9 -0
  2. __init__.py +0 -0
  3. jv_id_asr_split.py +176 -0
  4. requirements.txt +2 -0
README.md ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - jav
4
+ pretty_name: Jv Id Asr
5
+ task_categories:
6
+ - speech-recognition
7
+ tags:
8
+ - speech-recognition
9
+ ---
__init__.py ADDED
File without changes
jv_id_asr_split.py ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "jv_id_asr_train": "https://drive.google.com/file/d/1-9hocMVgjPYD02VX0q3H6Yp51vq9-fD7/view?usp=sharing",
57
+ "jv_id_asr_dev": "https://drive.google.com/file/d/1-Lj-dEE7xpAx_DsLDAipV-I-AVPB68lI/view?usp=sharing",
58
+ "jv_id_asr_test": "https://drive.google.com/file/d/1-9hbOozqvvOM_8he0pEG6aht2VEZcsNb/view?usp=sharing",
59
+ }
60
+
61
+ _SUPPORTED_TASKS = [Tasks.SPEECH_RECOGNITION] # example: [Tasks.TRANSLATION, Tasks.NAMED_ENTITY_RECOGNITION, Tasks.RELATION_EXTRACTION]
62
+
63
+ _SOURCE_VERSION = "1.0.0"
64
+
65
+ _SEACROWD_VERSION = "2024.06.20"
66
+
67
+ def download_from_gdrive(url, output_dir):
68
+ """Download a file from Google Drive and save it to the specified directory."""
69
+ file_id = url.split("/d/")[-1].split("/")[0] # Extract FILE_ID from URL
70
+ gdrive_url = f"https://drive.google.com/uc?id={file_id}"
71
+ output_path = os.path.join(output_dir, f"{file_id}.zip") # Save file
72
+ gdown.download(gdrive_url, output_path, quiet=False)
73
+ return output_path
74
+
75
+
76
+ class JvIdASR(datasets.GeneratorBasedBuilder):
77
+ """Javanese ASR training data set containing ~185K utterances."""
78
+
79
+ SOURCE_VERSION = datasets.Version(_SOURCE_VERSION)
80
+ SEACROWD_VERSION = datasets.Version(_SEACROWD_VERSION)
81
+
82
+ BUILDER_CONFIGS = [
83
+ SEACrowdConfig(
84
+ name="jv_id_asr_source",
85
+ version=SOURCE_VERSION,
86
+ description="jv_id_asr source schema",
87
+ schema="source",
88
+ subset_id="jv_id_asr",
89
+ ),
90
+ SEACrowdConfig(
91
+ name="jv_id_asr_seacrowd_sptext",
92
+ version=SEACROWD_VERSION,
93
+ description="jv_id_asr Nusantara schema",
94
+ schema="seacrowd_sptext",
95
+ subset_id="jv_id_asr",
96
+ ),
97
+ ]
98
+
99
+ DEFAULT_CONFIG_NAME = "jv_id_asr_source"
100
+
101
+ def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
102
+ # Check if dataset URL is from Google Drive
103
+ def get_dataset_path(url):
104
+ if "drive.google.com" in url and url.strip():
105
+ return download_from_gdrive(url, dl_manager.download_dir)
106
+ return dl_manager.download_and_extract(url)
107
+
108
+ return [
109
+ datasets.SplitGenerator(
110
+ name=datasets.Split.TRAIN,
111
+ gen_kwargs={"filepath": get_dataset_path(_URLs["jv_id_asr_train"], "train")},
112
+ ),
113
+ datasets.SplitGenerator(
114
+ name=datasets.Split.VALIDATION,
115
+ gen_kwargs={"filepath": get_dataset_path(_URLs["jv_id_asr_dev"], "dev")},
116
+ ),
117
+ datasets.SplitGenerator(
118
+ name=datasets.Split.TEST,
119
+ gen_kwargs={"filepath": get_dataset_path(_URLs["jv_id_asr_test"], "test")},
120
+ ),
121
+ ]
122
+
123
+ def _info(self) -> datasets.DatasetInfo:
124
+ if self.config.schema == "source":
125
+ features = datasets.Features(
126
+ {
127
+ "id": datasets.Value("string"),
128
+ "speaker_id": datasets.Value("string"),
129
+ "path": datasets.Value("string"),
130
+ "audio": datasets.Audio(sampling_rate=16_000),
131
+ "text": datasets.Value("string"),
132
+ }
133
+ )
134
+ elif self.config.schema == "seacrowd_sptext":
135
+ features = schemas.speech_text_features
136
+
137
+ return datasets.DatasetInfo(
138
+ description=_DESCRIPTION,
139
+ features=features,
140
+ homepage=_HOMEPAGE,
141
+ license=_LICENSE,
142
+ citation=_CITATION,
143
+ )
144
+
145
+ def _generate_examples(self, filepath: str):
146
+ tsv_file = os.path.join(filepath, "asr_javanese", "utt_spk_text.tsv")
147
+ with open(tsv_file, "r") as f:
148
+ tsv_file = csv.reader(f, delimiter="\t")
149
+ for line in tsv_file:
150
+ audio_id, sp_id, text = line[0], line[1], line[2]
151
+ wav_path = os.path.join(filepath, "asr_javanese", "data", "{}".format(audio_id[:2]), "{}.flac".format(audio_id))
152
+
153
+ if os.path.exists(wav_path):
154
+ if self.config.schema == "source":
155
+ ex = {
156
+ "id": audio_id,
157
+ "speaker_id": sp_id,
158
+ "path": wav_path,
159
+ "audio": wav_path,
160
+ "text": text,
161
+ }
162
+ yield audio_id, ex
163
+ elif self.config.schema == "seacrowd_sptext":
164
+ ex = {
165
+ "id": audio_id,
166
+ "speaker_id": sp_id,
167
+ "path": wav_path,
168
+ "audio": wav_path,
169
+ "text": text,
170
+ "metadata": {
171
+ "speaker_age": None,
172
+ "speaker_gender": None,
173
+ },
174
+ }
175
+ yield audio_id, ex
176
+ f.close()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ seacrowd>=0.2.0
2
+ gdown