Skip to content

Latest commit

 

History

28 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Piper logo

A fast, local neural text to speech system that sounds great and is optimized for the Raspberry Pi 4. Piper is used in a variety of projects.

echo 'Welcome to the world of speech synthesis!' | \
  ./piper --model en_US-lessac-medium.onnx --output_file welcome.wav

Listen to voice samples and check out a video tutorial by Thorsten Müller

Voices are trained with VITS and exported to the onnxruntime.

A library from the Open Home Foundation

Voices

Our goal is to support Home Assistant and the Year of Voice.

Download voices for the supported languages:

  • Arabic (ar_JO)
  • Catalan (ca_ES)
  • Czech (cs_CZ)
  • Welsh (cy_GB)
  • Danish (da_DK)
  • German (de_DE)
  • Greek (el_GR)
  • English (en_GB, en_US)
  • Spanish (es_ES, es_MX)
  • Finnish (fi_FI)
  • French (fr_FR)
  • Hungarian (hu_HU)
  • Icelandic (is_IS)
  • Italian (it_IT)
  • Georgian (ka_GE)
  • Kazakh (kk_KZ)
  • Luxembourgish (lb_LU)
  • Nepali (ne_NP)
  • Dutch (nl_BE, nl_NL)
  • Norwegian (no_NO)
  • Polish (pl_PL)
  • Portuguese (pt_BR, pt_PT)
  • Romanian (ro_RO)
  • Russian (ru_RU)
  • Serbian (sr_RS)
  • Swedish (sv_SE)
  • Swahili (sw_CD)
  • Turkish (tr_TR)
  • Ukrainian (uk_UA)
  • Vietnamese (vi_VN)
  • Chinese (zh_CN)

You will need two files per voice:

  1. A .onnx model file, such as en_US-lessac-medium.onnx
  2. A .onnx.json config file, such as en_US-lessac-medium.onnx.json

The MODEL_CARD file for each voice contains important licensing information. Piper is intended for text to speech research, and does not impose any additional restrictions on voice models. Some voices may have restrictive licenses, however, so please review them carefully!

Installation

You can run Piper with Python or download a binary release:

  • amd64 (64-bit desktop Linux)
  • arm64 (64-bit Raspberry Pi 4)
  • armv7 (32-bit Raspberry Pi 3/4)

If you want to build from source, see the Makefile and C++ source. You must download and extract piper-phonemize to lib/Linux-$(uname -m)/piper_phonemize before building. For example, lib/Linux-x86_64/piper_phonemize/lib/libpiper_phonemize.so should exist for AMD/Intel machines (as well as everything else from libpiper_phonemize-amd64.tar.gz).

Usage

  1. Download a voice and extract the .onnx and .onnx.json files
  2. Run the piper binary with text on standard input, --model /path/to/your-voice.onnx, and --output_file output.wav

For example:

echo 'Welcome to the world of speech synthesis!' | \
  ./piper --model en_US-lessac-medium.onnx --output_file welcome.wav

For multi-speaker models, use --speaker <number> to change speakers (default: 0).

See piper --help for more options.

Streaming Audio

Piper can stream raw audio to stdout as its produced:

echo 'This sentence is spoken first. This sentence is synthesized while the first sentence is spoken.' | \
  ./piper --model en_US-lessac-medium.onnx --output-raw | \
  aplay -r 22050 -f S16_LE -t raw -

This is raw audio and not a WAV file, so make sure your audio player is set to play 16-bit mono PCM samples at the correct sample rate for the voice.

JSON Input

The piper executable can accept JSON input when using the --json-input flag. Each line of input must be a JSON object with text field. For example:

{ "text": "First sentence to speak." }
{ "text": "Second sentence to speak." }

Optional fields include:

  • speaker - string
    • Name of the speaker to use from speaker_id_map in config (multi-speaker voices only)
  • speaker_id - number
    • Id of speaker to use from 0 to number of speakers - 1 (multi-speaker voices only, overrides "speaker")
  • output_file - string
    • Path to output WAV file

The following example writes two sentences with different speakers to different files:

{ "text": "First speaker.", "speaker_id": 0, "output_file": "/tmp/speaker_0.wav" }
{ "text": "Second speaker.", "speaker_id": 1, "output_file": "/tmp/speaker_1.wav" }

People using Piper

Piper has been used in the following projects/papers:

Training

See the training guide and the source code.

Pretrained checkpoints are available on Hugging Face

Running in Python

See src/python_run

Install with pip:

pip install piper-tts

and then run:

echo 'Welcome to the world of speech synthesis!' | piper \
  --model en_US-lessac-medium \
  --output_file welcome.wav

