The OpenWakeWordEventHandler class is an implementation of AsyncEventHandler designed to process Wyoming protocol events for wake word detection. It manages audio conversion, feature extraction, and multiple detector instances.
To use it, you must provide the following parameters during initialization:
threshold: The probability threshold above which a detection is triggered.trigger_level: The number of consecutive high-probability frames required before a detection is emitted.refractory_seconds: The cooldown period (in seconds) after a detection during which further detections for that specific model are ignored.state: A State object containing information about custom models.
Key behaviors:
Describe event: Responds by sending Info containing available wake models (both built-in and custom).Detect event: Configures which models the handler should actively monitor. It will load requested models and remove any previously active detectors not included in the new request.AudioStart event: Resets the audio timestamp, feature extractor, and all active detectors.AudioChunk event: Processes incoming audio chunks, extracts features, and runs them through the active detectors. If a detection meets the threshold and trigger level requirements, a Detection event is written to the client.AudioStop event: If no detections occurred during the audio stream, it sends a NotDetected event to the client.
from wyoming_openwakeword.handler import OpenWakeWordEventHandler
from wyoming_openwakeword.state import State
# Example initialization (contextual usage)
handler = OpenWakeWordEventHandler(
threshold=0.5,
trigger_level=2,
refractory_seconds=1.0,
state=my_state_instance
)