When implementing offline voice-controlled Bluetooth speaker functionality, I found that to achieve voice interruption of the currently playing Bluetooth audio, it’s necessary to resample the playing audio and then perform echo cancellation. However, I don’t know how to resample the currently playing Bluetooth audio and would appreciate any suggestions.
For self-played audio, you can directly obtain the playback data—refer to Xiao Zhi’s sample code, which already implements echo cancellation using WebRTC. If there’s a mismatch in sample rates, you can invoke the software’s sample rate conversion function.
Another approach is to use ADC to re-capture DAC output, but this requires external circuitry support, and we currently don’t have a related example available.
I also reviewed the middleware code, and it seems that implementing echo cancellation for Bluetooth audio playback might require rewriting the Bluetooth audio part of the code. I’m still not very familiar with the SDK.
Hello, regarding the use of AEC on Xiao Zhi, the following main processing steps are performed during audio initialization (open):
- Use the bi-directional audio mode (AUDIO_TXRX), where the microphone and speaker share the same audio device instance.
- Initialize Voice Activity Detection (VAD) using
WebRtcVad_Create,WebRtcVad_Init, andWebRtcVad_set_mode. - Keep the microphone constantly enabled (
thiz->is_rx_enable = 1).
Additionally, echo cancellation only supports sample rates of 16 kHz or 8 kHz.

I modified the underlying code in the SDK related to bt_sink to implement echo cancellation. The main issue currently is offline wake-up. I referred to Xiao Zhi’s program regarding offline wake-up (the kws part), but due to lack of relevant documentation, I haven’t been able to understand how it works. I would appreciate any suggestions.
Hello, does “how it works” refer to the data flow or call process, or is it about how keywords are identified?
While studying and modifying the XiaoZhi program, I found that this function can recognize keywords when the websocket disconnects, and then reconnect to the XiaoZhi server. However, I can’t find out the specific function of this code.

I was researching XiaoZhi’s program and came across the UI section where
Hello, because the implementation of this function is blocked by the library, it cannot be viewed.
Yeah, is there any documentation or sample code introducing functions related to ASR?
No, this is provided by a third party. Only a demo is available, with limitations on usage次数. There is no detailed information for commercial use; for commercial purposes, you need to contact the third party.
Provided by Youjie Company
Alright, then I’ll have to figure it out by referring to Xiao Zhi’s sample code. Thanks!