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.py exposes speak_text and a CLI (python -m tiny_voca.infer).
  • Export: src/tiny_voca/export.py converts 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.html loads the ONNX model via worker.js and streams audio in the browser.

How It Is Wired

Entry point: python -m tiny_voca.infer.

  • infer.main parses arguments, loads tiny_voca.model.TinyVoca, and calls speak_text.
  • speak_text tokenizes the input with src/tiny_voca/text.py, passes the sequence through the model, and writes a WAV via src/tiny_voca/journal.py.
  • The model class (src/tiny_voca/model.py) builds a torch.nn.Module from the checkpoint and exposes a forward method used by infer.

Export path: python -m tiny_voca.export.

  • export.main loads the same checkpoint, calls TinyVoca.export_to_onnx, and writes the file.

Training path:

  1. scripts/prepare.py → src/tiny_voca/prepare.py builds feature tensors.
  2. scripts/annotate.py → src/tiny_voca/annotate.py aligns text to audio.
  3. scripts/train.py → src/tiny_voca/train.py trains the model, invoking src/tiny_voca/losses.py.
  4. scripts/evaluate.py → src/tiny_voca/evaluate.py runs 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 only FUNDING.yml.
  • Low – No lockfile (pyproject.toml only 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.