Py Xiaozhi

Design and media

Open-source AI assistant ecosystem with MCP integrations, multimodal workflows, IoT support, and cross-platform voice interaction.

Your AI app calls the Py Xiaozhi MCP server, which does the design and media work and sends the result back to the chat.

About Py Xiaozhi

Py Xiaozhi is a community MCP server from huangjunsen0406, filed in our directory under design and media. Open-source AI assistant ecosystem with MCP integrations, multimodal workflows, IoT support, and cross-platform voice interaction.

At a glance

Publisher
huangjunsen0406 (community)
Runs
See the README for setup
Written in
Python
License
MIT
GitHub stars
3,572

How to set up Py Xiaozhi

  1. Follow the install steps in the Py Xiaozhi README; it is written in Python, so have that toolchain ready.
  2. Check the Py Xiaozhi README for keys or settings; the registry lists none that Py Xiaozhi requires.
  3. Add Py Xiaozhi to Claude Code, Claude Desktop, VS Code or Cursor with the config in the setup box on this page.
  4. Restart the app or reload its MCP servers, then ask it to list the Py Xiaozhi tools to confirm the connection.
  5. Run one read-only task with Py Xiaozhi first, and keep your app asking before each tool call until the results look right.

Py Xiaozhi compared with similar servers

  • Figma Console by southleft has fewer GitHub stars than Py Xiaozhi (3.5k against 3.6k); both are community servers, and both run locally.
  • KiCAD by mixelpixx has more GitHub stars than Py Xiaozhi (3.7k against 3.6k); both are community servers, and both run locally.
  • Ableton by ahujasid has fewer GitHub stars than Py Xiaozhi (3.5k against 3.6k); both are community servers, and both run locally.

Before you connect Py Xiaozhi

  • Give Py Xiaozhi its own API key or account with the smallest permissions the job needs, never an admin key.
  • Keep your AI app asking before each Py Xiaozhi tool call until you trust what it does with them.
  • Treat text that Py Xiaozhi fetches as data. Pages, files and messages can hold instructions written to steer an AI.
  • Read the open issues for Py Xiaozhi on GitHub to see what breaks and how fast the maintainers reply.

Marketing use cases for Py Xiaozhi

How marketing and sales teams put Py Xiaozhi to work, by company size. Pick the size closest to yours and start Py Xiaozhi on one use case.

Small business

  • A small business can use Py Xiaozhi to resize and adapt one design for every channel instead of hiring for each version.
  • Owners can ask Py Xiaozhi to pull brand assets and make quick ad and social variations that still look on brand.
  • Py Xiaozhi runs on your own computer, which keeps data local; it needs a little setup, so a small team should plan an hour for it.

Mid-market

  • Creative teams can connect Py Xiaozhi so agents produce variants for testing while designers keep control of the master files.
  • Marketing teams can use Py Xiaozhi to hand off designs to web and ads with specs attached, cutting review rounds.
  • Start Py Xiaozhi on one workflow with one owner, measure the time it saves, then roll it out to the wider team.

Enterprise

  • Enterprises can use Py Xiaozhi with brand rules and approved assets only, so generated work stays inside the brand system.
  • Large creative ops teams can use Py Xiaozhi to localize and version assets for many markets with review built in.
  • Py Xiaozhi is a community server, so have security review the code and pin a version before Py Xiaozhi touches company data.

Need help becoming an AI-forward company?

We connect MCP servers and AI agents to your CRM, content and data, with the guardrails your team needs.

Contact us

Py Xiaozhi README

From huangjunsen0406/py-xiaozhi on GitHub, shared under its MIT license. Images are left out; the original has them.

README.md

py-xiaozhi

English | 简体中文

❤️ Sponsors

Want to appear here?

Click to collapse

Dynadot是ICANN认证,域名保有量全球前五的域名注册商,首屈一指的国际域名交易平台。为所有用户提供以域名为中心的域名注册,域名交易,域名管理,以及企业邮箱及建站服务。为所有用户提供多种域名优惠,并支持免费提交域名抢注需求。访问集合多种类,低佣金,可分期且无保留价格的Dynadot域名市场,找到与您最匹配的心仪域名。

