End of utterance detection for LiveKit Agents
Project description
LiveKit Turn Detection Plugin (Vietnamese)
A specialized turn detection plugin for LiveKit Agents, optimized for Vietnamese language contexts. This plugin uses a local ONNX model to predict the end of a user's turn with high accuracy and low latency.
Features
- Vietnamese Optimized: Fine-tuned for Vietnamese conversational patterns.
- Local Inference: Runs ONNX model locally for privacy and speed.
- Context Aware: Considers preceding assistant messages for better prediction accuracy.
- Lightweight: Uses
SafeTensor/ONNXquantization for minimal memory footprint.
Development Workflow
flowchart TD
Train[Train BERT Model] -->|Export| Export[Export to ONNX]
Export -->|Copy & Replace| Replace[Replace livekit/plugins/turn_detection/model_quantized.onnx]
Replace -->|Build| Build[Build Wheel .whl]
Build -->|Push| Push[Push to S3 or PyPI]
Push -->|Install via uv/pip| Install[Install in Target Project]
Build Instructions
You can build the package wheel using uv (recommended) or build.
Build Wheel
Run the build command in the project root:
uv build
This will create a .whl file in the dist/ directory (e.g., dist/livekit_plugins_turn_detection-1.0.0-py3-none-any.whl).
Installation
You can verify the build and install the generated wheel file directly into your environment:
pip install dist/livekit_plugins_turn_detection-1.0.0-py3-none-any.whl
Usage
Integrate the TurnDetectionModel into your LiveKit VoicePipelineAgent.
Basic Integration
from livekit.agents import JobContext, WorkerOptions, cli
from livekit.agents.voice import Agent, AgentSession
from livekit.plugins import openai, silero
from livekit.plugins.turn_detection import TurnDetectionModel
class Assistant(Agent):
def __init__(self) -> None:
super().__init__()
async def entrypoint(ctx: JobContext):
await ctx.connect()
session = AgentSession(
vad=silero.VAD.load(),
stt=openai.STT(language="vi"),
llm=openai.LLM(),
tts=openai.TTS(),
# Initialize the turn detector
turn_detection=TurnDetectionModel(threshold=0.5),
)
await session.start(
agent=Assistant(),
room=ctx.room
)
if __name__ == "__main__":
cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint))
Configuration
The TurnDetectionModel accepts the following parameters:
threshold(float, default0.5): Probability threshold (0.0 - 1.0) to trigger end-of-turn. Higher values reduce false interruptions but may increase latency.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file livekit_plugins_turn_detection-1.0.1-py3-none-any.whl.
File metadata
- Download URL: livekit_plugins_turn_detection-1.0.1-py3-none-any.whl
- Upload date:
- Size: 64.2 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7a6fb46c6ed3b14b3024e5d77f8c31bdaedd2922abff839590d5cf60516e7dd
|
|
| MD5 |
c89a495f4bd6f0028aaa0c2cf13ff6e1
|
|
| BLAKE2b-256 |
0e5dc97e4ca865407ca17de209df4d97fab6cc660761cdc7d444d700512c472a
|