trugen-sdk) is the official Python client for building real-time avatar experiences in Python. Everything WebRTC- and audio-related — LiveKit transport, Acoustic Echo Cancellation, decoding, threading — is handled under the hood. You only ever import from trugen.
When to use it
- Desktop and GUI applications — OpenCV, Pygame, PyQt/PySide, or custom game engines
- Backend orchestration — spin up sessions from Python workers, cron jobs, or queue consumers
- Audio injection pipelines — pump pre-recorded WAV or raw PCM into a live agent conversation
- Automation & data workflows — connect avatar sessions to your existing Python stack
What the SDK provides
- 🎥 Real-time audio/video streaming — synchronised high-quality frames from the avatar
- 🔇 Built-in Acoustic Echo Cancellation — one call to
enable_audio_output()handles APM sync so the avatar never hears itself - 🟩 BGR OpenCV frames — zero-boilerplate async iterator yielding pre-converted NumPy arrays
- ⚙️ GUI runner support — thread-safe
TruGenRunnerwrapper for blocking rendering loops - 🎵 Custom audio injection — inject WAV files or raw 16-bit PCM directly into the room
- 🎙️ Microphone lifecycle management — mute/unmute, permission monitoring, device control
- 💬 Real-time captions — event hooks for streaming caption chunks and final transcripts
- 📡 Async iterator API — stream raw audio and video natively via async generators
- 🎯 Event-driven architecture — decorator-based handlers for connection, tracks, and speech events
- 📝 Fully typed — complete type hints for IDE autocompletion and safety
Requirements
- Python 3.10+
- Core dependencies (installed automatically):
livekit(>= 0.11.0)aiohttp(>= 3.8.0)
- Optional
[display]extras (for GUI examples):opencv-python(>= 4.8.0)sounddevice(>= 0.4.6)numpy(>= 1.24.0)
Installation
Package exports
Everything you need is re-exported from the top-leveltrugen package:
Next steps
Quickstart
Stream your first avatar in a Python GUI in under 5 minutes.
Authentication
Secure your API key and manage session tokens.