# Piper

> Fast, local neural text-to-speech that runs offline on your own machine

- Category: Multimodal Generation / Audio, Music & Voice
- Language: C++
- Licence: MIT
- Repository: https://github.com/rhasspy/piper
- Website: https://rhasspy.github.io/piper-samples/
- Canonical page: https://ai-tldr.dev/tools/piper/

## In short

Piper is an open-source neural text-to-speech engine that turns written text into natural-sounding speech. It is built to be fast and to run fully on your own machine, so you do not need to send text to a cloud service. It sits in the Audio, Music & Voice category of the Multimodal Generation tools and is open-source, written in C++ and licensed MIT.

## Overview

Piper is an open-source neural text-to-speech engine that turns written text into natural-sounding speech. It is built to be fast and to run fully on your own machine, so you do not need to send text to a cloud service.

Piper uses the espeak-ng project to convert words into phonemes, then a neural voice model to produce the audio. It ships ready-made voices in many languages, works well even on small hardware like a Raspberry Pi, and is used by projects such as Home Assistant and screen readers for the visually impaired.

## What it does

- Local, offline speech synthesis with no cloud dependency, so your text stays on your own device
- Fast neural voices that run on modest hardware, including small boards like the Raspberry Pi
- Pre-trained voices in many languages that you can list and download on demand
- Command-line interface, HTTP web server, Python API, and a C/C++ library for different integration needs
- Optional GPU acceleration through onnxruntime-gpu for higher throughput
- Tunable output, including volume, speaking speed, audio variation, and raw espeak-ng phoneme injection

## Getting started

Install Piper from PyPI, download a voice, then generate a WAV file from text. The Python package name is piper-tts.

1. Install Piper

   Install the Piper package from PyPI with pip.

```sh
pip install piper-tts
```

2. Download a voice

   List the available voices, then download one. This example downloads an English (US) voice into the current directory.

```sh
python3 -m piper.download_voices en_US-lessac-medium
```

3. Generate speech from the command line

   Run Piper with a voice model and write the spoken text to a WAV file. Here it creates test.wav from a short sentence.

```sh
python3 -m piper -m en_US-lessac-medium -f test.wav -- 'This is a test.'
```

4. Use the Python API

   You can also call Piper from Python with PiperVoice.synthesize_wav to write audio to a WAV file.

```python
import wave
from piper import PiperVoice

voice = PiperVoice.load("/path/to/en_US-lessac-medium.onnx")
with wave.open("test.wav", "wb") as wav_file:
    voice.synthesize_wav("Welcome to the world of speech synthesis!", wav_file)
```

## When to use it

- Adding offline voice output to home automation setups such as Home Assistant
- Powering screen readers and accessibility tools that read text aloud for visually impaired users
- Generating narration or voiceovers for videos and apps without relying on a paid cloud service
- Running a local text-to-speech web server for repeated synthesis from your own software
