The Problem
Deploying a small, fast English TTS model that runs on a CPU or in a browser is hard. Existing solutions are either large, require GPU inference, or lack a clear, reproducible training recipe. This repo offers a ready‑to‑use, 4.5 M‑parameter model with a public training pipeline and a lightweight web demo.
What This Does
The package delivers a two‑voice TTS system (F2 and M2) written in pure Python and PyTorch, with optional ONNX export for browser use.
- Inference:
src/tiny_voca/infer.pyexposesspeak_textand a CLI (python -m tiny_voca.infer). - Export:
src/tiny_voca/export.pyconverts a checkpoint to ONNX (tiny_voca.onnx). - Training: a sequence of scripts (
prepare.py,annotate.py,train.py,evaluate.py) builds features, aligns text, trains the network, and evaluates it. - Web demo:
web/public/index.htmlloads the ONNX model viaworker.jsand streams audio in the browser.
How It Is Wired
Entry point: python -m tiny_voca.infer.
infer.mainparses arguments, loadstiny_voca.model.TinyVoca, and callsspeak_text.speak_texttokenizes the input withsrc/tiny_voca/text.py, passes the sequence through the model, and writes a WAV viasrc/tiny_voca/journal.py.- The model class (
src/tiny_voca/model.py) builds atorch.nn.Modulefrom the checkpoint and exposes aforwardmethod used byinfer.
Export path: python -m tiny_voca.export.
export.mainloads the same checkpoint, callsTinyVoca.export_to_onnx, and writes the file.
Training path:
scripts/prepare.py→src/tiny_voca/prepare.pybuilds feature tensors.scripts/annotate.py→src/tiny_voca/annotate.pyaligns text to audio.scripts/train.py→src/tiny_voca/train.pytrains the model, invokingsrc/tiny_voca/losses.py.scripts/evaluate.py→src/tiny_voca/evaluate.pyruns inference on a validation set.
The web demo (web/public/index.html) fetches the ONNX model via scripts/fetch_assets.sh, starts a worker (worker.js) that calls onnxruntime-web, and streams WAV data to player.js.
How To Use It
# Clone the original repo
git clone https://github.com/n4ze3m/tiny-voca.git
cd tiny-voca
# Install dependencies (editable mode)
pip install -e ".[own]"
# Download pretrained weights
hf download n4ze3m/tiny-voca --local-dir weights
export DIZIONE_DATA=weights/phonemizer
# Inference
python -m tiny_voca.infer \
--checkpoint weights/tiny-voca.pt \
--voice F2 \
--text "Hello! This is tiny voca." \
--output hello.wav
For the browser demo:
cd web
bash fetch_assets.sh /path/to/dizione
npx wrangler dev
Real-World Use
A voice‑assistant backend can serve short prompts by calling tiny_voca.infer.speak_text as a library function, caching the WAV in memory, and streaming it to the client. In a web app, the demo’s worker.js can be reused to run TTS client‑side, eliminating server load.
Code Health & Issues
- Medium – No CI/CD pipeline:
.github/contains onlyFUNDING.yml. - Low – No lockfile (
pyproject.tomlonly lists dependencies).
The repo contains 10 unit tests (tests/*.py) and 8 documentation files (docs/*.md). No obvious license or secrets are committed.
The Bottom Line
tiny‑voca delivers a small, fast TTS model with a fully documented training and inference pipeline. It is well‑structured for developers who need reproducible training or lightweight inference, but lacks automated testing and dependency locking, which could hinder continuous integration. Use it when you need a two‑voice English TTS that runs on CPU or in the browser and can be extended or retrained with the provided scripts.