huangjunsen0406/py-xiaozhi
Open-source AI assistant ecosystem with MCP integrations, multimodal workflows, IoT support, and cross-platform voice interaction.
py‑xiaozhi – A lightweight, cross‑platform multimodal AI framework
What it is – py-xiaozhi is a Python library that lets you build an AI‑powered assistant that can listen, speak, see, and control hardware in real time. It is built on asyncio for low‑latency streaming and runs on desktops (Windows/macOS/Linux) as well as on edge devices such as Raspberry Pi, Jetson Nano or Horizon Robotics boards.
Why it matters – The project bridges large‑language‑model (LLM) services with on‑device perception (wake‑word detection, camera capture) and actuation (GPIO, MQTT). In other words, it provides a ready‑made “brain‑body” stack for embodied AI, voice assistants, or robotics prototypes without having to stitch together many separate tools.
Core capabilities
| Feature | What you get |
|---|---|
| Real‑time voice AI | Opus‑encoded audio streaming, sub‑20 ms latency, async handling of microphone and speaker. |
| Offline wake‑word | Sherpa‑ONNX keyword spotting runs locally, so the assistant can be activated without internet. |
| Vision‑language | Camera capture integrated with a vision‑language model (image understanding / scene perception). |
| MCP tool ecosystem | JSON‑RPC 2.0 “tool” server exposing utilities like music playback, screenshot, weather, volume control, etc. |
| Cross‑platform UI | PySide6 + QML graphical UI, a pure CLI mode, and a GPIO‑only mode for headless embedded boards. |
| Secure communication | WebSocket or MQTT with TLS/WSS, automatic reconnection and device fingerprint authentication. |
| Plugin architecture | Event‑driven async core, dependency‑injection container, easy to add new tools, protocols or UI plugins. |
| IoT / robotics ready | Direct GPIO access, MQTT bridge, and a modular design for sensor/actuator integration. |
Typical use‑cases
- Desktop voice assistant – Run on a laptop or PC with a GUI that shows a floating avatar, handles voice commands, plays music, shows weather, etc.
- Edge robot controller – Deploy on a Raspberry Pi or Jetson Nano, use the wake‑word to start listening, process camera frames, and drive motors via GPIO.
- Smart home hub – Connect over MQTT to other devices, expose tool APIs (e.g., turn lights on/off) while the LLM handles natural‑language intent parsing.
- Research prototype – Quickly prototype multimodal pipelines (speech → LLM → vision → actuation) without building the plumbing from scratch.
Getting started (quick‑start guide)
# 1. Clone the repo
git clone https://github.com/huangjunsen0406/py-xiaozhi.git
cd py-xiaozhi
# 2. Install dependencies (recommended: uv, otherwise pip)
uv sync # base install (CLI / GPIO mode)
# uv sync --extra gui # include PySide6 for the graphical UI
# pip install -e . # alternative for pip users
# 3. Run the assistant
# GUI mode (default when the extra is installed)
python main.py
# CLI‑only mode (no GUI, useful on headless boards)
python main.py --mode cli
# Choose communication protocol (default is WebSocket)
python main.py --protocol mqtt
Documentation – Full startup tutorials, configuration reference, and API docs are hosted at https://huangjunsen0406.github.io/py-xiaozhi/. A video walkthrough is also available on Bilibili.
Architecture at a glance
- Event‑driven async core (
asyncioloop) – all I/O (audio, network, camera) runs without blocking. - Layered design – application logic → protocol layer (WebSocket/MQTT) → UI layer (PySide6/CLI/GPIO).
- Dependency injection – a bootstrap container creates and wires components, making plugins easy to add.
- Security – TLS‑encrypted channels, device fingerprinting, and per‑tool permission checks.
Extending the framework
- Add a new MCP tool – drop a Python module under
src/mcp/tools/implementing the required JSON‑RPC methods. - Support a new protocol – subclass the abstract
Protocolclass insrc/protocols/and register it. - Create a plugin – place code in
src/plugins/and declare it in the plugin manifest; the core will load it automatically.
Community & support
- Sponsors – GitDo.net, Token能量站, 良心AI (provide aggregated API keys for Claude, Gemini, GPT, etc.).
- Contributing – see
CONTRIBUTING.mdfor the workflow; the project follows a typical PR‑review‑CI cycle. - Demo – a short Bilibili video showcases the UI and voice interaction.
License
py-xiaozhi is released under the permissive MIT License.
Bottom line – If you need a ready‑made, async‑first Python stack that couples LLM chat, speech I/O, vision, and hardware control, py-xiaozhi provides a solid, cross‑platform foundation with both GUI and headless options.
Related
- Project
- Project
- Project
- Dispatch
- Project