Update jv_id_asr_split.py

#2
Files changed (1) hide show
  1. 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
- 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()
 
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()