Installation
Install the Smart Turn plugin withExample
Check out our simple agent example to see a practical implementation of the plugin and get inspiration for your own projects, or read on for some key details.Initialisation
The Smart Turn plugin is exposed via theTurnDetection class:
Parameters
You can customise the behaviour of Smart Turn through the following parameters:| Name | Type | Default | Description |
|---|---|---|---|
buffer_in_seconds | float | 2.0 | Duration in seconds to buffer audio before processing. |
confidence_threshold | float | 0.5 | Probability threshold (0.0–1.0) for determining turn completion. |
sample_rate | int | 16000 | Audio sample rate in Hz for processing (audio is resampled automatically). |
Functionality
Start and Stop
Control turn detection with thestart() and stop() methods:
Events
The plugin emits turn detection events through the Vision Agents event system:Turn Started Event
Fired when a user begins speaking:Turn Ended Event
Fired when a user completes their turn (based on the model’s prediction and confidence threshold):Event Properties
BothTurnStartedEvent and TurnEndedEvent include the following properties:
| Property | Type | Description |
|---|---|---|
participant | Participant | Participant object with user_id and metadata. |
confidence | float|None | Confidence level of the turn detection (0.0–1.0). |
trailing_silence_ms | float|None | Milliseconds of silence after speech (TurnEnded). |
duration_ms | float|None | Duration of the turn in milliseconds (TurnEnded). |
custom | dict|None | Additional model-specific data. |
How It Works
Smart Turn uses a multi-stage pipeline to detect turn completion:- Silero VAD: Detects speech activity and segments audio
- Audio Buffering: Buffers audio based on
buffer_in_seconds - Whisper Feature Extraction: Extracts acoustic features from the audio
- Neural Turn Completion: Predicts turn completion probability using an ONNX model
- Event Emission: Emits
TurnStartedEventwhen speech begins andTurnEndedEventwhen turn completion probability exceedsconfidence_threshold

