Welcome to Raspberry Pi 5 repository
05. AI Voice Interaction Configuration
OpenClaw AI Voice Interaction Configuration
OpenClaw AI Voice Interaction Configuration1. Course Overview2. Overall Voice Interaction Chain3. Voice Configuration File Description3.1 Configuration File Location3.2 Minimum Configuration Checks Before Startup4. Key Parameter Description4.1 Voice Recognition Engine4.2 Microphone and Speaker Devices4.3 TTS Voice Broadcast Configuration4.4 OpenClaw Gateway Configuration Reference4.5 Serial Wake Configuration4.6 Chinese-English Switching Steps5. Start Voice Interaction5.1 Prepare Virtual Environment5.2 Startup Method6. Configuration Verification Methods6.1 Verify Voice Program Can Start6.2 Verify Recognition and Publishing Process6.3 Verify TTS [Optional]7. Common Problems7.1 Program Fails to Start7.2 No Recognition Result After Wake7.3 Recognition Succeeds But OpenClaw Has No Response7.4 Can Recognize But No Sound Broadcast7.5 Serial Wake Fails8. Recommended Debugging Order
1. Course Overview
This course will introduce how to configure the AI voice interaction chain of OpenClaw, including the voice configuration file location, key parameter descriptions, startup methods, and common problem troubleshooting.
After completing this course, you will be able to:
- Know which configuration file the AI voice interaction uses
- Understand the meaning of key parameters in
.env - Master how to switch between Chinese and English voice recognition
- Correctly start the voice program
2. Overall Voice Interaction Chain
OpenClaw's current voice interaction process can be simply understood as:
- Microphone collects voice
- Program performs silence detection and segmentation
- ASR engine recognizes voice into text
- Recognition result is published to OpenClaw
- OpenClaw returns result
[Optional]TTS broadcasts the returned result (the reply content will be very long, you can choose whether to broadcast yourself)
The core configuration file for this chain is:
/home/pi/voice_to_openclaw/.env3. Voice Configuration File Description
3.1 Configuration File Location
Default use factory image
xxxxxxxxxx/home/pi/voice_to_openclaw/.envIf this file does not exist, you can copy from the template first:
xxxxxxxxxxcd /home/pi/voice_to_openclawcp .env.example .env3.2 Minimum Configuration Checks Before Startup
It is recommended to confirm at least the following items:
ASR_ENGINEDASHSCOPE_API_KEYDASHSCOPE_LANGUAGEorXUNFEI_ASR_LANGUAGEDEVICESPEAKER_DEVICEOPENCLAW_CONFIG_PATHENABLE_SERIAL_WAKE
4. Key Parameter Description
4.1 Voice Recognition Engine
xxxxxxxxxxASR_ENGINE=dashscopeCurrently supports three modes:
dashscope: Tongyi Bailian native voice recognition interface, suitable for direct network usexunfei_ws: iFlytek WebSocket voice recognition, suitable for overseas version configurationfaster_whisper: Local Whisper recognition, suitable for local running (not supported on Raspberry Pi)
4.2 Microphone and Speaker Devices
xxxxxxxxxxDEVICE=0SPEAKER_DEVICE=0These two parameters determine which audio input and output devices the program uses.
Scenarios suitable for modification:
- Multiple microphone devices
- USB microphone is not the system default device
- Speaker output to the wrong device
If the voice program can start but you cannot hear sound or record sound, check here first.
4.3 TTS Voice Broadcast Configuration
xxxxxxxxxxENABLE_TTS=falseWAKE_ACK_TEXT=I am hereIf you want voice broadcast after voice recognition, you can enable:
xxxxxxxxxxENABLE_TTS=trueCurrently common TTS parameters include:
DASHSCOPE_TTS_MODELDASHSCOPE_TTS_VOICEDASHSCOPE_TTS_VOLUMEDASHSCOPE_TTS_SPEECH_RATE
It is recommended to first get the ASR working, then consider enabling TTS.
4.4 OpenClaw Gateway Configuration Reference
xxxxxxxxxxOPENCLAW_CONFIG_PATH=~/.openclaw/openclaw.jsonOPENCLAW_TIMEOUT=70 #Maximum retry time, waiting for OpenClaw reply. If it's a very long task, it is recommended to increase this timeOPENCLAW_RETRY=1This part of the configuration determines how the voice program sends recognition results to OpenClaw.
By default:
- The program will read
openclaw.json - Automatically derive the local gateway port
- Automatically read the gateway authentication token
Therefore, if voice recognition has succeeded but OpenClaw has not executed instructions, check here first.
4.5 Serial Wake Configuration
xxxxxxxxxxENABLE_SERIAL_WAKE=trueMIC_SERIAL_PORT=/dev/ttyUSB0MIC_SERIAL_BAUDRATE=115200SERIAL_WAKE_REQUIRED=trueIf you are using the factory voice module, serial wake mode is usually used.
Main functions:
- Normally wait for wake signal
- After receiving wake, start collecting the next voice segment
- After processing is complete, return to waiting state again
If you do not have a factory serial wake module, you can adjust according to needs:
xxxxxxxxxxENABLE_SERIAL_WAKE=false4.6 Chinese-English Switching Steps
If you need to switch voice interaction from Chinese to English, it is recommended to directly modify the language parameter in .env, then restart the program.
Currently, voice_to_openclaw/.env defaults to the domestic version (Bailian).
Overseas Version (iFlytek International)
Main configuration items:
xxxxxxxxxxXUNFEI_ASR_LANGUAGE=en_cnXUNFEI_ASR_ACCENT=mandarin- Chinese recognition:
XUNFEI_ASR_LANGUAGE=zh_cn - English recognition:
XUNFEI_ASR_LANGUAGE=en_us - When recognition language is changed to English,
XUNFEI_ASR_ACCENTis no longer needed; you can comment it out or keep the original value unused
Example:
x# Chinese recognitionXUNFEI_ASR_LANGUAGE=zh_cnXUNFEI_ASR_ACCENT=mandarin# English recognitionXUNFEI_ASR_LANGUAGE=en_us# XUNFEI_ASR_ACCENT=mandarinIf TTS is enabled at the same time and you want English broadcast, you also need to change TTS_VOICE to the English voice you have enabled; if you just want to verify English recognition first, only change ASR language.
After modification, just re-execute the startup command below to take effect.
5. Start Voice Interaction
5.1 Prepare Virtual Environment
Factory image does not need this step. If dependencies are not installed yet, execute first:
xxxxxxxxxxcd /home/pi/voice_to_openclawpython3 -m venv .venvsource .venv/bin/activatepip install -r requirements.txt5.2 Startup Method
xxxxxxxxxxcd /home/pi/voice_to_openclawsource .venv/bin/activatepython -m src.mainIf startup is successful, the program will enter the state of waiting for wake or waiting for voice input.
6. Configuration Verification Methods
6.1 Verify Voice Program Can Start
Execute:
xxxxxxxxxxcd /home/pi/voice_to_openclawsource .venv/bin/activatepython -m src.mainIf the program starts successfully and does not immediately report an error, the basic environment is probably normal.
6.2 Verify Recognition and Publishing Process
After saying "Hi,yahboom" to wake up, you can try saying:
- Tell me a joke
- Display "Hello" on OLED
If you can see OpenClaw return text, it means:
- Microphone collection is normal
- ASR is normal
- OpenClaw gateway publishing is normal

