CoolFace
Modelpublic

bhriguverma/speech-data-factory

sourceHugging Faceupdated 4mo agoView on Hugging Face
0likes
Model Card

๐ŸŽ™๏ธ 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

text
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

  1. 1.Clone the Repository and navigate to the directory:
bash
    git clone https://huggingface.co/bhriguverma/speech-data-factory
    cd speech-data-factory
  1. 1.Install the package in editable mode (this installs all dependencies and registers the voice-pipeline command):
bash
    pip install -e .
  1. 1.Set up HuggingFace authorization (required for gated models like Pyannote Diarization 3.1):
bash
    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.):

bash
# 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 podcast

2. Process a YouTube Video URL

Download and process a single YouTube video:

bash
voice-pipeline run-youtube "https://www.youtube.com/watch?v=dQw4w9WgXcQ" --lang hi --type storytelling

3. Process an Entire YouTube Playlist

Batch download and process a storytelling playlist (capping at 10 videos):

bash
voice-pipeline run-playlist "https://www.youtube.com/playlist?list=PL..." --max-videos 10 --lang hi --type audiobook

4. Check Checkpoint Statistics

View completion rates and failures per stage:

bash
voice-pipeline show-stats

5. Reset Checkpoints

Force a clean re-run of a stage or the whole pipeline:

bash
# 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_:

bash
# 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:

  1. 1.JSON Manifest: data/exports/segments.jsonl contains detailed records for every valid segment, including start/end times, speaker ID, emotion, style, transcripts, and SNR.
  2. 2.Dataset CSV: data/exports/annotations.csv provides a flat tabular spreadsheet view of the dataset.
  3. 3.Analytics Dashboard: data/reports/quality_report.json details pass rates, emotion, and speaker distributions.
  4. 4.Plots: Distribution plots (emotion_distribution.png, speaker_distribution.png, rejection_distribution.png) are generated under data/reports/.