LiveKit 语音活动检测插件配置要点

LiveKit 的 Silero VAD 插件在本地 CPU 上运行,用于判断用户说话与静默状态,从而支持语音对话中的轮次检测,并只在用户说话时执行语音转文字以节省资源。

LiveKit 文档 › 构建智能体 › 逻辑与结构 › 轮次检测与打断 › Silero VAD 插件 --- # Silero VAD 插件 > 用于LiveKit代理的高性能语音活动检测. ## 概览 Silero VAD插件提供语音活动检测(VAD),有助于准确 [转弯检测](https://docs.livekit.io/agents/logic/turns.md) 在语音 AI 应用程序中。 VAD是语音AI应用程序的关键组件,因为它有助于确定一个用户说话的时间和他们沉默的时间。这可以使对话中自然旋转,并有助于优化资源使用,只在用户说话时执行speech-to-text。 LiveKit 推荐使用 Silero VAD 插件与自定义结合 [转弯探测器模型](https://docs.livekit.io/agents/logic/turns/turn-detector.md) 表现最好 ## 快速引用 以下各节对 Silero VAD 插件提供了简要的概述。更多信息,请参见 [追加资源](#additional-resources). ### 所需经费 该模型在CPU上局部运行,需要最少的系统资源. ### 安装 安装 Silero VAD 插件 。 **Python 键**: 从 PyPI 安装插件 : ```shell uv add "livekit-agents[silero]~=1.8" ``` --- **节点.js**: 从 npm 安装插件 : ```shell pnpm install @livekit/agents-plugin-silero ``` ### 使用量 初始化为您的 `AgentSession` 与 Silero VAD 插件连接 : **Python 键**: ```python from livekit.plugins import silero session = AgentSession( vad=silero.VAD.load(), # ... stt, tts, llm, etc. ) ``` --- **节点.js**: ```typescript import { voice } from '@livekit/agents'; import * as silero from '@livekit/agents-plugin-silero'; const session = new voice.AgentSession({ vad: await silero.VAD.load(), // ... stt, tts, llm, etc. }); ``` ## 预温 你当然可以 [预温](https://docs.livekit.io/agents/server/options.md#prewarm) 用于改进新任务加载时间的插件 : **Python 键**: ```python from livekit.agents import AgentServer server = AgentServer() def prewarm(proc: agents.JobProcess): proc.userdata["vad"] = silero.VAD.load() server.setup_fnc = prewarm @server.rtc_session(agent_name="my-agent") async def my_agent(ctx: agents.JobContext): session = AgentSession( vad=ctx.proc.userdata["vad"], # ... stt, tts, llm, etc. ) # ... session.start etc ... if __name__ == "__main__": agents.cli.run_app(server) ``` --- **节点.js**: ```typescript import { voice, defineAgent, cli, ServerOptions, type JobContext, type JobProcess } from '@livekit/agents'; import * as silero from '@livekit/agents-plugin-silero'; import { fileURLToPath } from 'node:url'; export default defineAgent({ prewarm: async (proc: JobProcess) => { proc.userData.vad = await silero.VAD.load(); }, entry: async (ctx: JobContext) => { const vad = ctx.proc.userData.vad! as silero.VAD; const session = new voice.AgentSession({ vad, // ... stt, tts, llm, etc. }); // ... session.start etc ... }, }); cli.runApp(new ServerOptions({ agent: fileURLToPath(import.meta.url) })); ``` ## 配置 以下参数可用于 `load` 方法 : - **`min_speech_duration`** _(浮动)_(可选) - 默认 : `0.05`: 启动新语音块所需的最小发言时间。 - **`min_silence_duration`** _(浮动)_(可选) - 默认 : `0.55`: 静默时间,在发言结束后等待,以确定用户是否已经发言完毕. - **`prefix_padding_duration`** _(浮动)_(可选) - 默认 : `0.5`: 添加到每个语音块开头的补丁时间。 - **`max_buffered_speech`** _(浮动)_(可选) - 默认 : `60.0`: 在缓冲器中保留发言时间最长(秒). - **`activation_threshold`** _(浮动)_(可选) - 默认 : `0.5`: 阈值将框架视为语音。 更高的阈值会导致更保守的检测, 但可能错过软语音。 较低的阈值会导致更敏感的检测, 但可能会将噪音识别为语音 。 - **`sample_rate`** _( 线性[8000, 16000]_(可选) - 默认 : `16000`:推论的样本率(仅支持8KHz和16KHz). - **`force_cpu`** _(bool)_(可选) - 默认 : `True`:强制使用CPU进行推论. ## 追加资源 以下资源提供了使用LiveKit Silero VAD插件的更多信息. - **[Python 软件包](https://pypi.org/project/livekit-plugins-silero/)**编号: `livekit-plugins-silero` 在 PyPI 上的软件包。 - **[插件引用](https://docs.livekit.io/reference/python/livekit/plugins/silero/index.html.md#livekit.plugins.silero.VAD)**: LiveKit Silero VAD插件的参考. - **[GitHub 重传](https://github.com/livekit/agents/tree/main/livekit-plugins/livekit-plugins-silero)**:查看源代码或为LiveKit Silero VAD插件做出贡献. - **[Silero VAD项目](https://github.com/snakers4/silero-vad)**: 开源VAD型号,用于对LiveKit Silero VAD插件进行授权. - **[转写器](https://docs.livekit.io/reference/recipes/transcriber.md)**: 使用独立的VAD和STT的示例 `AgentSession`. --- 这份文件是在2026 - 11 - 30T18:24 :27.026. 本文件的最新版本见: [https://docs.livekit.io/agents/logic/turns/vad.md](https://docs.livekit.io/agents/logic/turns/vad.md). 要探索所有 LiveKit 文档,请参见 [页:1](https://docs.livekit.io/llms.txt).

查看原始来源