{"id":3541,"library":"livekit-plugins-silero","title":"LiveKit Silero Plugin","description":"The livekit-plugins-silero library provides a Voice Activity Detection (VAD) plugin for the LiveKit Agent Framework. It leverages the Silero VAD model to accurately detect speech versus silence, which is crucial for natural turn-taking in voice AI applications and for optimizing Speech-to-Text (STT) resource usage. The current version is 1.5.2, released as part of the LiveKit Agents framework, which follows a rapid release cadence.","status":"active","version":"1.5.2","language":"en","source_language":"en","source_url":"https://github.com/livekit/agents","tags":["ai","audio","livekit","realtime","voice","webrtc","vad"],"install":[{"cmd":"pip install livekit-plugins-silero","lang":"bash","label":"Basic Installation"},{"cmd":"pip install \"livekit-agents[silero]\"","lang":"bash","label":"Installation with livekit-agents"},{"cmd":"python -m livekit.agents.cli download-files","lang":"bash","label":"Download Silero model weights"}],"dependencies":[{"reason":"This is a plugin for the LiveKit Agent Framework.","package":"livekit-agents"}],"imports":[{"symbol":"silero","correct":"from livekit.plugins import silero"},{"note":"VAD is typically accessed via the top-level 'silero' import (e.g., `silero.VAD.load()`), but the class itself is in `livekit.plugins.silero.vad` if direct import is needed.","wrong":"from livekit.plugins.silero import VAD","symbol":"VAD","correct":"from livekit.plugins.silero.vad import VAD"}],"quickstart":{"code":"import asyncio\nimport os\n\nfrom livekit.agents import AgentServer, AgentSession, JobContext, JobProcess, cli\nfrom livekit.plugins import silero\n\n# Ensure LiveKit credentials are set up as environment variables\n# LIVEKIT_URL, LIVEKIT_API_KEY, LIVEKIT_API_SECRET\n\nserver = AgentServer()\n\ndef prewarm(proc: JobProcess):\n    # Load the VAD model once per process for faster job startup\n    print(\"Prewarming Silero VAD model...\")\n    proc.userdata[\"vad\"] = silero.VAD.load()\n    print(\"Silero VAD model prewarmed.\")\n\nserver.setup_fnc = prewarm\n\n@server.rtc_session(agent_name=\"my-silero-agent\")\nasync def my_agent(ctx: JobContext):\n    print(f\"Agent {ctx.agent_name} received job {ctx.job_id}\")\n    await ctx.connect()\n\n    # Retrieve the prewarmed VAD instance\n    vad = ctx.proc.userdata[\"vad\"]\n\n    # Example: Initializing AgentSession with Silero VAD\n    session = AgentSession(\n        ctx,\n        vad=vad,\n        # Other components like STT, TTS, LLM would go here\n        # stt=...,\n        # tts=...,\n        # llm=...,\n    )\n\n    print(\"Agent session started with Silero VAD.\")\n    try:\n        await session.start()\n        # Keep the agent running, e.g., for a conversation loop\n        await asyncio.sleep(600) # Keep alive for 10 minutes\n    finally:\n        await session.end()\n        print(\"Agent session ended.\")\n\nif __name__ == \"__main__\":\n    # Important: Download model weights before first run:\n    # python -m livekit.agents.cli download-files\n    \n    # Set dummy credentials for runnable quickstart if not in environment\n    os.environ.setdefault('LIVEKIT_URL', os.environ.get('LIVEKIT_URL', 'wss://your-livekit-server.livekit.cloud'))\n    os.environ.setdefault('LIVEKIT_API_KEY', os.environ.get('LIVEKIT_API_KEY', 'SK_XXXXX'))\n    os.setdefault('LIVEKIT_API_SECRET', os.environ.get('LIVEKIT_API_SECRET', 'YOUR_SECRET'))\n\n    cli.run_app(server)","lang":"python","description":"This quickstart demonstrates how to integrate `livekit-plugins-silero` into a LiveKit Agent. It sets up an `AgentServer` with a `prewarm` function to load the Silero VAD model efficiently once per process. The `my_agent` entrypoint then retrieves the prewarmed VAD instance and initializes an `AgentSession` with it, enabling voice activity detection for the agent. Remember to download model weights before running."},"warnings":[{"fix":"Update `AgentSession` initialization to use the `turn_handling` parameter with a `TurnHandlingOptions` dictionary. For example, to opt out of adaptive interruption and use VAD-only interruption, set `turn_handling={'interruption': {'mode': 'vad'}}`.","message":"LiveKit Agents v1.5.0 introduced significant changes to how turn handling (including VAD settings) is configured. Old keyword arguments like `min_endpointing_delay` and `allow_interruptions` in `AgentSession` are deprecated and will be removed in v2.0. Users should migrate to the new `TurnHandlingOptions` dictionary.","severity":"breaking","affected_versions":">=1.5.0"},{"fix":"Run `python -m livekit.agents.cli download-files` from your terminal or include this command in your deployment script.","message":"The Silero VAD model weights are not bundled with the package and must be downloaded separately before the first use. Failure to do so will result in runtime errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"It is highly recommended to prewarm the VAD model by loading it once in an `AgentServer`'s `setup_fnc` (or similar pre-job hook) and then passing the preloaded instance to each `AgentSession`.","message":"Loading the Silero VAD model via `silero.VAD.load()` is a blocking operation. Calling it directly within each agent session's entrypoint can lead to slow startup times for new jobs.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If GPU inference is desired, set `force_cpu=False` when calling `silero.VAD.load()` and verify your `onnxruntime-gpu` installation and environment are correctly configured to utilize the GPU.","message":"By default, Silero VAD runs on the CPU. While it supports GPU acceleration (e.g., with `onnxruntime-gpu`), explicitly setting `force_cpu=False` during loading and ensuring the correct GPU environment is configured is necessary. Simply installing `onnxruntime-gpu` might not be sufficient to guarantee GPU utilization.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}