boundless-battery-65494
08/11/2025, 12:24 PMtall-airline-16756
08/11/2025, 12:24 PMtall-airline-16756
08/11/2025, 12:26 PMnpm install @livekit/agents-plugin-silero @livekit/client
2. Set Up VAD and Silence Monitoring: Next, use the Silero VAD plugin to keep an ear on the audio and spot those longer silence periods:
import { Room } from 'livekit-client';
import { SileroVAD } from '@livekit/agents-plugin-silero';
const room = new Room({
url: '<ws://localhost:7880>',
token: 'your-token',
});
const vad = new SileroVAD();
const SILENCE_THRESHOLD = 5000; // 5 seconds
let userLastSpokeTime = Date.now();
vad.on('speechStart', () => {
userLastSpokeTime = Date.now();
});
setInterval(() => {
if (Date.now() - userLastSpokeTime > SILENCE_THRESHOLD) {
console.log('Silence threshold exceeded, potential voicemail detected');
handleVoicemailDetection();
}
}, 1000);
3. Implement LLM-Based Voicemail Detection: To boost accuracy, you can have an LLM analyze the audio once silence is detected:
async function handleVoicemailDetection() {
try {
const llmResponse = await analyzeAudioWithLLM();
if (llmResponse.detectedVoicemail) {
console.log('Voicemail detected by LLM');
await leaveVoicemailMessage();
}
} catch (error) {
console.error('Error handling voicemail detection:', error);
}
}
4. Combine VAD and LLM Detection: The magic happens when you bring both VAD and LLM-based detection together for a solid voicemail identification experience.
If you want more details or examples, just give me a shout—I’m here to help!
Sources: Configuring turn detection and interruptions | LiveKit Docsboundless-battery-65494
08/14/2025, 4:06 AMtall-airline-16756
08/14/2025, 4:07 AMconst { SileroVAD } = require('@livekit/agents-plugin-silero');
const vad = new SileroVAD({
threshold: 0.6,
prefixPaddingMs: 200,
silenceDurationMs: 500
});
vad.on('silenceDetected', () => {
console.log('Silence detected, potential voicemail.');
handleVoicemailDetection();
});
2. Integrate LLM-Based Detection: Once you catch that silence, you can use an LLM to analyze what’s going on and confirm if it’s voicemail:
async function handleVoicemailDetection() {
try {
await session.generateReply({
instructions: "This appears to be a voicemail system. Leaving a message."
});
await hangupCall();
} catch (error) {
console.error('Error handling voicemail detection:', error);
}
}
3. Combine VAD and LLM: Putting both together gives you a solid way to identify voicemail reliably. Here’s how you might do it:
const { VoicePipelineAgent } = require('@livekit/node');
class VoicemailDetector {
constructor(session) {
this.session = session;
this.vad = new SileroVAD({
threshold: 0.6,
prefixPaddingMs: 200,
silenceDurationMs: 500
});
this.initializeVAD();
}
initializeVAD() {
this.session.on('audio', (audio) => {
this.vad.processFrame(audio);
if (this.vad.silenceDetected()) {
this.handleVoicemailDetection();
}
});
}
async handleVoicemailDetection() {
await this.session.generateReply({
instructions: "Leaving a voicemail message."
});
await this.hangupCall();
}
async hangupCall() {
await this.session.session.aclose();
}
}
If anything’s unclear or you want to dive deeper into any part, just give me a shout—I’m here to help!
Sources: plugins/silero/package.json | Voice activity detection (VAD) parameters | LiveKit Docs