5-12-11 06:51:29,545 - WARNING livekit.plugins.sil...
# ask-ai
p
2025-12-11 065129,545 - WARNING livekit.plugins.silero - inference is slower than realtime {"room": "playground-5vZ3-Yprl", "delay": 0.45189460699795403, "pid": 37303, "job_id": "AJ_bfrDmAeCHiAr"}
t
Thanks for reaching out, arpan. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're right — that log line is a warning that the Silero plugin's inference ran slower than real time for room "playground-5vZ3-Yprl". I can help troubleshoot — a few quick questions to narrow this down: 1. Is this a one-off warning or happening repeatedly for that room (or other rooms)? 2. Are you seeing user-facing symptoms (audio glitches, lag, dropped frames, delayed captions/transcripts)? 3. What environment is the plugin running in (local machine, VM, container, cloud instance)? Please include CPU, memory, and whether a GPU is available. 4. Which Silero model/config are you using and what sample rate or chunk size are you sending to inference? 5. Approximate concurrent load when this happened (number of participants/streams) and whether other CPU-heavy tasks were running. With those details I can suggest targeted fixes (model/config changes, batching/chunk-size tuning, resource sizing, or CPU/GPU adjustments). Would you like me to propose immediate configuration changes based on common causes?
p
audio glitches, lag, dropped frames, delayed,vm cpu,8000
t
Thanks — you're seeing audio glitches, lag, dropped frames and delays while the Silero plugin ran slower than realtime on a VM using CPU (you also noted "8000"). I can help — a few targeted steps and quick checks to resolve this: 1. Verify instance type and CPU behavior • Are you on a burstable instance (e.g., AWS t3/t4g)? If so, CPU credits may be exhausted and causing throttling. Monitor CPU usage and, on AWS, the
CPUCreditBalance
CloudWatch metric. 1. Recommended immediate fixes • Move to a non-burstable, compute-optimized instance (example families: c5, c6i) or a VM with guaranteed sustained CPU. • Ensure the VM has spare vCPUs; inference latency >500ms typically indicates throttling or insufficient CPU. 1. Plugin/runtime tuning • Pre-download and prewarm Silero model weights so runtime doesn’t spike on first inferences. • If using a low audio sample rate (you indicated 8000 Hz), confirm the model supports it; very low sample rates can increase processing overhead per useful audio data. • Increase
queue_size_ms
in
AudioSource
to reduce buffer overloads that cause "failed to capture frame" and dropped frames. 1. Tests to run now • Run inference on a single stream with no other load to see single-stream latency. • Run a CPU profile or top/htop during the warning to confirm 100% CPU or throttling spikes. • If on AWS burstable, run a sustained CPU load test while watching
CPUCreditBalance
. If you share: instance type (vCPUs, RAM), whether it's burstable, Silero model/config, and concurrent participant count, I’ll recommend exact instance sizes and configuration changes. Would you like me to propose instance sizes and queue/sample-rate settings based on typical loads? Sources: Silero VAD plugin | LiveKit docs | Troubleshooting Latency and Timeout Errors with Turn Detection on AWS | LiveKit turn detector plugin | LiveKit docs | Resolving "InvalidState - failed to capture frame" errors in AudioSource
p
c5.4xlarge i am using
t
Thanks — since you're on a c5.4xlarge, that gives us a good baseline. I’ll address why you still see slow inference and what to try next. What to check right away • Confirm sustained CPU usage during the warning (use top/htop or
mpstat
) — look for near-100% on one or more vCPUs or heavy steal time. • Check memory usage to rule out swapping. c5.4xlarge has plenty of RAM, but confirm no OOM or swap activity. • Verify process affinity: ensure the Silero process isn't pinned to a single crowded core. Immediate configuration and runtime fixes • Prewarm the Silero model weights at startup so inference work isn’t spiking on first requests. • Increase
queue_size_ms
in
AudioSource
to give the audio pipeline more buffer headroom. • If you’re processing many small chunks, increase chunk size slightly to improve throughput (tradeoff: small added latency). • Run the plugin with isolated CPU quota (cgroups/CPU pinning) to avoid interference from other processes. Investigation steps 1. Capture a short trace while the issue occurs: ◦ Record `top`/`htop` and
pidstat -u -p <silero_pid> 1
for 30–60s. ◦ Note per-thread CPU and any I/O waits or steals. 1. Run single-stream vs. target-concurrency tests to see where latency grows. 2. Check logs for "failed to capture frame" or queue overflows. If tests show per-inference latency consistently >500ms • Try a lighter Silero model variant (if available) or reduce model complexity/config. • Consider horizontal scaling: run multiple plugin worker processes and distribute streams across them. If per-inference latency is low for single stream but spikes with concurrency • Increase number of workers or move to a dedicated host per N streams; use c5 family larger or multiple c5.2xlarge instances depending on concurrency. If you’d like, tell me: • concurrent streams/participants during the incident, • Silero model name/config, and • whether other CPU-heavy services run on the same host. I can then recommend exact worker counts, chunk sizes, and queue_size_ms values. Would you like that?
p
some code example
t
Thanks — below is a concise, usable Python example showing: • prewarming the Silero VAD model at process startup, • reusing the model across sessions, • setting sensible VAD parameters, • increasing audio buffer headroom, and • a note about CPU affinity / worker parallelism. Adjust values (chunk size,
queue_size_ms
, worker count) to match your concurrency.
Copy code
# Example: prewarm + reuse Silero VAD in a LiveKit agent process
# (adapt imports/names to your codebase)