This will automatically download voice files the first time they're used. Use --data-dir and --download-dir to adjust where voices are found/downloaded.

If you'd like to use a GPU, install the onnxruntime-gpu package:

.venv/bin/pip3 install onnxruntime-gpu

and then run piper with the --cuda argument. You will need to have a functioning CUDA environment, such as what's available in NVIDIA's PyTorch containers.

Piper TTS Trainer

A comprehensive GUI toolkit for training custom text-to-speech voices using the Piper engine.

Overview

Piper TTS Trainer provides an end-to-end solution for creating, recording, and training custom voice models for text-to-speech applications. The project combines three key components:

  1. Piper Engine - The core TTS system
  2. Recording Studio - A web interface for recording voice datasets
  3. Training GUI - A graphical interface for model training and testing

System Requirements

  • Operating System: Ubuntu 20.04+ (or Windows 10/11 with WSL2)
  • Python: 3.9+
  • Storage: At least 20GB free space
  • Memory: 16GB RAM recommended (8GB minimum)
  • GPU: NVIDIA GPU with CUDA support recommended for faster training

WSL Setup for Windows Users

If you're using Windows, you'll need to install and configure WSL2:

  1. Open PowerShell as administrator and run:

    wsl --install
  2. Once WSL is installed and you've set up your Ubuntu distribution, you'll need to install the required packages:

    sudo apt update
    sudo apt install python3-poetry
  3. If using the Poetry version of the software, make sure python3-poetry is installed:

    sudo apt install python3-poetry

The scripts in this repository will check for and install python3-poetry if it's not found.

Installation

You can install Piper TTS Trainer using one of the following methods:

Method 1: Use the setup script (Recommended)

  1. Clone this repository:

    git clone https://github.com/username/piper-tts-trainer.git
    cd piper-tts-trainer
  2. Run the setup script:

    bash setup_poetry.sh

    This script will:

    • Install system dependencies
    • Set up Poetry environment
    • Clone necessary repositories
    • Configure CUDA for GPU acceleration (if available)
    • Build required components
    • Create launcher scripts
  3. Download pre-trained checkpoints (optional but recommended):

    bash download_checkpoints.sh

Method 2: Manual Setup

For advanced users who prefer manual configuration, follow these steps:

  1. Install system dependencies:

    sudo apt update && sudo apt install -y python3-dev python3-pip espeak-ng ffmpeg build-essential git curl libespeak-ng-dev pkg-config cmake
  2. Clone required repositories:

    git clone https://github.com/rhasspy/piper.git
    git clone https://github.com/rhasspy/piper-recording-studio.git
    git clone https://github.com/rhasspy/piper-phonemize.git
  3. Install Poetry:

    curl -sSL https://install.python-poetry.org | python3 -
  4. Create and configure your environment manually following the steps in setup_poetry.sh

Usage

Recording Voice Dataset

  1. Start the recording studio:

    ./run_recording_studio.sh
  2. Open your browser and navigate to http://localhost:8000

  3. Follow the on-screen instructions to:

    • Create a new speaker profile
    • Record sentences
    • Review and re-record as needed
  4. Export your dataset:

    ./export_dataset.sh en-GB my-dataset

    Replace en-GB with your language code and my-dataset with your preferred name.

Training a Voice Model

  1. Launch the training GUI:

    ./run_gui.sh
  2. Open your browser and navigate to http://localhost:7860

  3. Use the interface to:

    • Select your dataset
    • Configure training parameters
    • Start training
    • Monitor progress
    • Test your model

Using Your Trained Model

Once training is complete, you can:

  1. Export your model to ONNX format using the GUI
  2. Use the model with the Piper TTS engine
  3. Integrate with other applications like Home Assistant

Project Structure

  • checkpoints/ - Pre-trained model checkpoints
  • datasets/ - Voice datasets
  • training/ - Training outputs and logs
  • models/ - Exported TTS models
  • normalized_wavs/ - Processed audio files
  • piper/ - Piper engine source code
  • piper-recording-studio/ - Recording studio interface
  • piper-phonemize/ - Text phonemization module

Troubleshooting

Common Issues

  1. CUDA/GPU errors:

    • Ensure your NVIDIA drivers are up to date
    • Check compatibility between PyTorch and CUDA versions
  2. Audio recording issues:

    • Verify microphone permissions in browser
    • Check microphone settings in your OS
  3. Training fails to start:

    • Ensure the dataset is properly exported
    • Check for sufficient disk space

Getting Help

If you encounter issues not covered here:

Additional Resources

License

This project includes components under various open source licenses. See individual repositories for details.

Acknowledgments

About

GUI for training custom voices using Piper TTS

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages