Skip to content
 
 

Repository files navigation

inflect-tts

Run Inflect v2 TTS locally, in the browser (or from the command line).

This model is tiny (Micro 9M, Nano 4M parameters), voice generation with ONNX is almost instant.

Screen recording of the inflect-tts web app: typing text, clicking Generate, and the resulting audio player

Inflect TTS v2 was heroically trained by Owen Song (GitHub, model weights on HuggingFace: Micro, Nano). I just converted it to .onnx. Original code and weights are released under Apache-2.0; see LICENSE.

Benchmark

"A small voice can still have something meaningful to say."

seed=7, speed=1.0, variation=0.667. Average of 3 runs:

Implementation Model CPU WebGPU
inference-py-orig micro 0.85s
inference-py-orig nano 0.87s
inference-py-standalone micro 0.99s
inference-py-standalone nano 0.86s
inference-nodejs micro 0.29s 0.18s
inference-nodejs nano 0.15s 0.12s

Directories

An evolution, in the order they were built:

  • inference-py-orig/ — thin wrapper (run.py) that downloads weights from HF Hub and calls the author's own vendored package (Inflect-Micro-v2/) for inference (me)
  • inference-py-standalone/ — same PyTorch model, but with no import of the author's package: text.py (normalization + phonemization), model.py (VITS network), run.py (download + synthesis + CLI). (Claude)
  • inference-nodejs/ — Node.js + onnxruntime-node port. The PyTorch model is exported to two ONNX graphs (scripts/export_onnx.py: encoder + decoder, split so noise injection — and thus the --seed flag — stays controllable from JS). Text normalization is a JS port (text.js); phonemization uses piper-phonemize (espeak-ng compiled to WASM, no native/system dependency). (Claude)
  • frontend/ + Dockerfile — Vite frontend. The Dockerfile downloads .pth from HF, converts to .onnx, and ships an nginx container serving the static site. Inference runs in the users's browser with onnxruntime-web (webgpu with wasm fallback). Tested on Chrome 150.0.7871.115, Safari 18.6, Firefox 152.0.6, Edge 150.0.4078.99 (Claude)

inference-py-standalone/run.py and inference-nodejs/run.js take --model <micro|nano> --text "..." --output out.wav [--speed 1.0] [--variation 0.667] [--seed 7]; run.js also takes --webgpu, run.py a --device. (inference-py-orig/run.py only takes --model.) inference-nodejs needs its ONNX graphs exported once first (downloads from HF automatically):

python inference-nodejs/scripts/export_onnx.py --model nano --out-dir inference-nodejs/models/nano

Releases

Packages

Contributors

Languages