MCPcopy Create free account
hub / github.com/allenai/OLMoASR / LibrispeechLoader

Class LibrispeechLoader

scripts/eval/eval.py:320–371  ·  view source on GitHub ↗

Dataset loader for LibriSpeech test sets. LibriSpeech is a large corpus of approximately 1000 hours of English speech derived from LibriVox audiobooks. This loader handles both 'test-clean' and 'test-other' evaluation subsets. Dataset Structure: - Audio files in FLAC format

Source from the content-addressed store, hash-verified

318
319
320class LibrispeechLoader(BaseDatasetLoader):
321 """Dataset loader for LibriSpeech test sets.
322
323 LibriSpeech is a large corpus of approximately 1000 hours of English speech
324 derived from LibriVox audiobooks. This loader handles both 'test-clean' and
325 'test-other' evaluation subsets.
326
327 Dataset Structure:
328 - Audio files in FLAC format organized by speaker/chapter
329 - Transcript files (.txt) contain utterance ID and normalized text
330 - Standard format: SPEAKER-CHAPTER-UTTERANCE_ID transcript_text
331
332 Returns:
333 Tuple of audio file paths and corresponding transcript texts
334
335 Reference:
336 Panayotov, V., et al. "Librispeech: an ASR corpus based on public domain audio books."
337 """
338
339 def load(self) -> Tuple[list, list]:
340 """Load LibriSpeech audio files and transcripts.
341
342 Recursively searches for transcript files and maps them to corresponding
343 FLAC audio files using the LibriSpeech naming convention.
344
345 Returns:
346 Tuple[list, list]: A tuple containing:
347 - List of audio file paths (FLAC format)
348 - List of corresponding transcript strings
349 """
350 transcript_files = []
351 audio_text = {}
352
353 for root, _, files in os.walk(self.root_dir):
354 transcript_files.extend(
355 os.path.join(root, file) for file in files if file.endswith(".txt")
356 )
357
358 for file in sorted(transcript_files):
359 with open(file, "r") as f:
360 for line in f:
361 parts = line.split(" ")
362 audio_codes = parts[0].split("-")
363 audio_file = os.path.join(
364 self.root_dir,
365 audio_codes[0],
366 audio_codes[1],
367 f"{audio_codes[0]}-{audio_codes[1]}-{audio_codes[2]}.flac",
368 )
369 audio_text[audio_file] = " ".join(parts[1:]).strip()
370
371 return list(audio_text.keys()), list(audio_text.values())
372
373
374class ArtieBiasCorpusLoader(BaseDatasetLoader):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected