Lesson 28 / Unit 7: Adaptation and Serving
Deployment Costs
At a real-time factor of 0.052, one busy container-hour yields about 1,150 audio minutes. Turn RTF into cost per minute, price in utilisation, clear the licence gate.
Start with measured synthesis time, then account for idle capacity. A fast voice can still be expensive if its machine spends most of the month waiting for requests.
Compute Cost
Divide the machine’s hourly price by the minutes of audio it produces per hour at your real operating point. With real-time factor RTF, one fully busy hour produces 60 / RTF minutes of audio, so:
cost per audio minute = P × RTF / (60 × U)
P = hourly price of the machine (your placeholder)RTF = seconds of compute per second of audio, measured on that machineU = utilisation, the fraction of paid time spent synthesising (0 to 1)Here are the real-time factors we measured, all on the same 4-core container, one request at a time, with the audio minutes per busy hour derived from them:
| System (measured on 4 CPU cores, concurrency one) | RTF | Audio minutes per busy hour (60 / RTF) | Cost per minute at U = 1 |
|---|---|---|---|
Piper en_US-ljspeech-medium | 0.052 | about 1,150 | P × 0.00087 |
| Our tiny model (step 1,650) + HiFi-GAN | 0.24 | 250 | P × 0.004 |
| HiFi-GAN vocoder alone, across runs | 0.19 to 0.27 | about 220 to 320 | P × 0.0032 to P × 0.0045 |
The Piper row comes from three probe sentences. On the 61 sentences of the eval harness, the same voice on the same container measured RTF 0.037. We keep 0.052 as the worked example, but the choice of test changes the number, so measure on text like yours.
The third column is arithmetic on the second, not a throughput test. Two things we did not measure would change it: running several requests at once, which can raise total throughput or collapse per-request speed depending on the machine, and GPU hardware, where the numbers are different in kind. Measure RTF at your target concurrency before you trust the column.
Where does the money go? The table hints at it. In our cascade the vocoder took 96.4% of synthesis time, so any cost work on that pipeline starts with the vocoder. The neural vocoder lesson has the breakdown.
Capacity Utilisation
Because you pay for the machine whether it is speaking or waiting. Cost per minute scales with 1 / U: at U = 0.25, Piper’s P × 0.00087 becomes P × 0.0035, four times higher, with no change to the model.
Voice traffic makes high utilisation hard. Calls cluster by time of day, and an agent that must answer instantly cannot queue requests to fill the gaps. Three things push U down in practice:
- Warm capacity for latency. A service that scales to zero pays a cold start on the first request. Keeping a floor of warm instances protects time to first audio and costs money every idle hour.
- Headroom for peaks and failures. Capacity sized for the busiest minute sits partly idle the rest of the day, and redundancy doubles some of it.
- Per-session slots. If your serving stack reserves a worker per call, that worker sits idle between replies and while audio plays.
The comparison with a hosted API follows from the same terms. If you keep N instances warm all month, your floor is N × P × (hours in the month). A hosted service charging A per minute costs A × V for V minutes. The break-even volume is V = N × P × hours / A, before engineering time. Below it, hosted wins on cost; above it, self-hosting can, if the utilisation you assumed is the utilisation you get.
Deployment Boundaries
The audio stops being allowed to leave. Often that constraint, rather than cost, is what moves a team to self-host.
In-region deployment runs the same serving stack inside a named jurisdiction. The model is the easy part. Telephony numbers, media paths, logs and recordings all need to stay in the region too, and the audit trail that proves it is most of the work.
On-premises means hardware the customer controls, sometimes with no internet access. Everything above still applies, with tighter limits: the hardware is fixed rather than rented, updates become a release process, and monitoring cannot phone home. Model choice shifts towards what fits the machines that exist. That is where CPU numbers like ours become directly useful: a single-voice model at an RTF of 0.052 on four cores, from a 63.5 MB ONNX file, fits hardware a GPU-first model does not.
Licence Review
Every layer of the stack carries its own licence, and a deployment clears the gate only when all of them allow it. For the systems in the build-along:
| Layer | Component | Licence |
|---|---|---|
| Training data | LJSpeech | Public domain |
| Aligner weights | torchaudio MMS_FA (data preparation only) | CC-BY-NC 4.0, per its docs |
| Vocoder weights | speechbrain/tts-hifigan-ljspeech | Apache-2.0 |
| Voice weights | rhasspy/piper-voices | MIT |
| Runtime | piper-tts | GPL-3.0-or-later |
The aligner row is easy to miss: it never runs at serving time, but it shaped the training data, so read its terms before a commercial model depends on it. The Piper row is the one to remember: MIT weights and a GPL runtime make up one “model”. Calling it behind your own API is one situation; under common readings of the GPL, shipping it inside a product installed at a client site can count as distribution, and then the runtime’s terms travel with it. Check with counsel. Dataset licensing covers the data side, including consent for any voice you clone or fine-tune.
Fill in the cost sheet
Measure RTF for your chosen model on your target machine at your expected concurrency. Put your real hourly price in for P, estimate U from a week of traffic, and compute cost per minute. Then list the licence for data, weights and runtime. If any cell is blank, that is the next task.
Further Experiments
You have now built each stage of a TTS system: audio as numbers, a filtered dataset, a text front end, an acoustic model trained from random weights, a pretrained vocoder, and an eval harness that scores it. The last unit added the parts you would need to take a model further: codec tokens, adaptation, cloning, serving and cost.
The acoustic model remains a teaching experiment. The saved audio and scores show one run; they do not establish deployment quality or concurrent capacity.
When the requirement is a specific language, dialect, domain or deployment boundary, our self-hosted voice agent work follows the same order as this unit: acceptance metrics agreed in writing, then a data assessment, then training and evaluation against those metrics, then deployment.
Common questions
How do you calculate the cost per minute of self-hosted TTS?
Cost per audio minute = P × RTF / (60 × U), where P is the hourly price of the machine, RTF is the real-time factor measured on that machine at your concurrency, and U is utilisation between 0 and 1. One busy machine-hour produces 60 / RTF minutes of audio; utilisation scales that down.
Why does utilisation matter so much for TTS cost?
Because you pay for the machine whether it is synthesising or idle. Cost per minute scales with 1 / U, so a machine that is busy a quarter of the time costs four times as much per minute of audio as the same machine kept fully busy.
Can you deploy a TTS model commercially if the weights are open?
Only after checking every licence in the stack separately: the training data, the model weights and the runtime. Piper is a real example: its voices repository is MIT, while the piper-tts runtime package is GPL-3.0-or-later. Under common readings of the GPL, an on-premises delivery to a client can count as distribution, so the runtime licence may apply in a way an API call does not; check with counsel.
We do this work for teams shipping voice agents: Self-Hosted Voice Agent .
Edit this lesson on GitHub ↗Discussion
Questions, corrections and war stories welcome. Sign in with GitHub to comment.