w11wo commited on
Commit
b2a420e
1 Parent(s): e68bac0

Update Dataloader for Clean Versions

Browse files
Files changed (1) hide show
  1. OpenBible_Swahili.py +7 -1
OpenBible_Swahili.py CHANGED
@@ -103,7 +103,7 @@ class OpenBible_Swahili(datasets.GeneratorBasedBuilder):
103
  name=book,
104
  version=datasets.Version("1.1.0"),
105
  )
106
- for book in BOOKS + ["default"]
107
  ]
108
 
109
  def _info(self):
@@ -129,6 +129,8 @@ class OpenBible_Swahili(datasets.GeneratorBasedBuilder):
129
  def _split_generators(self, dl_manager):
130
  if self.config.name == "default":
131
  archive_paths = [dl_manager.download_and_extract(f"{_DATA_URL}/{book}.tar.gz") for book in BOOKS]
 
 
132
  else:
133
  archive_paths = [dl_manager.download_and_extract(f"{_DATA_URL}/{self.config.name}.tar.gz")]
134
 
@@ -155,6 +157,10 @@ class OpenBible_Swahili(datasets.GeneratorBasedBuilder):
155
  book_chapter = f"{book}_{chapter.zfill(3)}"
156
  book_chapter_verse = f"{book_chapter}_{verse_number.zfill(3)}"
157
  audio_path = (path / book / book_chapter / book_chapter_verse).with_suffix(".wav")
 
 
 
 
158
  transcript_path = audio_path.with_suffix(".txt")
159
  with open(transcript_path) as f:
160
  transcript = f.read().strip()
 
103
  name=book,
104
  version=datasets.Version("1.1.0"),
105
  )
106
+ for book in BOOKS + [f"{_book}_clean" for _book in BOOKS] + ["default", "clean"]
107
  ]
108
 
109
  def _info(self):
 
129
  def _split_generators(self, dl_manager):
130
  if self.config.name == "default":
131
  archive_paths = [dl_manager.download_and_extract(f"{_DATA_URL}/{book}.tar.gz") for book in BOOKS]
132
+ elif self.config.name == "clean":
133
+ archive_paths = [dl_manager.download_and_extract(f"{_DATA_URL}/{book}_clean.tar.gz") for book in BOOKS]
134
  else:
135
  archive_paths = [dl_manager.download_and_extract(f"{_DATA_URL}/{self.config.name}.tar.gz")]
136
 
 
157
  book_chapter = f"{book}_{chapter.zfill(3)}"
158
  book_chapter_verse = f"{book_chapter}_{verse_number.zfill(3)}"
159
  audio_path = (path / book / book_chapter / book_chapter_verse).with_suffix(".wav")
160
+ # skip if audio file does not exist, e.g. audio not included in clean data after filtering
161
+ if not audio_path.exists():
162
+ continue
163
+
164
  transcript_path = audio_path.with_suffix(".txt")
165
  with open(transcript_path) as f:
166
  transcript = f.read().strip()