# Kikuyu TTS
A custom Text-to-Speech (TTS) training pipeline for the Kikuyu language (kik), built on the Piper TTS framework using a VITS neural architecture.
## Overview
This project trains a Kikuyu voice model by:
1. Downloading the Kikuyu audio dataset from HuggingFace (`google/WaxalNLP`, `kik_tts` split)
2. Preprocessing and phonemizing text using espeak-ng
3. Fine-tuning a Piper medium-quality (22050 Hz) VITS model
4. Exporting the trained model to ONNX for inference
## Requirements
- Python 3.7+
- espeak-ng (system dependency for Kikuyu phonemization)
- PyTorch 1.11+
- A pretrained Piper base checkpoint at `./pretrained/base.ckpt`
Install espeak-ng:
```bash
# macOS
brew install espeak-ng
# Ubuntu/Debian
sudo apt-get install espeak-ng
```
## Installation
```bash
# Clone or navigate to the project
cd kikuyu_tts
# Create and activate virtual environment
python -m venv venv
source venv/bin/activate
# Install training dependencies
cd piper/src/python
pip install -e .
# Build Cython alignment extension
bash build_monotonic_align.sh
# Install runtime (optional, for inference)
cd ../python_run
pip install -e .
cd ../../..
# Install project-specific dependencies
pip install datasets soundfile librosa
```
## Training Workflow
All scripts are run from the `kikuyu_tts/` subdirectory:
```bash
cd kikuyu_tts
```
### Step 1 — Download and prepare the dataset
```bash
python prepare_data.py
```
Downloads audio from HuggingFace, resamples to 22050 Hz, cleans text, and writes:
- `dataset/wavs/*.wav` — audio files
- `dataset/metadata.csv` — pipe-delimited `wavs/XXXXX.wav|text` pairs
### Step 2 — Validate the dataset (optional)
```bash
python validate.py
```
Prints duration statistics (average, min, max, total hours) for the first 100 utterances.
### Step 3 — Resample audio (if needed)
```bash
python resample.py
```
Ensures all WAV files are exactly 22050 Hz, overwriting files in place.
### Step 4 — Preprocess for training
```bash
python preprocess.py …