loud-postman-20421
09/19/2025, 12:43 PMtall-airline-16756
09/19/2025, 12:43 PMtall-airline-16756
09/19/2025, 12:44 PMloud-postman-20421
09/19/2025, 12:44 PMtall-airline-16756
09/19/2025, 12:45 PMsilero.VAD.load() method. You can customize it by setting parameters like min_speech_duration and min_silence_duration to suit your needs.
2. Create a VAD Stream: Next, create a VAD stream using the .stream() method. This will help you process audio frames smoothly.
3. Push Audio Frames: Send your audio frames to the VAD stream using push_frame() in Python or pushFrame() in Node.js — whichever fits your setup.
4. Handle VAD Events: Finally, listen for important events like START_OF_SPEECH, END_OF_SPEECH, and INFERENCE_DONE to detect when speech starts and ends. Here's a quick example:
async for event in vad_stream:
if event.type == VADEventType.START_OF_SPEECH:
print("Speech started")
elif event.type == VADEventType.END_OF_SPEECH:
print("Speech ended")
If you're working with Node.js, you can try this:
for await (const event of vadStream) {
if (event.type === VADEventType.START_OF_SPEECH) {
console.log("Speech started");
} else if (event.type === VADEventType.END_OF_SPEECH) {
console.log("Speech ended");
}
}
Please feel free to reach out if you'd like me to walk you through more examples or if you have any questions along the way. I'm here to help!
Sources: Silero VAD plugin | LiveKit Docs | Silero VAD plugin | LiveKit Docs | examples/primitives/echo-agent.py | plugins/silero/src/vad.ts | basics/echo_transcriber_agent.pyloud-postman-20421
09/19/2025, 12:45 PMtall-airline-16756
09/19/2025, 12:46 PM.on() method. Here’s a little example to help you get started:
from livekit.plugins import silero
from livekit.agents import vad
class MyAgent:
def __init__(self):
self.vad = silero.VAD.load()
def on_start_of_speech(event: vad.VADEvent):
print("Speech started")
def on_end_of_speech(event: vad.VADEvent):
print("Speech ended")
self.vad.on("start_of_speech", on_start_of_speech)
self.vad.on("end_of_speech", on_end_of_speech)
If you’re interested in using decorators, we can definitely explore creating a custom wrapper together. Just let me know, and I’d be happy to guide you through it!
Sources: Silero VAD plugin | LiveKit Docs | Working with plugins | LiveKit Docs | metrics/send-metrics-to-3p/send_metrics_to_3p.py | tests/fake_vad.pyloud-postman-20421
09/19/2025, 12:48 PMtall-airline-16756
09/19/2025, 12:49 PMVADEvent isn’t actually an attribute of the VAD object. Instead, VADEvent is a separate data structure that helps represent events emitted by the VAD system. To work with these events, you’ll want to listen to the events coming from the VAD stream. Here’s a little example to guide you:
from livekit.plugins import silero
from livekit.agents import vad
vad_instance = silero.VAD.load()
vad_stream = vad_instance.stream()
async for event in vad_stream:
if event.type == vad.VADEventType.START_OF_SPEECH:
print("Speech started")
elif event.type == vad.VADEventType.END_OF_SPEECH:
print("Speech ended")
If anything isn’t clear or you’d like a hand with something else, please don’t hesitate to ask—I’m here to help!
Sources: agents/src/voice/audio_recognition.ts | livekit-plugins/livekit-plugins-silero/livekit/plugins/silero/__init__.py