Update jv_id_asr_split.py

#1
Files changed (1) hide show
  1. jv_id_asr_split.py +36 -27
jv_id_asr_split.py CHANGED
@@ -130,33 +130,42 @@ class JvIdASR(datasets.GeneratorBasedBuilder):
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
- tsv_file = csv.reader(f, delimiter="\t")
135
- for line in tsv_file:
136
  audio_id, sp_id, text = line[0], line[1], line[2]
137
- wav_path = os.path.join(filepath, "asr_javanese", "data", "{}".format(audio_id[:2]), "{}.flac".format(audio_id))
138
-
139
- if os.path.exists(wav_path):
140
- if self.config.schema == "source":
141
- ex = {
142
- "id": audio_id,
143
- "speaker_id": sp_id,
144
- "path": wav_path,
145
- "audio": wav_path,
146
- "text": text,
147
- }
148
- yield audio_id, ex
149
- elif self.config.schema == "seacrowd_sptext":
150
- ex = {
151
- "id": audio_id,
152
- "speaker_id": sp_id,
153
- "path": wav_path,
154
- "audio": wav_path,
155
- "text": text,
156
- "metadata": {
157
- "speaker_age": None,
158
- "speaker_gender": None,
159
- },
160
- }
161
- yield audio_id, ex
 
 
 
 
162
  f.close()
 
130
 
131
  def _generate_examples(self, filepath: str):
132
  tsv_file = os.path.join(filepath, "asr_javanese", "utt_spk_text.tsv")
133
+
134
+ # Debugging: Cek apakah tsv_file ada
135
+ if not os.path.isfile(tsv_file):
136
+ raise FileNotFoundError(f"File tidak ditemukan: {tsv_file}")
137
+
138
  with open(tsv_file, "r") as f:
139
+ tsv_reader = csv.reader(f, delimiter="\t")
140
+ for line in tsv_reader:
141
  audio_id, sp_id, text = line[0], line[1], line[2]
142
+ wav_path = os.path.join(filepath, "asr_javanese", "data", "{}.flac".format(audio_id))
143
+
144
+ # Debugging: Cek apakah wav_path ada
145
+ if not os.path.isfile(wav_path):
146
+ print(f"File audio tidak ditemukan: {wav_path}")
147
+ continue
148
+
149
+ if self.config.schema == "source":
150
+ ex = {
151
+ "id": audio_id,
152
+ "speaker_id": sp_id,
153
+ "path": wav_path,
154
+ "audio": wav_path,
155
+ "text": text,
156
+ }
157
+ yield audio_id, ex
158
+ elif self.config.schema == "seacrowd_sptext":
159
+ ex = {
160
+ "id": audio_id,
161
+ "speaker_id": sp_id,
162
+ "path": wav_path,
163
+ "audio": wav_path,
164
+ "text": text,
165
+ "metadata": {
166
+ "speaker_age": None,
167
+ "speaker_gender": None,
168
+ },
169
+ }
170
+ yield audio_id, ex
171
  f.close()