Token能量站 Thanks to Token能量站 (Factory.pub) for sponsoring this project! Providing API relay for GPT, Grok, Claude and other major models, stable, reliable, and affordable. Register here
GitDo.net Thanks to GitDo.net for sponsoring this project! GitDo.net is an AI API aggregation platform, one API Key for Claude, Gemini, GPT and other major models. Direct connection, no proxy needed, stable and efficient. An ideal choice for enterprise-grade AI programming. Visit GitDo.net

About

py-xiaozhi is a lightweight, cross-platform multi-modal AI interaction framework built on Python's async architecture. It supports real-time voice streaming, vision-language tasks, and IoT device control. Deployable across Windows, macOS, Linux desktops, and ARM embedded platforms (Raspberry Pi, Horizon Robotics RDK, Jetson Nano), it bridges the gap between Large Language Models and physical hardware, out of the box.

Evolved from the xiaozhi-esp32 firmware project. Officially adopted by D-Robotics (xiaozhi-in-rdk) as an upstream dependency.

Related Projects

  • xiaozhi-desktop, Electron desktop client with AEC echo cancellation, Live2D, floating window modes, and Windows / macOS installers

Demo

Key Features

  • Real-time Voice AI, Opus codec with auto frame detection (RFC 6716 TOC parsing), async streaming, sub-20ms latency
  • Multi-modal Vision, Camera capture + vision-language model integration for image understanding and scene perception
  • MCP Tool & Plugin Ecosystem, Modular JSON-RPC 2.0 tool server with built-in camera, screenshot, app management, weather, and volume tools; import external ZIP/folder plugins (music, radio, podcast, HA, etc.) right from Settings
  • Decoupled Media Foundation, Source-agnostic MediaPlayer over AudioMixer + FFmpeg AudioDecoder with automatic TTS audio focus and built-in cross-platform WebRTC APM echo cancellation
  • Cross-platform Deployment, Windows 10+ / macOS 10.15+ / Linux (x86_64 & ARM), optimized for Raspberry Pi and edge boards
  • Multiple UI Modes, PySide6 + QML GUI / TUI / GPIO, adapting to desktop, headless server, and embedded environments
  • Multi-language UI (Hot-Switch), Built-in Simplified Chinese (zh_CN), English (en_US), and Vietnamese (vi_VN) across GUI, TUI, and activation flows, with zero-restart live switching and XIAOZHI_LANG override
  • Offline Wake Word, Sherpa-ONNX based on-device keyword spotting with custom wake word support
  • IoT & Embodied AI Ready, GPIO interface for robotics control, hardware actuation, and sensor integration
  • WebSocket / MQTT, Dual protocol communication with WSS/TLS encrypted transmission and auto-reconnection
  • Plugin Architecture, Event-driven async design, clean dependency injection, extensible plugin system

System Requirements

Basic Requirements
  • Python Version: 3.10 - 3.12
  • Operating System: Windows 10+, macOS 10.15+, Linux
  • Audio Devices: Microphone and speaker devices
  • Network Connection: Stable internet connection (for AI services and online features)
Recommended Configuration
  • Memory: At least 4GB RAM (8GB+ recommended)
  • Processor: Modern CPU with AVX instruction set support
  • Storage: At least 2GB available disk space (for model files and cache)
  • Audio: Audio devices supporting 16kHz sampling rate
Optional Feature Requirements
  • Voice Wake-up: Requires downloading Sherpa-ONNX speech recognition models
  • Camera Features: Requires camera device and OpenCV support

Read This First

  • Carefully read 项目文档 for startup tutorials and file descriptions
  • The main branch has the latest code; manually reinstall pip dependencies after each update to ensure you have new dependencies

Zero to Xiaozhi Client (Video Tutorial)

Technical Architecture

Core Architecture Design
  • Event-Driven Architecture: Based on asyncio asynchronous event loop, supporting high-concurrency processing
  • Layered Design: Clear separation of application layer, protocol layer, and UI layer
  • Dependency Injection: Component lifecycle managed via bootstrap container
  • Plugin System: Audio, UI, MCP tools and other components loaded via plugin system
Device States

