Audio Dataset Preparation Guide

July 7, 2025 ยท View on GitHub

This guide walks you through the process of preparing audio datasets (LibriSpeech and TIMIT) for model training, including the generation of aligned transcriptions using a pre-trained Wav2Vec2 model. The output is a structured manifest directory ready for use in downstream training tasks.


๐Ÿš€ Overview

The provided script performs the following steps:

  1. Scans audio files under the provided dataset roots.
  2. Optionally aligns transcriptions using facebook/wav2vec2-base-960h.
  3. Saves audio metadata and alignment files to a manifest directory.

The output will contain:

  • *.jsonl files for train, dev, and test splits
  • A transcriptions_alignment/ directory with aligned character timestamps

๐Ÿ“ฅ Dataset Download

You must manually download and extract the datasets before using the script.

DatasetLink
LibriSpeechOfficial Site
TIMITLDC Catalog (LDC93S1) (licensed)

๐Ÿ“‚ Directory Structure

Expected input structure:

<LibriSpeech_root>/train-clean-100/...
<TIMIT_root>/TRAIN/DR1/...

Output structure:

<output_dir>/
โ”œโ”€โ”€ LibriSpeech_train.jsonl
โ”œโ”€โ”€ LibriSpeech_dev.jsonl
โ”œโ”€โ”€ LibriSpeech_test.jsonl
โ”œโ”€โ”€ timit_train.jsonl
โ”œโ”€โ”€ timit_test.jsonl
โ””โ”€โ”€ transcriptions_alignment/
    โ””โ”€โ”€ [mirrors dataset folder structure]

โš™๏ธ Script Usage

Basic Command:

python scripts/audio_dataset_extraction.py \
  --LibriSpeech_root /path/to/LibriSpeech \
  --timit_root /path/to/TIMIT \
  --output_dir /path/to/output_dir

Parameters Explained:

ArgumentRequiredDescription
--LibriSpeech_rootโœ”Path to extracted LibriSpeech dataset
--timit_rootโœ–Path to TIMIT dataset (required for phoneme head training)
--output_dirโœ”Where to save manifest files and alignments
--skip_transcriptions_alignmentโœ–Speeds up processing, but disables auxiliary head training
--debugโœ–Limits file count for quick testing
--num_processesโœ–Number of parallel processes (default: 8)

๐Ÿง  Notes on Alignment

  • Alignment uses HuggingFace's facebook/wav2vec2-base-960h to compute character-level timestamps.
  • Alignment is required for training asr auxiliary head.
  • Skipping alignment will produce valid .jsonl metadata, but alignment files will be missing.
  • TIMIT dataset is used for phoneme classification auxiliary task.

๐Ÿ–ฅ๏ธ Performance Tips

SettingRecommendation
Machine TypeUse a machine with GPU (preferably multi-GPU)
Number of ProcessesUse a high number (e.g., 8-32) for speed
Alignment SkippedMuch faster, but no support forasr auxiliary head

โœ… Example Command With Alignment

python scripts/audio_dataset_extraction.py \
  --LibriSpeech_root /data/LibriSpeech \
  --timit_root /data/TIMIT \
  --output_dir /data/manifests \
  --num_processes 16

โšก Example Command Without Alignment

python scripts/audio_dataset_extraction.py \
  --LibriSpeech_root /data/LibriSpeech \
  --output_dir /data/manifests \
  --skip_transcriptions_alignment \
  --num_processes 16

๐Ÿ“Œ FAQ

Q: Can I run with just LibriSpeech? A: Yes. But phoneme alignment head training will not be possible.

Q: What if I skip --skip_transcriptions_alignment? A: The script will generate transcriptions using Wav2Vec2. This is slower but enables alignment-based training.

Q: What model is used for alignment? A: facebook/wav2vec2-base-960h from HuggingFace Transformers.