Update jv_id_asr_split.py
#2
by
bryanjeshua
- opened
- jv_id_asr_split.py +40 -28
jv_id_asr_split.py
CHANGED
|
@@ -129,34 +129,46 @@ class JvIdASR(datasets.GeneratorBasedBuilder):
|
|
| 129 |
]
|
| 130 |
|
| 131 |
def _generate_examples(self, filepath: str):
|
| 132 |
-
tsv_file = os.path.join(filepath, "asr_javanese", "utt_spk_text.tsv")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
with open(tsv_file, "r") as f:
|
| 134 |
-
|
| 135 |
-
for line in
|
| 136 |
audio_id, sp_id, text = line[0], line[1], line[2]
|
| 137 |
-
wav_path = os.path.join(
|
| 138 |
-
|
| 139 |
-
if os.path.
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
|
|
|
|
|
|
|
|
|
| 162 |
f.close()
|
|
|
|
| 129 |
]
|
| 130 |
|
| 131 |
def _generate_examples(self, filepath: str):
|
| 132 |
+
tsv_file = os.path.join(filepath, "asr_javanese", "data", "utt_spk_text.tsv")
|
| 133 |
+
data_dir = os.path.join(filepath, "asr_javanese", "data")
|
| 134 |
+
|
| 135 |
+
# Debugging: Cek isi direktori
|
| 136 |
+
print(f"Memeriksa file TSV: {tsv_file}")
|
| 137 |
+
print(f"Isi direktori data: {os.listdir(data_dir)}")
|
| 138 |
+
|
| 139 |
+
if not os.path.isfile(tsv_file):
|
| 140 |
+
raise FileNotFoundError(f"File tidak ditemukan: {tsv_file}")
|
| 141 |
+
|
| 142 |
with open(tsv_file, "r") as f:
|
| 143 |
+
tsv_reader = csv.reader(f, delimiter="\t")
|
| 144 |
+
for line in tsv_reader:
|
| 145 |
audio_id, sp_id, text = line[0], line[1], line[2]
|
| 146 |
+
wav_path = os.path.join(data_dir, "{}.flac".format(audio_id))
|
| 147 |
+
|
| 148 |
+
if not os.path.isfile(wav_path):
|
| 149 |
+
print(f"File audio tidak ditemukan: {wav_path}")
|
| 150 |
+
continue
|
| 151 |
+
|
| 152 |
+
if self.config.schema == "source":
|
| 153 |
+
ex = {
|
| 154 |
+
"id": audio_id,
|
| 155 |
+
"speaker_id": sp_id,
|
| 156 |
+
"path": wav_path,
|
| 157 |
+
"audio": wav_path,
|
| 158 |
+
"text": text,
|
| 159 |
+
}
|
| 160 |
+
yield audio_id, ex
|
| 161 |
+
elif self.config.schema == "seacrowd_sptext":
|
| 162 |
+
ex = {
|
| 163 |
+
"id": audio_id,
|
| 164 |
+
"speaker_id": sp_id,
|
| 165 |
+
"path": wav_path,
|
| 166 |
+
"audio": wav_path,
|
| 167 |
+
"text": text,
|
| 168 |
+
"metadata": {
|
| 169 |
+
"speaker_age": None,
|
| 170 |
+
"speaker_gender": None,
|
| 171 |
+
},
|
| 172 |
+
}
|
| 173 |
+
yield audio_id, ex
|
| 174 |
f.close()
|