TruGenSession and TruGenRunner is event-driven. Register handlers with decorators; the SDK invokes them on the correct thread as events fire.
You have two entry points:
@runner.on_*decorators on aTruGenRunner— main-thread callbacks, ideal for UI updates@session.on()decorator on aTruGenSession— low-level async callbacks, run on the session’s event loop
Runner Decorators
@runner.on_frame
Receives BGR video frames (NumPy arrays) or None on the main thread. Fired on every new frame.
@runner.on_caption
Receives real-time streaming caption chunks — ideal for UI overlays.
@runner.on_state
Called when the session’s connection state transitions.
@runner.on_event
Handles any standard TruGenEvent enum or custom string event.
Session Decorators
If you’re not usingTruGenRunner, listen to events directly on the TruGenSession using @session.on():
Common patterns
Connection lifecycle
Reconnection handling
Transient network drops emitconnection.reconnecting and connection.reconnected as string events:
Speaking indicators
Microphone permission lifecycle
Next steps
List all events
Complete reference of every event the SDK emits.
Audio Control
Programmatically control the mic and inject audio.