6.3 Verify TTS [Optional]
If already enabled:
xxxxxxxxxxENABLE_TTS=trueThen after OpenClaw returns results, you should hear voice broadcast.
7. Common Problems
7.1 Program Fails to Start
Check in order:
- Whether
.venvexists - Whether dependencies are installed
- Whether
.envexists
7.2 No Recognition Result After Wake
Check in order:
- Whether
ASR_ENGINEis configured correctly - Whether
DASHSCOPE_API_KEYis valid - Whether microphone device number
DEVICEis correct
7.3 Recognition Succeeds But OpenClaw Has No Response
Check in order:
- Whether
OPENCLAW_CONFIG_PATHis correct - Whether the gateway port in
openclaw.jsonis normal - Whether OpenClaw gateway is started
7.4 Can Recognize But No Sound Broadcast
Check in order:
- Whether
ENABLE_TTSistrue - Whether
SPEAKER_DEVICEis correct - Whether the speaker is connected properly
7.5 Serial Wake Fails
Check in order:
- Whether
ENABLE_SERIAL_WAKEistrue - Whether
MIC_SERIAL_PORTis correct - Whether
MIC_SERIAL_BAUDRATEis correct - Whether the voice module serial device is recognized by the system
8. Recommended Debugging Order
It is recommended to troubleshoot the voice chain in the following order:
- First confirm the
.envfile exists - Then confirm
DASHSCOPE_API_KEYis filled in - Start the program and confirm no immediate error
- Check if wake takes effect
- Check if recognition takes effect
- Check if OpenClaw receives text
- Finally check TTS broadcast