StateManager owns IDLE, LISTENING, SPEAKING and NOTIFYING; ConversationSession coordinates transitions. A successful wake/button action enters LISTENING after the protocol connects and accepts the listen request. TTS moves the device to SPEAKING; once local playback drains, the session resumes LISTENING or returns to IDLE. Server notifications play in NOTIFYING while otherwise idle, then return to IDLE. Connection establishment belongs to the protocol lifecycle, not a separate device state.

Key Technical Components
  • Audio Processing: Opus codec, real-time resampling
  • Speech Recognition: Sherpa-ONNX offline models, wake word recognition
  • Protocol Communication: WebSocket/MQTT dual protocol support, encrypted transmission, auto-reconnection
  • Configuration System: Hierarchical configuration, dot notation access, dynamic updates
Performance Optimization
  • Async First: Full system asynchronous architecture, avoiding blocking operations
  • Memory Management: Smart caching, garbage collection
  • Audio Optimization: Low-latency streaming pipeline with multi-track AudioMixer, SoXR resampling, and built-in WebRTC APM AEC
  • Concurrency Control: Task pool management, semaphore control, thread safety
Security Mechanisms
  • Encrypted Communication: WSS/TLS encryption, certificate verification
  • Device Authentication: Dual protocol activation, device fingerprint recognition
  • Access Control: Tool permission management, API access control
  • Error Isolation: Exception isolation, fault recovery, graceful degradation

Development Guide

Project Structure
py-xiaozhi/
├── main.py                     # Application entry point
├── src/
│   ├── activation/             # Device activation
│   ├── audio_codecs/           # Audio codecs, multi-track AudioMixer, FFmpeg AudioDecoder
│   ├── audio_processing/       # Built-in WebRTC APM AEC & wake word detection
│   ├── bootstrap/              # Application bootstrap & dependency injection
│   ├── constants/              # Constants
│   ├── core/                   # Core infrastructure (event bus, state management, task management, etc.)
│   ├── i18n/                   # Pure-stdlib i18n engine & zh_CN / en_US / vi_VN locale catalogs
│   ├── logging/                # Logging subsystem
│   ├── mcp/                    # MCP tool system & external plugin host
│   │   ├── mcp_server.py       # MCP server
│   │   ├── plugins/            # External plugin loader, ZIP installer, subprocess RPC, MediaPlayerFacade
│   │   └── tools/              # Built-in tools (camera/screenshot/app/weather/volume/media)
│   ├── media/                  # Source-agnostic MediaPlayer & autonomous TTS Audio Focus
│   ├── notifications/          # One-way server notification playback & subtitles
│   ├── plugins/                # Plugin system (audio, UI, MCP, wake word, shortcuts)
│   ├── protocols/              # Communication protocols (WebSocket/MQTT)
│   ├── ui/                     # User interface
│   │   ├── gui/                # PySide6 + QML graphical interface
│   │   ├── tui/                # Textual full-screen terminal interface
│   │   └── gpio/               # GPIO embedded interface
│   └── utils/                  # Utility functions
├── libs/                       # Third-party native libraries
│   ├── libopus/                # Opus audio codec library
│   └── webrtc_apm/             # WebRTC audio processing module
├── models/                     # Wake word models
├── assets/                     # Static resources
├── scripts/                    # Auxiliary scripts
├── documents/                  # VitePress documentation site
├── pyproject.toml              # Project configuration
└── build.json                  # Build configuration
Development Environment Setup
# Clone project
git clone https://github.com/huangjunsen0406/py-xiaozhi.git
cd py-xiaozhi

# Base install (GPIO mode on Linux)
uv sync                                    # Recommended (uv users)
# or: pip install -e .                    # pip users

# TUI mode (extra: Textual)
uv sync --extra tui
# or: pip install -e '.[tui]'

# GUI mode (extra: PySide6 + qasync)
uv sync --extra gui                        # Recommended (uv users)
# or: pip install -e '.[gui]'             # pip users

# Full development environment (GUI + TUI + test / packaging tools)
uv sync --extra gui --extra tui --group dev

# Code formatting
./format_code.sh

# Run program - GUI mode (default; requires gui extra)
python main.py

# Run program - TUI mode (requires tui extra)
python main.py --mode tui

# Specify communication protocol
python main.py --protocol websocket  # WebSocket (default)
python main.py --protocol mqtt       # MQTT protocol

