Rdzleo 8111515277 修复 Pendant 衍生项目无痛移植问题
实机验证通过后,按 Kapi 无屏底座路线补齐 Pendant RTC 吊坠项目的迁移修复。

1. BLE 配网与资源隔离
- sdkconfig.defaults 开启 BT 优先 PSRAM 分配,并将 LWIP socket 上限提升到 20
- sdkconfig.defaults.esp32s3 允许 BSS/NOINIT 放入 PSRAM,释放内部 SRAM 给 BLE/WiFi/RTC
- 配网模式 codec 使用 StartOutputOnly(),跳过麦克风 RX DMA 和 ES7210 输入链路
- ResetWifiConfiguration() 改为独立 wifi_reset task,避免在 iot_button/esp_timer 回调中阻塞延时
- WifiBoard 增加 IsWifiConfigMode(),供启动阶段判断是否走配网资源隔离路径

2. 音频底噪与 DMA 残留修复
- AudioCodec 增加 StartOutputOnly(),支持仅启动扬声器输出
- RTC 音频通道打开后灌入 200ms silence PCM,覆盖 I2S DMA 残留数据
- 软退出进入待命前重启 codec output 并再次灌静音,减少待命音/欢迎语前杂音
- box_audio_codec 在无硬件回采时使用 channel_mask=0,避免 I2S slot mask 被错误污染

3. 软件 loopback AEC
- 引入 esp_aec 底层同步 API,使用 DAC 输出复制构建 ref ring
- 上行 mic PCM 与延迟 ref 做同步消回声,适配无屏无硬件回采的 Pendant 形态
- AEC 采用 lazy init,减少启动阶段对 WiFi/BLE 内部 SRAM 的压力
- ref 静音时直接 passthrough,避免 AI 静音后误压制用户语音
- 在 player_pipeline_write 和 codec->OutputData 两条下行路径都追加 ref hook

4. RTC 连接稳定性与软退出
- VolcRtcProtocol 增加 LeaveRoom(bool notify_closed),支持 stop 房间但保留 rtc_handle
- hibernate 路径使用 LeaveRoom(false),避免关闭回调顺手关掉 codec output 导致待命音无声
- LeaveRoom/ForceRebuildEngine 重置 downlink_is_pcm_ 和首包标志,避免本地 Opus 音效被当 PCM 播成杂音
- OpenAudioChannel 连续失败 3 次后 ForceRebuildEngine,清理 RTC SDK 内部异常状态
- 加入 DIAG-RTC socket/heap/PSRAM/RSSI 日志,便于定位 ICE socket 和内存问题

5. Dialog watchdog 与 BOOT 唤醒
- Dialog watchdog 到期不再写 reboot_dlg_idle 后 esp_restart
- 新增 EnterIdleHibernate():软退房、清空残留音频队列、关闭麦克风、播放待命音后静默
- 新增 WakeFromHibernate():BOOT 唤醒后复用 RTC engine 并通过 ToggleChatState() 重连 RTC
- BOOT 单击优先判断 IsHibernating(),异步唤醒,避免走普通按键状态机
- hibernate 期间禁止 PowerSaveTimer 进入 Light Sleep,保护 I2C/codec 总线

6. 文档与衍生项目沉淀
- 更新石头光源属性检测方案文档
- 将 Pendant 实测通过的软退出、AEC、BLE 配网隔离经验同步到衍生项目移植规则
2026-05-29 13:36:36 +08:00

XiaoZhi AI Chatbot

(中文 | English | 日本語)

Introduction

👉 Build your AI chat companion with ESP32+SenseVoice+Qwen72B!【bilibili】

👉 Equipping XiaoZhi with DeepSeek's smart brain【bilibili】

👉 Build your own AI companion, a beginner's guide【bilibili】

Project Purpose

This is an open-source project released under the MIT license, allowing anyone to use it freely, including for commercial purposes.

Through this project, we aim to help more people get started with AI hardware development and understand how to implement rapidly evolving large language models in actual hardware devices. Whether you're a student interested in AI or a developer exploring new technologies, this project offers valuable learning experiences.

Everyone is welcome to participate in the project's development and improvement. If you have any ideas or suggestions, please feel free to raise an Issue or join the chat group.

Learning & Discussion QQ Group: 376893254

Implemented Features

  • Wi-Fi / ML307 Cat.1 4G
  • BOOT button wake-up and interruption, supporting both click and long-press triggers
  • Offline voice wake-up ESP-SR
  • Streaming voice dialogue (WebSocket or UDP protocol)
  • Support for 5 languages: Mandarin, Cantonese, English, Japanese, Korean SenseVoice
  • Voice print recognition to identify who's calling AI's name 3D Speaker
  • Large model TTS (Volcano Engine or CosyVoice)
  • Large Language Models (Qwen, DeepSeek, Doubao)
  • Configurable prompts and voice tones (custom characters)
  • Short-term memory, self-summarizing after each conversation round
  • OLED / LCD display showing signal strength or conversation content
  • Support for LCD image expressions
  • Multi-language support (Chinese, English)

Hardware Section

Breadboard DIY Practice

See the Feishu document tutorial:

👉 XiaoZhi AI Chatbot Encyclopedia

Breadboard demonstration:

Breadboard Demo

Supported Open Source Hardware

Firmware Section

Flashing Without Development Environment

For beginners, it's recommended to first use the firmware that can be flashed without setting up a development environment.

The firmware connects to the official xiaozhi.me server by default. Currently, personal users can register an account to use the Qwen real-time model for free.

👉 Flash Firmware Guide (No IDF Environment)

Development Environment

  • Cursor or VSCode
  • Install ESP-IDF plugin, select SDK version 5.3 or above
  • Linux is preferred over Windows for faster compilation and fewer driver issues
  • Use Google C++ code style, ensure compliance when submitting code

Developer Documentation

AI Agent Configuration

If you already have a XiaoZhi AI chatbot device, you can configure it through the xiaozhi.me console.

👉 Backend Operation Tutorial (Old Interface)

Technical Principles and Private Deployment

👉 Detailed WebSocket Communication Protocol Documentation

For server deployment on personal computers, refer to another MIT-licensed project xiaozhi-esp32-server

Star History

Star History Chart
Description
本项目为AI智能吊坠项目,基于RTC底座进行开发!
Readme MIT 16 MiB
Languages
C++ 67.6%
C 25.3%
Python 6.5%
CMake 0.6%