SabaKore

Home / Articles / AI guides

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, a junior infrastructure engineer

Ren

I want to build a feature that reads articles aloud. Can a text-to-speech AI run on a VPS too?
Procura, a cloud AI robot who explains

Procura

It can. Text-to-speech involves a lot of processing that depends on a GPU less than image generation does, and in some cases a CPU alone is practical. How heavy it needs to be depends on how natural a voice you want.

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, a junior infrastructure engineer

Ren

What's the difference between running it yourself and using an external API?
Procura, a cloud AI robot who explains

Procura

An external API gives you natural voices easily, but you send the text to be read to the other party. If you run it yourself, that concern disappears, but you take on the naturalness of the voice and the operating effort yourself.

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, a cloud AI robot who explains

Procura

If you decide first how natural a voice you need, choosing a model and the setup both become much easier to settle. If you start building with the goal left vague, you tend to end up redoing it later, so be careful.
Ren, a junior infrastructure engineer

Ren

Can I choose the type of voice (male, female, speaking style, and so on)?
Procura, a cloud AI robot who explains

Procura

The voices available differ by model. Some can switch among several voices, while others can only produce a fixed voice. It's a good idea to check, before you choose, whether a voice that suits where you want to use it is available.
Procura, a cloud AI robot who explains

Procura

Audio leaves a stronger impression on listeners than text does. What is read aloud and which voice you choose affect the user experience more than you might think, so don't treat it lightly as just a feature; choose carefully.

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, a junior infrastructure engineer

Ren

So decide first whether you want naturalness or lightness, and then start building.

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