$ pip install piper-tts
Since you installed it via pip, you can use the piper command directly in your terminal. Because Piper is a "neural" text-to-speech engine, it doesn't come with voices built-in; you have to provide a model file (.onnx) and its configuration file (.json).
Here is the workflow to convert your text file:
1. Get a Voice Model
If you haven't already, download a voice from the official repository. You need both files for a specific voice (e.g., en_US-lessac-medium.onnx and en_US-lessac-medium.onnx.json).
2. The Conversion Command
To convert a text file (let's call it input.txt) into an audio file (output.wav), use the following syntax:
piper --model /path/to/voice.onnx < input.txt --output_file output.wav
3. Practical Example
If your text file is named script.txt and your model is in the same folder, run:
cat script.txt | piper --model en_US-lessac-medium.onnx --output_file speech.wav
Pro Tips for Better Usage
Adjusting Speed: Use the
--length_scaleflag. A higher number makes it slower, a lower number makes it faster.Example (Slower):
--length_scale 1.5
Adding Pause/Sentence Gap: Use the
--sentence_silenceflag to add seconds of silence between sentences.Example:
--sentence_silence 0.5
Batch Processing: If you want to listen to the file immediately without saving it, you can pipe it to a player like
aplay(built-in to Ubuntu):Bashcat script.txt | piper --model en_US-lessac-medium.onnx --output-raw | aplay -r 22050 -f S16_LE -t raw
Quick Note: If you get a "command not found" error, your pip script folder might not be in your PATH. You can usually fix this by running python3 -m piper instead of just piper at the start of the command.
Do you have a specific voice or language in mind, or are you looking for recommendations on the best-sounding models?
Sorry, I open the page, but can not find en_US-lessac-medium.onnx and en_US-lessac-medium.onnx.json
# Download the .onnx model file
wget -O en_US-lessac-medium.onnx "https://huggingface.co/rhasspy/piper-voices/resolve/main/en/en_US/lessac/medium/en_US-lessac-medium.onnx?download=true"
# Download the .json config file
wget -O en_US-lessac-medium.onnx.json "https://huggingface.co/rhasspy/piper-voices/resolve/main/en/en_US/lessac/medium/en_US-lessac-medium.onnx.json?download=true"
# Download the .onnx model file (approx. 114MB)
wget -O en_GB-cori-high.onnx "https://huggingface.co/rhasspy/piper-voices/resolve/main/en/en_GB/cori/high/en_GB-cori-high.onnx?download=true"
# Download the .json config file
wget -O en_GB-cori-high.onnx.json "https://huggingface.co/rhasspy/piper-voices/resolve/main/en/en_GB/cori/high/en_GB-cori-high.onnx.json?download=true"
Run the conversion
Once those are finished, use this command to convert your text file (e.g., input.txt) to a UK-voiced audio file:
cat input.txt | piper --model en_GB-cori-high.onnx --output_file uk_speech.wav
Other UK Options
Gemini, could you give me the commands for downloading some other GB voice models, please? Thank you!Here are the commands for some of the most popular British (UK) voice models available for Piper. Each model has a slightly different personality and quality level.
1. Alan (Male - Medium Quality)
This is a standard, clear male British voice.
# Model
wget -O en_GB-alan-medium.onnx "https://huggingface.co/rhasspy/piper-voices/resolve/main/en/en_GB/alan/medium/en_GB-alan-medium.onnx?download=true"
# Config
wget -O en_GB-alan-medium.onnx.json "https://huggingface.co/rhasspy/piper-voices/resolve/main/en/en_GB/alan/medium/en_GB-alan-medium.onnx.json?download=true"
2. Southern English Female (Female - Low Quality)
Despite being "low" quality, it is very fast and efficient, with a distinct southern accent.
# Model
wget -O en_GB-southern_english_female-low.onnx "https://huggingface.co/rhasspy/piper-voices/resolve/main/en/en_GB/southern_english_female/low/en_GB-southern_english_female-low.onnx?download=true"
# Config
wget -O en_GB-southern_english_female-low.onnx.json "https://huggingface.co/rhasspy/piper-voices/resolve/main/en/en_GB/southern_english_female/low/en_GB-southern_english_female-low.onnx.json?download=true"
3. VCTK (Multi-speaker - Medium Quality)
The VCTK model is unique because it contains dozens of different British speakers in one file. You can switch between them using the --speaker flag (e.g., --speaker 0, --speaker 1, etc.).
# Model
wget -O en_GB-vctk-medium.onnx "https://huggingface.co/rhasspy/piper-voices/resolve/main/en/en_GB/vctk/medium/en_GB-vctk-medium.onnx?download=true"
# Config
wget -O en_GB-vctk-medium.onnx.json "https://huggingface.co/rhasspy/piper-voices/resolve/main/en/en_GB/vctk/medium/en_GB-vctk-medium.onnx.json?download=true"
How to use them
Just swap the model name in your command. For example, to use the Alan voice:
cat temp03.txt | piper --model en_GB-alan-medium.onnx --output_file output_alan.wav
Pro Tip: Automating the check
Since you've had issues with corrupted downloads before, you can run this quick "check" after downloading to see if the file is valid:
# This will show the size; Alan should be ~15MB, VCTK ~45MB
ls -lh *.onnx
If you ever want to try a Northern English accent, there is also a northern_english_male model available—just let me know and I'll grab those links for you!
Yes, please. Thank you!
The Northern English voice is a great choice—it has a very distinct, warm character compared to the standard "Received Pronunciation" (London-style) voices.
Here are the commands for the Northern English Male model (Medium quality):
1. Download the Northern English Voice Files
# Download the .onnx model file (approx. 63MB)
wget -O en_GB-northern_english_male-medium.onnx "https://huggingface.co/rhasspy/piper-voices/resolve/main/en/en_GB/northern_english_male/medium/en_GB-northern_english_male-medium.onnx?download=true"
# Download the .json config file
wget -O en_GB-northern_english_male-medium.onnx.json "https://huggingface.co/rhasspy/piper-voices/resolve/main/en/en_GB/northern_english_male/medium/en_GB-northern_english_male-medium.onnx.json?download=true"
2. Run the conversion
Use this command to hear the new accent:
cat temp03.txt | piper --model en_GB-northern_english_male-medium.onnx --output_file northern_uk.wav
A Quick Tip for Your Setup
Since you've downloaded several voices now, your folder might be getting a bit crowded. You can verify all your available models at once with:
ls -lh *.onnx
Common Model Sizes for Comparison:
Cori (High): ~114 MB
Northern English (Medium): ~63 MB
Alan (Medium): ~15 MB
If any of these files show a size of only a few KB, they didn't download correctly—just delete that specific file and run the wget command for it again.
Enjoy the new voice! It’s one of the more unique ones in the British collection.
No comments:
Post a Comment