1. Obtain MP3 Files
- First, create the prompt sound .mp3 files.
- Recommended website: https://www.text-to-speech.cn/
- Format requirements:
- 16KHz mono audio
- 32bit depth
- Create a folder for the prompt sounds under the SDK's voice directory, for example: voice/Guangxi_Brother
- Generate all prompt sounds according to the list below and place them in the prompt sound folder
The names of the prompt sound files must not be changed, otherwise subsequent steps will be affected!
No. | Prompt Sound Type | Prompt Sound Name (Fixed) | Example Content |
---|---|---|---|
1 | Power-on prompt (first part) | shang_dian_ti_shi.mp3 | I am your AI voice assistant. You can use "Hello Xiao An". |
2 | Power-on prompt (second part 1) | kai_shi_pei_wang.mp3 | Start network configuration. |
3 | Power-on prompt (second part 2) | huan_xing_wo.mp3 | Wake me up. |
4 | Response | wo_zai.mp3 | I'm here. |
5 | Network config mode prompt | pei_wang_mo_shi.mp3 | Entering network configuration mode. Please use the Anxinke mini program or App to configure the network. |
6 | Connecting to network prompt | lian_wang_zhong.mp3 | Connecting to network. |
7 | Network connected prompt | lian_wang_cheng_gong.mp3 | Network connected successfully. |
8 | Network connection failed prompt | lian_wang_shi_bai.mp3 | Network connection failed. |
9 | Device verification code prompt | she_bei_yan_zheng_ma.mp3 | Device verification code: |
10 | Number 0 | NO_0.mp3 | 0. |
11 | Number 1 | NO_1.mp3 | 1. |
12 | Number 2 | NO_2.mp3 | 2. |
13 | Number 3 | NO_3.mp3 | 3. |
14 | Number 4 | NO_4.mp3 | 4. |
15 | Number 5 | NO_5.mp3 | 5. |
16 | Number 6 | NO_6.mp3 | 6. |
17 | Number 7 | NO_7.mp3 | 7. |
18 | Number 8 | NO_8.mp3 | 8. |
19 | Number 9 | NO_9.mp3 | 9. |
20 | Reconnect after network failure prompt | lian_wang_shi_bai_qing_chu_li.mp3 | Network connection failed, please re-enter network configuration mode. |
21 | Network exception prompt | wang_luo_yi_chang.mp3 | Network exception, reconnecting. |
22 | Sleep prompt | tui_xia_le.mp3 | Going to sleep. |
2. Audio Conversion
▫️2.1 Run Script
- Enter the voice folder
shell
cd voice
- Install script dependencies
shell
sudo pip3 install pydub opuslib numpy
- Run the audio generation script, for example: 广西表哥
shell
python3 mp3_to_opus.py 广西表哥/
▫️2.2 Replace File
- Replace the generated xiaozhi_voic.h with the one under the xiaozhi folder
shell
mv -f 广西表哥/xiaozhi_voic.h ../xiaozhi/xiaozhi_voic.h
3. Compile and Test
- Go back to the SDK
shell
cd ..
- Compile
shell
make -j
- Flash
shell
make -j p=/dev/ttyUSBx
/dev/ttyUSBx
is the actual serial port number on your computer. You can check it with the following command:
shell
ls /dev/tty*
4. Problems and Solutions
▫️Error installing opuslib and numpy libraries
The installation error is only due to environment issues. You can solve it as follows:
- Install the Python virtual environment tool
shell
sudo apt install python3-venv
- Create a virtual environment (for example, in the project directory)
shell
python3 -m venv myenv
- Activate the virtual environment
shell
source myenv/bin/activate
- Reinstall the dependencies
shell
pip3 install pydub opuslib numpy