from livekit import agents
from livekit.agents import AgentSession, JobContext, AgentServer
from livekit.plugins import silero

# Prewarm: load model once per worker process and store on proc.userdata
def prewarm(proc: agents.JobProcess):
    proc.userdata["vad"] = silero.VAD.load(
        min_speech_duration=0.1,
        min_silence_duration=0.5,
        activation_threshold=0.5,
        force_cpu=True  # set False if you run GPU-backed inference
    )
    # Optionally call a dummy inference to warm JIT/cache
    proc.userdata["vad"].is_speech(b"\x00" * 320)  # tiny silent frame

server = AgentServer()
server.setup_fnc = prewarm

@server.rtc_session()
async def silero_agent(ctx: JobContext):
    # Reuse preloaded VAD instance
    vad: silero.VAD = ctx.proc.userdata["vad"]

    # Tune audio source buffer to reduce dropped frames
    # If your API exposes AudioSource settings, increase queue_size_ms
    # Example placeholder (replace with your AudioSource init code):
    audio_source_cfg = {
        "queue_size_ms": 200,    # raise from default to add headroom
        "chunk_size_ms": 20,     # how much audio is sent per inference call
        "sample_rate": 8000      # keep consistent with your stream
    }

    session = AgentSession(
        vad=vad,
        # add other models like stt/tts/llm as needed
    )

    # Start session; session.start should use your audio_source_cfg
    await session.start(room=ctx.room, agent=agents.Agent(instructions="You are a helpful assistant."))

if __name__ == "__main__":
    agents.cli.run_app(server)
