Logo Lanfrica

michsethowusu/fast-ghana-voice

Domaine:

natural language processing

Type de record:

softwaremodel
Créateur:
mic
Hôte:
Offline Twi/Ewe/Dagbani text-to-speech on ONNX Runtime (no PyTorch). ~14-20x realtime on CPU. # Fast Ghana Voice 🗣️🇬🇭 **Offline Twi / Ewe / Dagbani text-to-speech on ONNX Runtime — no PyTorch.** ▶️ **Try the live demo:** Fast Ghana Voice on Hugging Face Spaces (runs the same full ONNX pipeline on CPU). Lightweight (`onnxruntime + numpy + soundfile`), fast on CPU, and fully offline after the first model download. Built from a StableTTS flow-matching model finetuned on the GhanaNLP Bible dataset, exported to ONNX (text encoder + duration + flow-matching decoder baked into one acoustic graph; a 44.1 kHz Vocos vocoder with a real-op iSTFT). ## Install ```bash pip install fast-ghana-voice # or from source: pip install git+github.com ``` ## Usage ### Python ```python from fast_ghana_voice import FastGhanaVoice tts = FastGhanaVoice() # downloads + caches ONNX models on first run wav, sr = tts.synthesize("Awurade ne me hwɛfo.", language="twi") tts.save("out.wav", wav, sr) ``` ### Command line ```bash fast-ghana-voice "Naawuni n-nyɛ n lana." --language dagbani -o out.wav ``` Languages: `twi`, `ewe`, `dagbani` (each is a distinct baked voice). ### Fully offline Download the model files once (`model-steps-4.onnx`, `vocos.onnx`, `tokens.txt` from the model repo) into a folder, then point the library at it — no network needed: ```python tts = FastGhanaVoice(model_dir="./models") ``` ## Knobs - `length_scale` — `>1` slower, `<1` faster speech. - `noise_scale` — sampling temperature (default 0.667). - `steps` — baked ODE-solver steps variant (default 4; more steps = smoother, slightly slower). ## How it works 1. **Tokenizer** (pure Python): text → grapheme characters → ids → blank-interspersed. 2. **Acoustic ONNX** (`model-steps-N.onnx`): tokens + speaker id → mel. The text encoder, duration predictor, length regulation, and the euler ODE loop are all baked in. 3. **Vocoder ONNX** (`vocos.onnx`): mel → 44.1 kHz waveform (Vocos; the complex iSTFT was reimplemented with real ops so it runs in ONNX …