Running Text-to-Speech (TTS) on a VPS
The setup for handling a text-to-speech AI that reads text aloud on a VPS, and the factors for deciding whether to prioritize naturalness or light processing.
Ren

Procura
Naturalness and lightness are hard to have together
- If you can accept some robotic quality, it can often be generated quickly enough on a CPU
- The more human-like intonation you want, the heavier the computation tends to get
- If you use an external text-to-speech API, you don't have to carry this weight on the VPS side

Ren

Procura
Setup when running on a VPS
Text-to-speech takes a certain amount of time from receiving text until the audio file is ready. Rather than making users wait for it as a web response, it's better to accept the request, process it in the background, and notify them when it's done, so they aren't left waiting. For reading long texts aloud, this asynchronous design is almost essential.
- Separate accepting requests from the actual audio generation processing
- Add a mechanism that processes requests in order so that those being generated don't overlap
- Delete finished audio files once the necessary period has passed
Consideration for the text you handle
Also take care that the text you have read aloud doesn't contain other people's copyrighted works or personal information that wasn't meant to be read aloud. Turning text into audio can spread information in ways that differ from text.

Procura

Ren

Procura
Procura
When the same text is read aloud many times
In situations where the same text is read aloud repeatedly, such as announcements, saving the audio file you've made once and reusing it is effective. It reduces the processing load compared with generating from scratch each time, and shortens the time users wait. However, so that old audio doesn't keep playing old content after you change the original text, manage the correspondence between texts and audio carefully.
- Don't regenerate audio for fixed phrases; save it and reuse it
- When you change the original text, always regenerate the corresponding audio
- Clean up audio files that are no longer used on a regular basis

Ren
This article is translated from the Japanese original. If the two differ, the Japanese version is the one we keep up to date.