A pipeline to process paired audio-text data for any language, suitable for fine-tuning TTS and ASR models. It enhances audio quality, segments long audio into short utterances using CTC forced alignment, filters candidate segments, then clusters speakers.
Configure the target language via align_language in configs/config.yml (e.g. kmr for Kurdish Kurmanji, eng for English). See supported language codes.
Clone the latest code:
git clone git@github.com:cikay/voice_dataset_pipeline.gitPlace dataset/raw_data_manifest.json before running the pipeline. It is a JSONL file where each line describes one audio/text pair:
{"id": "abc123", "title": "...", "audio_file": "dataset/audio/abc123.wav", "text_file": "dataset/text/abc123.txt"}The audio and text folders must contain files with the same stem so that each manifest entry can reference both.
deepfilternet requires Rust to compile. Install it before running pipenv install:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source ~/.cargo/envThen install dependencies:
pip install pipenv
pipenv shell
pipenv installIf you use runpod/pytorch:1.0.2-cu1281-torch280-ubuntu2404, keep PyTorch aligned with the image stack:
pipenv run pip install --no-cache-dir --force-reinstall torch==2.8.0 torchaudio==2.8.0 nvidia-cusparselt-cu12==0.7.1
pipenv run python -c "import torch; print(torch.__version__, torch.version.cuda)"Expected output should start with 2.8.0 and CUDA 12.8.
The pipeline is configured via configs/config.yml. Run it with:
python -m voice_dataset_pipeline.pipeline --config configs/config.yml --log-file logs/pipeline.logStages run in the order defined under the stages key in configs/config.yml.
To resume from a specific stage (skipping all preceding ones):
python -m voice_dataset_pipeline.pipeline --config configs/config.yml --from segmentation --log-file logs/pipeline.logApplies audio enhancement tools to each file. Currently supports DeepFilterNet for noise suppression.
Enhancement is conditional — each tool has run_if conditions (skip clean audio) and replace_if conditions (revert if enhancement damages the signal). Quality is measured using DNS-MOS (bak, sig, ovr, p808).
Reads from dataset/raw_data_manifest.json.
Splits long audio into short utterances using CTC forced alignment:
- Loads the MMS-300M forced alignment model (supports 1,130+ languages).
- Aligns ground truth text to audio — no ASR transcription involved.
- Maps word-level timestamps back to sentence boundaries.
- Sub-splits long sentences by
;:punctuation. - Resamples audio and saves candidate segment WAV files and
metadata.jsonltooutput_dir. - All parent metadata fields (
audio_id,title, etc.) are inherited by every segment.
| Key | Default | Description |
|---|---|---|
end_padding |
0.15 |
Silence padding after each segment end (seconds) |
sample_rate |
24000 |
Output sample rate for segment WAV files |
Runs after segmentation. Filters candidate segments by duration, word count, alignment confidence, and optional text-pattern exclusions.
| Key | Default | Description |
|---|---|---|
min_duration |
2.0 |
Minimum segment duration (seconds) |
max_duration |
15.0 |
Maximum segment duration (seconds) |
min_words |
3 |
Minimum words per segment |
min_align_score |
-7.0 |
Minimum alignment confidence score |
exclude_abbr |
true |
Exclude segments containing abbreviation-like uppercase terms |
exclude_number |
true |
Exclude segments containing digits |
Runs after filtering. Assigns a speaker_id to every segment by clustering segments by their source audio file:
- Groups segments by
audio_id. - Extracts ECAPA-TDNN embeddings (SpeechBrain) for all segments in each group.
- Computes a centroid embedding per audio file.
- Clusters audio centroids with agglomerative clustering using cosine distance.
- Assigns one
speaker_idper cluster. - Stamps
speaker_idonto all segments from that audio file.
This stage assumes each source audio file contains one reader/speaker.
| Key | Default | Description |
|---|---|---|
threshold |
0.70 |
Minimum cosine similarity for merging audio files into the same speaker cluster |
id_format |
speaker_{n:03d} |
Format string for speaker IDs |
pip install pytest
python -m pytest tests/To run a specific test file:
python -m pytest tests/segmentation/test_stage.py -vReads the speaker clustering manifest, selects explicit columns, checks that the repo doesn't already exist, then pushes to HuggingFace Hub.
python -m voice_dataset_pipeline.push_dataset \
--repo your-username/your-dataset-nameMY_HF_TOKEN must be set in .env or as an environment variable.
dataset/
├── audio/ ← input: WAV files
├── text/ ← input: text files (same stem as audio)
├── raw_data_manifest.json ← input: place before running the pipeline
├── enhanced_audio/ ← enhancement: enhanced + symlinked WAV files
├── audio_segments/ ← segmentation: segment WAV files
├── enhancement_manifest.json
├── segmentation_manifest.json
├── filter_manifest.json
├── speaker_clustering_manifest.json
└── quality_score_manifest.json