Turn a local text file into speech
Generate a WAV file with Piper, compare speaking rates, and check the spoken details against the source text.
Install Piper and get a voice
Piper reads the text you give it and produces speech locally. In a Python 3 virtual environment, install the version below. These commands were tested with Python 3.13 on Apple silicon. Check the linked package for a build that matches your platform.
python -m pip install "piper-tts==1.8.0"
mkdir voices
python -m piper.download_voices en_US-lessac-medium --download-dir voices
The download supplies an .onnx model and its matching .onnx.json settings. If the download command fails, save both files from the voice’s official file listing into the voices folder. Consult the voice’s model card for language, speaker, and license information.
Generate a recording
Save this text file in your working directory. Run the command below after both voice files are available.
View announcement.txt
The reading room closes at six p.m. on Saturdays. Ask at the front desk for help.python -m piper --model voices/en_US-lessac-medium.onnx --input-file announcement.txt --output-file announcement.wav
A media player opens announcement.wav and you can hear the Saturday closing time and the instruction about the front desk. Once the files are downloaded, repeat the command offline with a new output name.
Compare two speaking rates
python -m piper --model voices/en_US-lessac-medium.onnx --input-file announcement.txt --output-file fast.wav --length-scale 0.8 --noise-scale 0 --noise-w-scale 0
python -m piper --model voices/en_US-lessac-medium.onnx --input-file announcement.txt --output-file slow.wav --length-scale 1.3 --noise-scale 0 --noise-w-scale 0
Play both files and compare durations. Check whether the slower version is easier to understand. Try writing a time in digits and then in words. Listen for the difference before choosing wording for an announcement.
Check your understanding
If the audio has the wrong closing time, which input should you check first?
Check the original text. Then try spelling the intended time out in words and listen again.
Sources
Progress is saved in this browser.