Workload · Running your own voice engine

Your own text-to-speech server, with Piper

You want text to speech for your app, your phone line or your accessibility tool, without sending every sentence to someone else's cloud. Piper does that on your own machine: an open-source engine, installed from pip, that answers a JSON request with a WAV file. Here is how to set it up so only your software can reach it.

The short version
  1. Open source: GPL-3.0-or-later
  2. Each voice has its own licence
  3. Runs on ordinary processors
  4. NVIDIA acceleration with --cuda
  5. Listens on every IPv4 address unless told not to

What you end up with

A small web service on your server. Your application posts some text to it, and it sends back spoken audio as a WAV file. Under the hood, Piper uses espeak-ng to turn words into phonemes (the individual sounds of a language), then voices them with neural models stored as ONNX files, a common format for running trained AI models. It is maintained by the Open Home Foundation in the OHF-Voice/piper1-gpl repository (the older rhasspy/piper is archived) and published on PyPI as piper-tts, currently version 1.8.0 and labelled Alpha.

Typical jobs: reading notifications aloud in a smart-home setup, generating prompts for a phone menu, narrating articles, or giving a chatbot a voice. Projects listed in Piper's README as using it include Home Assistant and NVDA, the free Windows screen reader.

Choose voices with the licence in hand

This is the step people skip, so do it first. Piper's code is GPL-3.0-or-later, but every voice was trained on someone's recordings, and each one carries its own terms. The voice collection lives at rhasspy/piper-voices on Hugging Face, and next to each voice is a MODEL_CARD stating where the training audio came from and under what licence. Piper's own voices page describes the project as meant only for personal use and speech research, says it places no extra limits of its own, and cautions that certain voices have restrictive terms.

  • en_US-libritts_r-medium: trained on LibriTTS-R, CC BY 4.0, with 904 speakers in one file.
  • en_US-ryan-high: its training data is licensed CC BY-NC-SA 4.0, and the NC part rules out commercial use.
  • en_US-lessac-medium: the card points to Lessac's Blizzard Challenge 2013 recordings, which come with a research licence agreement.
  • en_US-amy-medium: its card says "See URL" and points to Mycroft's mimic3-voices repository.

The download helper saves the .onnx and .onnx.json files only; the MODEL_CARD stays on Hugging Face. Read it there before a voice goes live, and keep a note of what you checked. This page is not legal advice.

Get it running

  1. Install Ubuntu and turn on ufw with only SSH allowed, before you start any service. Open /etc/default/ufw and confirm the IPv6 line reads yes; that way your firewall covers IPv6 addresses as well.
  2. Create a dedicated piper system account with its home in /opt/piper, then build a Python virtual environment there and install piper-tts[http].
  3. Download a voice into a voices folder with python -m piper.download_voices.
  4. Start piper.http_server from a systemd unit with --host 127.0.0.1, so it comes back after a reboot or crash and stays off public addresses.
sudo apt install -y python3-venv ufw
sudo ufw allow OpenSSH
sudo ufw enable
sudo useradd --system --create-home --home-dir /opt/piper --shell /usr/sbin/nologin piper
sudo -u piper bash -c 'cd /opt/piper && python3 -m venv venv && venv/bin/pip install "piper-tts[http]" && mkdir -p voices && venv/bin/python -m piper.download_voices --data-dir voices en_US-libritts_r-medium'
sudo tee /etc/systemd/system/piper-tts.service >/dev/null <<'EOF'
[Unit]
Description=Piper TTS
After=network-online.target
Wants=network-online.target

[Service]
User=piper
WorkingDirectory=/opt/piper
ExecStart=/opt/piper/venv/bin/python -m piper.http_server --host 127.0.0.1 --port 5000 --data-dir /opt/piper/voices -m en_US-libritts_r-medium
Restart=on-failure

[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable --now piper-tts

Piper also serves a test page with a Speak button and settings for the length and noise scales. The first line below checks the API from the server itself; the second, run on your laptop, forwards the page through your own SSH login so you can open localhost:5000 in a browser.

curl -X POST -H 'Content-Type: application/json' -d '{"text": "It works."}' -o hello.wav http://127.0.0.1:5000/synthesize
ssh -L 5000:127.0.0.1:5000 you@your-server

Keep it private

Out of the box, Piper's web server binds to 0.0.0.0 on port 5000 and asks for no password. That is why the setup above pins it to 127.0.0.1. It matters for one route in particular: POST /download makes Piper fetch whichever voice the caller names and save it locally, which you do not want strangers triggering.

When software on another machine needs speech, add a reverse proxy (a web server such as nginx that sits in front and forwards requests) with TLS that passes through only /synthesize, asks for a key or a basic-auth login, limits the request size and refuses every other path. Running it in a container? Map the port as 127.0.0.1:5000:5000. A plain -p 5000:5000 opens it on all IPv4 and IPv6 addresses, and Docker's own firewall rules take effect before ufw ever sees the traffic.

Does it need a graphics card?

Not to speak. Piper uses your processor by default. Add --cuda and install onnxruntime-gpu if you want an NVIDIA card to do the work. The documentation gives no speed figures, so time it yourself: the test page shows how long the last sentence took to synthesise.

Making your own voice is a different story. Training takes a folder of recordings plus a CSV of what each one says, and the guide recommends starting from an existing checkpoint. Most of the official voices came from training or fine-tuning on an NVIDIA A6000 with 48 GB or a 3090 with 24 GB, and the guide notes users getting by on 8 GB of VRAM. For that work, look at our GPU servers.

Where to run it

A Primcast dedicated server is a physical machine that is yours alone, with root access and an unmetered port, so generating hours of audio adds nothing to the bill. If the machine you choose is already in a rack, it is handed over within about 30 minutes once your order is approved. Machines built to your spec need more time. Pick the location nearest your listeners from our data centers.

  • Small and cheap cartridges are meant for one job per machine, and a voice service that does nothing else is exactly that. Try your longest usual sentence on it first.
  • Desktop machines come with a graphics card of their own, handy if you want to see whether --cuda makes a difference for your voices.
  • Locked yourself out with a firewall rule? Rack servers, blades, plus the m510 and m710x cartridge models, come with a remote console that works outside the operating system, so you still get the screen and power button without waiting for us. On the remaining cartridge models you can only switch the power.

Want the conversation to flow both ways? Pair Piper with Whisper on your own server, which turns speech back into text, and your voice assistant hears and answers without a single recording leaving your hardware.

Questions people ask

Is Piper free to use in a product?
Piper's code is under GPL-3.0-or-later. Whether a given voice can be used commercially depends on that voice's MODEL_CARD: en_US-libritts_r-medium is CC BY 4.0, while en_US-ryan-high is non-commercial (CC BY-NC-SA 4.0). Check each one, and take legal advice where it matters.
How do I call the Piper API from my app?
Send a POST to /synthesize with a JSON body containing text. Optional fields pick the voice, a speaker or speaker_id on multi-speaker voices, and tune speed with length_scale and variation with the two noise settings. The reply is a WAV file.
Can I switch between voices without restarting?
Yes. Put several voices in the data directory and name one in the voice field. The server loads it the first time it is asked for and keeps it in memory; GET /voices lists what is available.
Does Piper clone voices?
Its documentation offers no clone-from-a-clip feature. Custom voices come from training on a set of recordings with their transcripts, then exporting the result to ONNX.

Give your project a voice

Start with a dedicated server you control, and your speech stays on your own hardware.

Get a server for your voice engine

Read next