One-click to Achieve Local TTS! Full Process of Deploying Piper Text-to-Speech Tool on OKMX8MP Development Board
In IoT and edge computing projects, the demand for offline and localized text-to-speech (TTS) functionality is increasing. Piper, a fast and open-source neural network TTS engine, perfectly meets this demand.
Today, step by step instructions will be provided to deploy Piper on the Forlinx Embedded OKMX8MP development board and achieve high-quality local voice synthesis. This tutorial includes complete steps, code examples, and troubleshooting for common issues to help you get started easily!
Preparation
Required Files
piper_bin.tar (about 22.6 MB)
Piper executable files and core dependent libraries (e.g., libonnxruntime, libespeak-ng).
piper-voices_cut.tar (about 114.4 MB)
Trimmed Chinese and English voiceprint model libraries.
Development Environment
Forlinx OKMX8MP development board (with Linux system flashed).
Terminal access to the development board via SSH or serial port.
Tools for file transfer (e.g., USB drive, SCP).
Detailed Deployment Steps
Step 1: Deploy Piper Executable Files
1. Copy files to the development board
Copy piper_ok.tar to any directory on the development board (take /root as an example): # Assume the file has been copied to /run/media/sda1 via USB drive root@OK8MP:~# cp /run/media/sda1/piper_ok.tar ./ root@OK8MP:~# sync
2. Extract the files
Enter the working directory and extract the files. The -m parameterpreserves the file modification time.
root@OK8MP:~# tar -xvf piper_ok.tar -m
After extraction, the directory structure of piper is as follows:
piper/ ├── piper # Core executable file ├── lib*.so* # All dynamic link libraries required for running ├── espeak-ng-data/ # Voice data └── *.ort # ONNX-related model files
3. Perform a preliminary test
Try to run the piper program directly:
root@OK8MP:~/piper# ./piper # Expected error output: "Model file doesn't exist"
Note: It's normal to get an error at this point because no voiceprint models have been specified yet. This verifies that the program itself can run.
Step 2: Deploy the Voiceprint Model Library
1. Extract the voiceprint library
Extract piper-voices_cut.tar to the /opt directory, a common locationfor optional software.
root@OK8MP:/opt# tar -xvf /path/to/piper-voices_cut.tar -m
After extraction, you'll get Chinese voiceprint model files, forexample:
/opt/piper-voices_cut/medium_zh/zh_CN-huayan-medium.onnx.
2. Create a Chinese test text
Create a text file named zh_test.txt and write the content to beconverted.
# Use the cat command to quickly create a file root@OK8MP:~/piper# cat > zh_test.txt << EOF Welcome to use Forlinx Embedded OKMX8MP development board: This is a text-to-speech local test. EOF
Note: Ensure that the text file uses UTF-8 encoding to avoid Chinesecharacter garbling.
Step 3: Run Text-to-Speech and Play
1. Execute the conversion command
In the piper directory, execute the following command to convert thetext to an audio file zh_audio.mp3.
root@OK8MP:~/piper# ./piper \ -m /opt/piper-voices_cut/medium_zh/zh_CN-huayan-medium.onnx \ --output_file zh_audio.mp3 < zh_test.txt
Parameter description:
Successful output example:
[piper] [info] Loaded voice in 1.99 second(s) [piper] [info] Real-time factor: 0.61 (infer=1.72 sec, audio=2.82 sec) [piper] [info] Terminated piper
-m: Specify the voiceprint model file to be used.
--output_file: Specify the name of the output audio file.
< zh_test.txt: Redirect the input text from the file.
2. Play the audio file
Use the gst - play - 1.0 tool to play the generated audio.
root@OK8MP:~/piper# gst-play-1.0 ./zh_audio.mp3
Common Questions and Solutions (Q&A)
Question 1:
Error message: ''Model file doesn't exist''
Solution: Check if the path of the voiceprint model after the -m parameter is correct. Ensure that piper - voices_cut.tar has been successfully extracted to the /opt directory and the file permissions are normal.
Question 2:
Unable to directly input Chinese on the command - line or garbled characters appear.
Solution: It is highly recommended to save the Chinese content in a text file with UTF - 8 encoding and then input it through redirection <. This is the most reliable method. (For other languages, refer to the same method and save the text in the corresponding encoding format.)
Question 3:
Error message: ''Error while loading shared libraries''
Solution: This is because the program cannot find the dependent .so library files. The problem can be solved by adding the current directory to the library search path:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:
and then execute the ./piper command again.
Expansion and Exploration
Direct input on the command - line:
For simple English tests, you can use the echo pipeline:
echo "Hello from OKMX8MP board." | ./piper -m <English model path> -f output.wav
Change different voices:
piper - voices provides a large number of voiceprint models. Easily switch by HuggingFace
Model Library downloading other .onnx models and specifying them in the -m parameter.
Refer to:
Piper GitHub Release: piper_arm64.tar.gz
Voiceprint model library (Hugging Face): rhasspy/piper-voices




