Skip to content

1. Obtain MP3 Files

  • First, create the prompt sound .mp3 files.
  • 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 TypePrompt Sound Name (Fixed)Example Content
1Power-on prompt (first part)shang_dian_ti_shi.mp3I am your AI voice assistant. You can use "Hello Xiao An".
2Power-on prompt (second part 1)kai_shi_pei_wang.mp3Start network configuration.
3Power-on prompt (second part 2)huan_xing_wo.mp3Wake me up.
4Responsewo_zai.mp3I'm here.
5Network config mode promptpei_wang_mo_shi.mp3Entering network configuration mode. Please use the Anxinke mini program or App to configure the network.
6Connecting to network promptlian_wang_zhong.mp3Connecting to network.
7Network connected promptlian_wang_cheng_gong.mp3Network connected successfully.
8Network connection failed promptlian_wang_shi_bai.mp3Network connection failed.
9Device verification code promptshe_bei_yan_zheng_ma.mp3Device verification code:
10Number 0NO_0.mp30.
11Number 1NO_1.mp31.
12Number 2NO_2.mp32.
13Number 3NO_3.mp33.
14Number 4NO_4.mp34.
15Number 5NO_5.mp35.
16Number 6NO_6.mp36.
17Number 7NO_7.mp37.
18Number 8NO_8.mp38.
19Number 9NO_9.mp39.
20Reconnect after network failure promptlian_wang_shi_bai_qing_chu_li.mp3Network connection failed, please re-enter network configuration mode.
21Network exception promptwang_luo_yi_chang.mp3Network exception, reconnecting.
22Sleep prompttui_xia_le.mp3Going 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

  1. Go back to the SDK
shell
cd ..
  1. Compile
shell
make -j
  1. 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

Released under the MIT License.