Skip to main content

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 / ONNX quantization 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, default 0.5): Probability threshold (0.0 - 1.0) to trigger end-of-turn. Higher values reduce false interruptions but may increase latency.

Metadata

Release files for livekit-plugins-turn-detection 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for livekit-plugins-turn-detection 1.0.1
File Interpreter ABI Platform
livekit_plugins_turn_detection-1.0.1-py3-none-any.whl Python 3 none any Details

Release files / livekit_plugins_turn_detection-1.0.1-py3-none-any.whl

Download URL livekit_plugins_turn_detection-1.0.1-py3-none-any.whl
Size 64.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
e7a6fb46c6ed3b14b3024e5d77f8c31bdaedd2922abff839590d5cf60516e7dd
BLAKE2b-256 checksum
How to use checksums
0e5dc97e4ca865407ca17de209df4d97fab6cc660761cdc7d444d700512c472a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.21

Release history Release notifications | RSS feed

This release

1.0.1 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page