Practical tuning checklist to run alongside the code: • Increase
queue_size_ms
(example above: 200 ms) to reduce buffer overflow / dropped frames. • Slightly increase
chunk_size_ms
(e.g., 20–40 ms) to improve CPU throughput vs. per-inference overhead. • Prewarm model (shown) to avoid first-call spikes. • Ensure Silero process has CPU headroom: use CPU pinning or cgroups to spread worker processes across vCPUs; run multiple workers if handling many concurrent streams. • If you see per-inference >500 ms under load, add more workers or horizontal hosts and distribute streams. If you want, tell me: • your typical concurrent stream count and desired max latency, • current
queue_size_ms
and
chunk_size_ms
values, and I’ll recommend concrete numbers for workers, chunk sizes, and buffer settings.
p
class HolionixAgent(BaseAgent): """ HolionixAgent: A Multilingual Voice Assistant - Handles STT, LLM, TTS, and VAD with LiveKit. - Configurable system instructions loaded from prompt template. """ def __init__(self,tools=None,chat_ctx=None,ctx=None,vad=None): super().__init__( instructions=AGENT_PROMPT, stt=aws.STT(language="en-US",language_model_name="us_engclm",vocab_filter_name="English",vocab_filter_method="mask",vocabulary_name="bajaj"), llm=openai.LLM(api_key=secrets.OPENAI_API_KEY,model="gpt-4o-mini",prompt_cache_key="24h"), tts=tts.StreamAdapter( tts=elevenlabs.TTS( model="eleven_turbo_v2_5", api_key=os.getenv("ELEVENLABS_API_KEY"), voice_id="204jSNMxoKiZqmO2dePr", auto_mode=True, voice_settings=elevenlabs.VoiceSettings( stability=0.7, similarity_boost=0.85, style=0.6, use_speaker_boost=True, speed=1.2 ), enable_ssml_parsing=True, ), text_pacing=True, ), vad=vad, tools=tools, chat_ctx=chat_ctx ) self.ctx = ctx self.metrics_db = DynamoServices(table_name="metrics") self.session_id =self.ctx.room.name self.metrics = Metrics() logger.info(f"🎙️ Agent started | session_id={self.session_id}") # LLM metrics def llm_metrics_wrapper(metrics: LLMMetrics): asyncio.create_task(self.metrics.on_llm_metrics_collected(metrics)) self.llm.on("metrics_collected", llm_metrics_wrapper) # STT metrics def stt_metrics_wrapper(metrics: STTMetrics): asyncio.create_task(self.metrics.on_stt_metrics_collected(metrics)) self.stt.on("metrics_collected", stt_metrics_wrapper) # EOU metrics def eou_metrics_wrapper(metrics: EOUMetrics): asyncio.create_task(self.metrics.on_eou_metrics_collected(metrics)) self.stt.on("eou_metrics_collected", eou_metrics_wrapper) # TTS metrics def tts_metrics_wrapper(metrics: TTSMetrics): asyncio.create_task(self.metrics.on_tts_metrics_collected(metrics)) self.tts.on("metrics_collected", tts_metrics_wrapper) # VAD metrics def vad_metrics_wrapper(event: VADMetrics): asyncio.create_task(self.metrics.on_vad_event(event)) self.vad.on("metrics_collected", vad_metrics_wrapper) async def on_enter(self) -> None: await self.session.generate_reply( instructions="First tell user-'This call may be recorded for quality and compliance purposes' then Greet the user warmly and offer your assistance. Ask their Language", allow_interruptions=True ) async def on_exit(self) -> None: """Called when user want to leave the conversation or want to close ther conversation""" await self.session.generate_reply(instructions="say goodbye to the user") async def metrics_store(self)-> None: """Store Metrics To DynamoDB""" data ={ "session_id":self.session_id, "llm":self.metrics.llm_metrics, "stt":self.metrics.stt_metrics, "tts":self.metrics.tts_metrics, "eou":self.metrics.eou_metrics, "vad":self.metrics.vad_metrics } self.metrics_db.connect() self.metrics_db.insert_item(data) self.metrics_db.disconnect()
t
Thanks — I see your HolionixAgent code and that you want help integrating/tuning VAD for better realtime performance. Which of these would you like me to help with first? • Add VAD prewarm + reuse into your class (code patch showing where to load/store the model). • Tune buffer/chunk settings (
queue_size_ms
,
chunk_size_ms
) inside your agent/session and sample values to try. • Show how to pin the Silero process to vCPUs or run multiple worker processes and distribute streams. • Instrument VAD metrics hooks you already have to surface per-inference latency and CPU usage samples. • A full annotated patch that includes prewarm, buffer tuning, and worker suggestions integrated into your HolionixAgent. Tell me which option (or combination) you want and share: • concurrent streams during peak, and • current
queue_size_ms
/
chunk_size_ms
if set.
p
heplp me
t
I can help — I’ll add VAD prewarm/reuse, tune buffers, and show simple CPU pinning/worker options directly in your HolionixAgent. Before I produce the patch, two quick clarifying questions so I target it correctly: 1. How many concurrent streams/participants do you handle at peak? 2. What are your current
queue_size_ms
and
chunk_size_ms
(or where those are configured)? If you don’t know the exact numbers, say “unknown” and I’ll provide safe defaults and a patch you can drop into your class. Which do you prefer?