bhriguverma/speech-data-factory
๐๏ธ High-Fidelity Voice AI Dataset Pipeline
An industrial-strength, production-grade speech data factory designed for building expressive Text-to-Speech (TTS), Dubbing, and Voice AI training datasets. This system automatically ingests, normalizes, segments, diarizes, tags, validates, and exports raw audio and video data into clean, training-ready speech corpora.
๐๏ธ Pipeline Architecture
The pipeline executes a series of decoupled, modular stages. Each stage supports pluggable backends and state checkpoints for fault tolerance, resumability, and idempotence. <p align="center"> <img src="./architecture.png" alt="Voice AI Dataset Pipeline Architecture" width="100%"> </p>
๐ Key Features
- Idempotency & Resumability: Every stage uses file-based checkpoints. If a run crashes or is stopped, re-running the command skips already-completed files.
- Model-Agnostic Interfaces: Abstract base classes define VAD (
VadBackend), Diarization (DiarizationBackend), Emotion Tagging (EmotionBackend), and ASR (AsrBackend) backends. Swap between models easily. - Fault-Tolerant Processing: Individual file processing failures are isolated. If one audio file fails at a stage, the pipeline logs the failure, updates checkpoints, and moves to the next file without crashing.
- Production Logging: Emits dual console logging (Rich interactive console logs) and file logging (structured JSON log lines for Kibana/Grafana monitoring).
- Quality QA Guardrails: Filters training data based on signal metrics (clipping ratio, Signal-to-Noise Ratio (SNR), silence-to-speech ratio) and ML model confidence scores.
- Diverse Export Formats: Exports datasets in
segments.jsonl(standard manifest),annotations.csv,diarization.rttm, and HuggingFace-compatible dataset manifests, along with copied Wav files.
๐ Repository Structure
voice_ai_pipeline/
โโโ pyproject.toml # Package configurations & CLI declaration
โโโ README.md # Repository Card / Documentation
โโโ voice_pipeline/ # Core Package
โ โโโ __init__.py
โ โโโ pipeline.py # Master pipeline orchestrator
โ โโโ ingestion/ # Ingestion & YouTube download
โ โโโ audio_processing/ # Normalization & DSP preprocessing
โ โโโ speech_activity/ # Voice Activity Detection (VAD)
โ โโโ diarization/ # Speaker turn clustering & mapping
โ โโโ emotion_tagging/ # Speech style & emotion classification
โ โโโ asr/ # Whisper transcription & alignment
โ โโโ validation/ # DSP & quality assurance validator
โ โโโ export/ # Manifest & dataset generation
โ โโโ reports/ # Summary metrics & analytics plots
โ โโโ utils/ # Logging, checkpoints, & helper scripts
โ โโโ configs/ # Configuration YAML & sources catalog
โ โโโ cli/ # Typer CLI application
โโโ tests/ # Test Suite
โ โโโ unit/
โโโ data/ # Local storage (created at runtime)
โโโ raw/ # Downloaded raw audio files
โโโ processed/ # Normalized WAV files
โโโ segments/ # Split speech segment WAV files
โโโ exports/ # Final exported manifests & WAVs
โโโ reports/ # HTML/JSON reports & plots๐ ๏ธ Installation & Setup
- Clone the Repository and navigate to the directory:
git clone https://huggingface.co/bhriguverma/speech-data-factory
cd speech-data-factory- Install the package in editable mode (this installs all dependencies and registers the
voice-pipelinecommand):
pip install -e .- Set up HuggingFace authorization (required for gated models like Pyannote Diarization 3.1):
export HF_TOKEN="your_huggingface_write_token"๐ป CLI Usage Examples
The pipeline installs a command-line tool voice-pipeline. You can run commands directly:
1. Process a Local File or Directory
Run the pipeline on a single audio file or directory of media files (MP3, WAV, MP4, MKV, etc.):
# Run on single file
voice-pipeline run-local data/my_audio.mp3 --lang hi --type audiobook
# Run on directory of files
voice-pipeline run-local /workspace/media_folder/ --lang hi --type podcast2. Process a YouTube Video URL
Download and process a single YouTube video:
voice-pipeline run-youtube "https://www.youtube.com/watch?v=dQw4w9WgXcQ" --lang hi --type storytelling3. Process an Entire YouTube Playlist
Batch download and process a storytelling playlist (capping at 10 videos):
voice-pipeline run-playlist "https://www.youtube.com/playlist?list=PL..." --max-videos 10 --lang hi --type audiobook4. Check Checkpoint Statistics
View completion rates and failures per stage:
voice-pipeline show-stats5. Reset Checkpoints
Force a clean re-run of a stage or the whole pipeline:
# Reset VAD stage only
voice-pipeline reset-checkpoints --stage vad
# Reset all stages
voice-pipeline reset-checkpointsโ๏ธ Configuration
Runtime overrides can be configured directly in voice_pipeline/configs/pipeline_config.yaml. You can also override parameters using environment variables prefixed with VOICE_:
# Force target sample rate to 22.05kHz and run on CPU
export VOICE_AUDIO_TARGET_SAMPLE_RATE=22050
export VOICE_PIPELINE_DEVICE=cpu
voice-pipeline run-local data/audio.mp3๐ Quality Reporting & Outputs
At the end of a run, the pipeline exports:
- JSON Manifest:
data/exports/segments.jsonlcontains detailed records for every valid segment, including start/end times, speaker ID, emotion, style, transcripts, and SNR. - Dataset CSV:
data/exports/annotations.csvprovides a flat tabular spreadsheet view of the dataset. - Analytics Dashboard:
data/reports/quality_report.jsondetails pass rates, emotion, and speaker distributions. - Plots: Distribution plots (
emotion_distribution.png,speaker_distribution.png,rejection_distribution.png) are generated underdata/reports/.
