Fathan
commited on
Commit
·
a02d16d
1
Parent(s):
d5ee35b
fix url
Browse files- .gitignore +1 -0
- generate_dataset.py +9 -0
- su_id_asr.py +34 -16
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
env
|
generate_dataset.py
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from datasets import load_dataset
|
2 |
+
|
3 |
+
# Menggunakan dataset builder yang telah disiapkan
|
4 |
+
dataset = load_dataset("./su_id_asr.py", split='train', trust_remote_code=True)
|
5 |
+
dataset = load_dataset("./su_id_asr.py", split='validation', trust_remote_code=True)
|
6 |
+
dataset = load_dataset("./su_id_asr.py", split='test', trust_remote_code=True)
|
7 |
+
|
8 |
+
# Cetak beberapa contoh dari split train
|
9 |
+
print(dataset[0])
|
su_id_asr.py
CHANGED
@@ -38,9 +38,13 @@ _HOMEPAGE = "https://indonlp.github.io/nusa-catalogue/card.html?su_id_asr"
|
|
38 |
_LICENSE = "Attribution-ShareAlike 4.0 International."
|
39 |
|
40 |
_URLs = {
|
41 |
-
"
|
|
|
|
|
42 |
}
|
43 |
|
|
|
|
|
44 |
_SUPPORTED_TASKS = [Tasks.SPEECH_RECOGNITION]
|
45 |
|
46 |
_SOURCE_VERSION = "1.0.0"
|
@@ -89,38 +93,51 @@ class SuIdASR(datasets.GeneratorBasedBuilder):
|
|
89 |
homepage=_HOMEPAGE,
|
90 |
license=_LICENSE,
|
91 |
citation=_CITATION,
|
92 |
-
task_templates=[datasets.AutomaticSpeechRecognition(audio_column="audio", transcription_column="text")],
|
93 |
)
|
94 |
|
95 |
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
|
|
101 |
return [
|
102 |
datasets.SplitGenerator(
|
103 |
name=datasets.Split.TRAIN,
|
104 |
-
gen_kwargs={"filepath":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
),
|
106 |
]
|
107 |
|
108 |
-
def _generate_examples(self, filepath: Dict):
|
109 |
|
110 |
-
if self.config.schema == "source" or self.config.schema == "seacrowd_sptext":
|
111 |
|
|
|
|
|
|
|
|
|
|
|
112 |
for key, each_filepath in filepath.items():
|
113 |
-
|
114 |
tsv_file = os.path.join(each_filepath, "asr_sundanese", "utt_spk_text.tsv")
|
115 |
-
|
116 |
with open(tsv_file, "r") as file:
|
117 |
tsv_file = csv.reader(file, delimiter="\t")
|
118 |
-
|
119 |
for line in tsv_file:
|
120 |
audio_id, speaker_id, transcription_text = line[0], line[1], line[2]
|
121 |
-
|
|
|
122 |
wav_path = os.path.join(each_filepath, "asr_sundanese", "data", "{}".format(audio_id[:2]), "{}.flac".format(audio_id))
|
123 |
-
|
124 |
if os.path.exists(wav_path):
|
125 |
if self.config.schema == "source":
|
126 |
ex = {
|
@@ -129,6 +146,7 @@ class SuIdASR(datasets.GeneratorBasedBuilder):
|
|
129 |
"path": wav_path,
|
130 |
"audio": wav_path,
|
131 |
"text": transcription_text,
|
|
|
132 |
}
|
133 |
yield audio_id, ex
|
134 |
elif self.config.schema == "seacrowd_sptext":
|
@@ -142,8 +160,8 @@ class SuIdASR(datasets.GeneratorBasedBuilder):
|
|
142 |
"speaker_age": None,
|
143 |
"speaker_gender": None,
|
144 |
},
|
|
|
145 |
}
|
146 |
yield audio_id, ex
|
147 |
-
|
148 |
else:
|
149 |
raise ValueError(f"Invalid config: {self.config.name}")
|
|
|
38 |
_LICENSE = "Attribution-ShareAlike 4.0 International."
|
39 |
|
40 |
_URLs = {
|
41 |
+
"train": "https://univindonesia-my.sharepoint.com/personal/fathan_naufal_office_ui_ac_id/_layouts/15/download.aspx?share=EXnxiynWF0BBhhJS7_1xPT4BInHRARnyP4nqbpLOZwKuLg",
|
42 |
+
"validation": "https://univindonesia-my.sharepoint.com/personal/fathan_naufal_office_ui_ac_id/_layouts/15/download.aspx?SourceUrl=/personal/fathan_naufal_office_ui_ac_id/Documents/ES0-kCylYWtDqlpGq428pJYBK4u83a53Dl_zLmY7tg9ycw?e=PqW0tX",
|
43 |
+
"test": "https://univindonesia-my.sharepoint.com/personal/fathan_naufal_office_ui_ac_id/_layouts/15/download.aspx?SourceUrl=/personal/fathan_naufal_office_ui_ac_id/Documents/EfNmlx62QRVDrBmCRxQvgzEB13AqeJNESYy_pSbjVZV9yg?e=VU2g90",
|
44 |
}
|
45 |
|
46 |
+
|
47 |
+
|
48 |
_SUPPORTED_TASKS = [Tasks.SPEECH_RECOGNITION]
|
49 |
|
50 |
_SOURCE_VERSION = "1.0.0"
|
|
|
93 |
homepage=_HOMEPAGE,
|
94 |
license=_LICENSE,
|
95 |
citation=_CITATION,
|
96 |
+
# task_templates=[datasets.AutomaticSpeechRecognition(audio_column="audio", transcription_column="text")],
|
97 |
)
|
98 |
|
99 |
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
|
100 |
+
# Mengunduh dataset dari tiga tautan yang berbeda (train, validation, test)
|
101 |
+
train_path = dl_manager.download_and_extract(_URLs["train"])
|
102 |
+
validation_path = dl_manager.download_and_extract(_URLs["validation"])
|
103 |
+
test_path = dl_manager.download_and_extract(_URLs["test"])
|
104 |
+
|
105 |
+
# Membagi dataset ke dalam split train, validation, dan test
|
106 |
return [
|
107 |
datasets.SplitGenerator(
|
108 |
name=datasets.Split.TRAIN,
|
109 |
+
gen_kwargs={"filepath": train_path, "split": "train"},
|
110 |
+
),
|
111 |
+
datasets.SplitGenerator(
|
112 |
+
name=datasets.Split.VALIDATION,
|
113 |
+
gen_kwargs={"filepath": validation_path, "split": "validation"},
|
114 |
+
),
|
115 |
+
datasets.SplitGenerator(
|
116 |
+
name=datasets.Split.TEST,
|
117 |
+
gen_kwargs={"filepath": test_path, "split": "test"},
|
118 |
),
|
119 |
]
|
120 |
|
|
|
121 |
|
|
|
122 |
|
123 |
+
def _generate_examples(self, filepath: Dict, split: str):
|
124 |
+
"""
|
125 |
+
Generate examples from the dataset, supporting multiple splits (train, validation, test).
|
126 |
+
"""
|
127 |
+
if self.config.schema == "source" or self.config.schema == "seacrowd_sptext":
|
128 |
for key, each_filepath in filepath.items():
|
129 |
+
|
130 |
tsv_file = os.path.join(each_filepath, "asr_sundanese", "utt_spk_text.tsv")
|
131 |
+
|
132 |
with open(tsv_file, "r") as file:
|
133 |
tsv_file = csv.reader(file, delimiter="\t")
|
134 |
+
|
135 |
for line in tsv_file:
|
136 |
audio_id, speaker_id, transcription_text = line[0], line[1], line[2]
|
137 |
+
|
138 |
+
# Menentukan path untuk file audio
|
139 |
wav_path = os.path.join(each_filepath, "asr_sundanese", "data", "{}".format(audio_id[:2]), "{}.flac".format(audio_id))
|
140 |
+
|
141 |
if os.path.exists(wav_path):
|
142 |
if self.config.schema == "source":
|
143 |
ex = {
|
|
|
146 |
"path": wav_path,
|
147 |
"audio": wav_path,
|
148 |
"text": transcription_text,
|
149 |
+
"split": split, # Menyimpan info split
|
150 |
}
|
151 |
yield audio_id, ex
|
152 |
elif self.config.schema == "seacrowd_sptext":
|
|
|
160 |
"speaker_age": None,
|
161 |
"speaker_gender": None,
|
162 |
},
|
163 |
+
"split": split, # Menyimpan info split
|
164 |
}
|
165 |
yield audio_id, ex
|
|
|
166 |
else:
|
167 |
raise ValueError(f"Invalid config: {self.config.name}")
|