Skip to content
All posts
Guide7 min read

Piper TTS in production: natural speech from your own servers

A practical guide to FastVision's speech stack: choosing Piper voices, streaming audio with sub-second first-byte, and shaping pronunciation with SSML.

Lena KovacsFounding Engineer, Speech

Text-to-Speech went through the same transition OCR did: the open models got good. Piper — a fast, local neural TTS engine built on VITS — produces speech that most listeners can't distinguish from the big cloud vendors, and it does it on a CPU, from ONNX files you download once and own forever.

Nine languages, dozens of voices

FastVision ships a curated voice catalog across English, Spanish, French, German, Portuguese, Italian, Dutch, Polish and Chinese. Query GET /api/v1/voices for the full list with samples, then reference any voice by id.

const job = await fv.tts.create({
  text: "Your statement for June is ready.",
  voiceId: "en_US-lessac-medium",
  format: "mp3",
  speed: 1.0,
});

const done = await fv.jobs.waitFor(job.id);
const audio = await fv.tts.download(done.id);

Streaming: first audio in under a second

Batch synthesis is fine for audiobooks; voice interfaces need audio now. POST /api/v1/stream synthesizes sentence-by-sentence and returns chunked WAV as each segment completes. In our reference deployment the first audible byte arrives in roughly 300 ms on CPU — fast enough for IVRs and voice agents to feel live.

curl -N -X POST http://localhost:8000/api/v1/stream \
  -H "X-API-Key: fv_live_yourkeyhere" \
  -H "Content-Type: application/json" \
  -d '{"text": "Connecting you now.", "voice_id": "en_US-lessac-medium"}' \
  | aplay

Shaping speech with SSML

Plain text gets you 90% of the way; SSML closes the rest. Wrap your input in speak tags to control pauses, emphasis and pronunciation — essential for account numbers, addresses and anything a naive reading would garble.

<speak>
  Your confirmation code is
  <say-as interpret-as="characters">FV92X</say-as>.
  <break time="400ms"/>
  It expires in <emphasis>ten minutes</emphasis>.
</speak>
  • speed 0.5–2.0× — slow down legal disclosures, speed up long confirmations
  • pitch −20..+20 — differentiate voices in multi-speaker flows
  • volume_gain_db −20..+20 — normalize loudness across voices
  • formats — mp3 for delivery, wav for telephony, ogg for the web

Like everything in FastVision, the speech stack honors AI_MODE=mock: in development, TTS jobs return deterministic silent audio with correct metadata, so CI never downloads a model. Production flips one env var.