Registry / ai-ml / livekit-plugins-turn-detector

livekit-plugins-turn-detector

JSON →
library1.7.1pypypi✓ verified 23d ago

livekit-plugins-turn-detector provides end-of-utterance detection for LiveKit Agents, leveraging machine learning to differentiate between genuine interruptions and incidental background noises. It is an integral part of LiveKit Agents' adaptive interruption handling introduced in v1.5.0. The current version is 1.5.2, and it typically releases in conjunction with major livekit-agents updates.

pip install livekit-plugins-turn-detector
INSTALL
IMPORT
SIG · LIVEKIT-PLUGINS-TU
L
livekit-plugins-turn-detector
ai-mlpythonv1.7.1
Install
17.0s avg
Import
Disk
498MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.3.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.1s · import 0.000s · 393.3MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 30.4s · import 0.000s · 605MB
498MB installed
● package 498MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

TurnDetector
from livekit.plugins.turn_detector import TurnDetector
from livekit.plugins.turn_detector import TurnDetector

Demonstrates how to initialize the `TurnDetector`, feed it simulated audio frames, and listen for `TurnStarted` and `TurnFinished` events. This illustrates the core API for integrating turn detection into an audio processing pipeline.

import asyncio import numpy as np from livekit.agents.utils import AudioFrame from livekit.plugins.turn_detector import TurnDetector, TurnStarted, TurnFinished async def quickstart_turn_detector(): print("Initializing TurnDetector...") # TurnDetector.create() is an async factory method detector = await TurnDetector.create() # Simulate an audio stream (e.g., 16kHz mono audio) sample_rate = 16000 num_silent_frames = 50 # 500ms of silence (50 * 10ms frames) num_speech_frames = 100 # 1 second of speech frame_size = int(sample_rate * 0.01) # 10ms frame async def simulate_audio(): # Silence for _ in range(num_silent_frames): frame = AudioFrame(np.zeros(frame_size, dtype=np.int16), sample_rate, 1) await detector.push_frame(frame) await asyncio.sleep(0.01) # Simulate real-time print("Simulated silence.") # Speech (simulated non-zero audio) for i in range(num_speech_frames): t = np.linspace(0, 0.01, frame_size, endpoint=False) sine_wave = (np.sin(2 * np.pi * 440 * t) * 1000).astype(np.int16) frame = AudioFrame(sine_wave, sample_rate, 1) await detector.push_frame(frame) if i == 0: print("Simulating speech...") await asyncio.sleep(0.01) # Post-speech silence for _ in range(num_silent_frames): frame = AudioFrame(np.zeros(frame_size, dtype=np.int16), sample_rate, 1) await detector.push_frame(frame) await asyncio.sleep(0.01) print("Simulated post-speech silence. Closing detector.") # Signal end of stream await detector.flush() # Process events from the detector async def process_events(): async for event in detector.detect_turns(): if isinstance(event, TurnStarted): print(f"Turn Started at timestamp {event.timestamp}") elif isinstance(event, TurnFinished): print(f"Turn Finished at timestamp {event.timestamp}, duration: {event.duration}s") # Run both concurrently await asyncio.gather(simulate_audio(), process_events()) print("Quickstart finished.") if __name__ == "__main__": asyncio.run(quickstart_turn_detector())
Debug
Known issues
gotchaStarting with `livekit-agents` 1.5.0, adaptive interruption handling, powered by this plugin, is enabled by default. This significantly changes the default VAD (Voice Activity Detection) behavior and might override custom VAD configurations if not explicitly managed. Users upgrading from older `livekit-agents` versions should be aware of this behavioral shift.
fix
Review `livekit-agents` documentation on VAD and interruption handling for version 1.5.0+ to understand the new defaults and customization options.
affects: livekit-agents >=1.5.0
gotchaThe plugin has significant dependencies, notably `transformers[torch]`. This leads to a large installation size and introduces `torch` as a dependency, which can have performance implications and specific hardware requirements (e.g., GPU for faster inference).
fix
Ensure your environment meets the resource requirements for `transformers` and `torch`. If memory or CPU usage is a concern, monitor the agent's performance. Consider installing specific CPU-only versions of `torch` if GPU is not available or desired.
affects: all
gotchaVersions of `livekit-plugins-turn-detector` prior to 1.5.1 had a stricter upper bound on the `transformers` dependency. This could lead to dependency conflicts if other libraries in your project required a newer or different `transformers` version.
fix
Upgrade to `livekit-plugins-turn-detector` version 1.5.1 or newer to benefit from relaxed dependency constraints. If upgrading is not possible, carefully manage your `transformers` version to match the requirements.
affects: <1.5.1
gotchaThis plugin is specifically designed to work within the LiveKit Agents ecosystem. While the underlying ML model might be general-purpose, the `TurnDetector` class and its event handling are tightly integrated with LiveKit's audio stream processing and agent lifecycle.
fix
Use this plugin in conjunction with `livekit-agents`. For general-purpose VAD or turn detection outside of LiveKit, consider standalone libraries or direct use of the underlying `transformers` model.
affects: all
Upgrade
Version history
1.7.1latest on PyPI · released Aug 27, 2026
Audit
Dependencies
livekit-agentsrequiredCore framework this plugin extends.
transformersrequiredRequired for the underlying machine learning model, specifically the 'torch' extra, which is pulled automatically.
numpyrequiredUsed for audio frame data manipulation.
soundfilerequiredAudio I/O utilities.
Agent activity
28 hits · last 30 days
node
24
Bingbot
1
OpenAI (training)
1
Resources
livekit-plugins-turn-detector — pip install livekit-plugins-turn-detector · libregistry