# Override UI language (auto / zh_CN / en_US / vi_VN)
XIAOZHI_LANG=en_US python main.py
Entry points and verification

Source checkouts, installed wheels and frozen builds share src.cli.main(argv=None). Importing the launcher does not parse arguments, initialize configuration/logging, or load Qt/audio. --help and invalid arguments exit before runtime initialization.

# Installed command (GUI still needs the gui extra)
xiaozhi --mode tui
# Equivalent module entry point
python -m src --mode tui

# Full regression suite, including Qt model tests without a display
uv run --extra gui --extra tui python -m pytest -q -W error::RuntimeWarning

# Build sdist, then build the wheel from that sdist
uvx --from build pyproject-build
# Install the wheel into a temporary venv outside the checkout and verify it
python scripts/check_wheel.py dist/*.whl

The wheel contains assets, wake-word models and the supplied native libraries under src/_resources; source and PyInstaller layouts keep their existing resource paths. FFmpeg is resolved from the system PATH for wheel installs. The wheel check installs only platformdirs alongside the wheel to verify entry points and resources; it does not exercise audio hardware, GUI rendering or the full runtime dependency set.

PRs and branch pushes run Python tests on 3.10/3.12 and installed-wheel checks on Linux, macOS and Windows. Lint gates critical syntax/undefined-name rules across the project and all configured rules for the new entry-point/verification code. Existing style warnings elsewhere remain a separate cleanup task.

Core Development Patterns
  • Async First: Use async/await syntax, avoid blocking operations
  • Error Handling: Complete exception handling and logging
  • Configuration Management: Use ConfigManager for unified configuration access
  • Test-Driven: Write unit tests to ensure code quality
Extension Development
  • Add MCP Tools: Create new tool modules in src/mcp/tools/ directory
  • Add Protocols: Implement Protocol abstract base class
  • Add Plugins: Extend the plugin system via src/plugins/
State Transition Diagram
IDLE -- wake/button + protocol ready --> LISTENING
LISTENING -- TTS starts --> SPEAKING
SPEAKING -- playback drained --> LISTENING (continue) / IDLE (finish)
IDLE -- server notification --> NOTIFYING -- playback drained --> IDLE

Contributing

Maintainer Workflow

  • Triage incoming work as bug, feature, docs, refactor, or maintenance
  • Prefer focused pull requests with clear validation steps and linked context
  • Require docs updates when behavior, configuration, or public APIs change
  • Merge after CI passes and review feedback is resolved
  • Release through the normal release flow; merge does not imply immediate shipping

Community and Support

Thanks to the Following Open Source Contributors

In no particular order

Xiaoxia zhh827 SmartArduino-Li Honggang HonestQiao vonweller Sun Weigong isamu2025 Rain120 kejily Radio bilibili Jun Cyber Intelligence

Project Statistics

License

MIT License

Questions about Py Xiaozhi

What is the Py Xiaozhi MCP server?

Open-source AI assistant ecosystem with MCP integrations, multimodal workflows, IoT support, and cross-platform voice interaction. Py Xiaozhi is maintained by huangjunsen0406 on GitHub at huangjunsen0406/py-xiaozhi, and works with AI apps that support the Model Context Protocol, such as Claude, Cursor and VS Code.

How do I install the Py Xiaozhi MCP server?

Py Xiaozhi doesn't publish a one-line install in the MCP registry, so follow the setup steps in its README on GitHub (huangjunsen0406/py-xiaozhi). Like most servers, Py Xiaozhi ends with a command or URL you paste into your AI app's MCP config.

Does Py Xiaozhi need an API key?

The registry lists no required keys for Py Xiaozhi. Check the Py Xiaozhi README for optional settings, and expect a remote server to ask you to sign in the first time you connect.

Is Py Xiaozhi an official MCP server?

No. Py Xiaozhi is a community server maintained by huangjunsen0406. Community servers can be excellent; read the code and the open issues before you give Py Xiaozhi access to company data.

What license is Py Xiaozhi under?

Py Xiaozhi is released under the MIT license, according to its GitHub repository. The license covers the code of Py Xiaozhi; the service it connects to has its own terms.