1. Obtain MP3 Files
- First, create the prompt sound
- Recommended website: None for now, you can search for MP3 audio resources online
- Format requirements:
- Sample rate: 16KHz
- Channel: Mono
- Prompt sound list, the file path:
aipi-palchat_v2/doubao/lib/axk_app/tone.h
The names of the prompt sounds must not be changed, otherwise subsequent steps may fail!
No. | Prompt Sound Array Name | Example Content |
---|---|---|
1 | tone_wozai | I'm here |
2 | tone_weipeiwang | I am your AI voice assistant. Please say: Hello Xiaoan. Start network configuration |
3 | tone_kaishipeiwang | Entering network configuration mode, please use the Ai-Thinker Mini Program or App to configure |
4 | tone_peiwangshibai | Network configuration timeout, please try again |
5 | tone_peiwangchenggong | Network configuration successful |
6 | tone_lianwangchenggong | Network connected successfully |
7 | tone_wangluoduankai | Network error, reconnecting |
8 | tone_lianwangzhong | Connecting to network |
9 | tone_lianwangshibai | Network connection failed |
10 | tone_yipeiwang | I am your AI voice assistant. Please say: Hello Xiaoan. Wake me up |
11 | tone_tuixia | Exit |
2. Audio Conversion
For your convenience, we provide a Python script that batch converts an MP3 folder to a C header file in Opus format (16kHz sample rate, mono). This script uses ffmpeg for format conversion. Please install the required dependencies before running.
▫️Script Environment Installation
- Install python3. If already installed, skip. Use python --version to check.
shell
sudo apt-get install python3
- Install ffmpeg and opus encoder
shell
sudo apt-get install ffmpeg libopus0 libopus-dev
▫️Script Usage
- Enter the MP3_Conversion folder
shell
cd MP3_Conversion
- Run the script
shell
./mp3_to_opus.py northeast_sister/ -o northeast_sister/tone.h
This command runs batch_mp3_to_opus_header_simplified.py. The first argument is the audio folder, the second is the output file path and name.
(Click to view) Success Example
(Click to view) The script outputs a .h file in the specified format
- Replace the original file
shell
cp northeast_sister/tone.h aipi-palchat_v2/doubao/lib/axk_app/tone.h
3. Build and Test
▫️Enter boubao directory
shell
cd ../doubao
▫️Build
shell
make
▫️Flash
shell
make flash COMX=/dev/ttyACM0
COMX is the serial port name, please modify according to your actual situation
4. Issues and Solutions
(Click to view) Error when installing opuslib and numpy libraries
Installation errors due to environment issues can be resolved as follows。
- Install python virtual environment tool
shell
sudo apt install python3-venv
- Create a virtual environment (e.g. in the project directory)
shell
python3 -m venv myenv
- Activate the virtual environment
shell
source myenv/bin/activate
- Reinstall dependencies
shell
pip3 install ffmpeg-python pydub numpy opuslib