Does setting `session.input.audio.enabled = false`...
# ask-ai
s
Does setting
session.input.audio.enabled = false
just mute the mic, or does it fully stop audio frames from being sent to the STT pipeline (e.g., Deepgram)?
t
Thanks for reaching out, Anmy. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're asking whether
session.input.audio.enabled = false
just mutes the mic or completely stops audio frames from reaching the STT pipeline. Setting
session.input.audio.enabled = false
fully stops audio frames from being sent to the STT pipeline (e.g., Deepgram). Audio input is disabled at the agent level, so no audio data is forwarded for transcription or downstream processing. If you need, I can explain the difference between this and SDK-level mic muting (e.g.,
setMicrophoneEnabled(false)
) and when to use each. Sources: Text and transcriptions | LiveKit docs
s
so how to test if stt is still streaming when mic is off?
t
You're asking how to verify whether STT is still receiving audio after the mic is turned off. Here are concise, practical tests you can run. 1) Verify STT/transcript events • Disable audio:
session.input.set_audio_enabled(false)
• Observe STT events (e.g.,
INTERIM_TRANSCRIPT
,
FINAL_TRANSCRIPT
,
SpeechEvent
). If no transcript events arrive after disabling, STT is not receiving audio. 2) Log incoming audio frames • In your audio capture/agent code, log or count audio frames pushed to the STT stream (e.g., calls to
stt_stream.push_frame()
or your audio loop). When mic is disabled, the frame count should stop increasing. 3) Check STT provider activity/metrics • Inspect provider-side activity or LiveKit STT metrics (
metrics_collected
,
eou_metrics_collected
). If metrics or provider stream activity stop after disabling audio, streaming has stopped. 4) Use voice-activity indicators • Watch for
START_OF_SPEECH
/
END_OF_SPEECH
or VAD signals. After disabling audio, no start-of-speech events should be emitted. Suggested quick test sequence 1. Start a session with STT enabled and confirm live transcripts appear. 2. Call
session.input.set_audio_enabled(false)
. 3. Speak into the microphone and watch: ◦ Transcript events (should stop), ◦ Logged
push_frame()
counts (should stay at zero), ◦ Provider metrics (should stop). If you tell me which SDK/environment you’re using (agent vs standalone, language/runtime, or which STT provider), I can give a short code snippet for logging frames or checking events. Sources: Speech-to-text (STT) models | LiveKit Docs | Text and transcriptions | LiveKit docs | STT Metrics | LiveKit docs
s
but when I am initially connecting the agent it is starting by connecting to deepgram why ? even when session.input.audio.enabled = false
t
You're asking why the agent opens a Deepgram connection at startup even when
session.input.audio.enabled = false
. The agent pre-establishes the STT connection when the session starts because the STT provider is configured on the AgentSession. This reduces latency so the agent can begin transcribing immediately if audio is enabled later. However, opening the connection does not mean audio is sent—when you call
session.input.set_audio_enabled(false)
no audio frames are forwarded to Deepgram and no transcripts are produced. If you want, I can: • Show how to confirm this with a quick event/log check for transcript or
push_frame()
activity, or • Provide a short code snippet for your environment to log frame pushes or STT events. Which would help most? Sources: Deepgram STT plugin guide | LiveKit docs | ElevenLabs Change Language | LiveKit docs | Text and transcriptions | LiveKit docs
s
i want to check using logs
t
You're asking how to confirm via logs that no audio is streamed to Deepgram after disabling the mic. Follow these quick checks and log points. 1) Log the audio-enable toggle • Log when you call:
Copy code
<http://logger.info|logger.info>("Audio input disabled")
session.input.set_audio_enabled(False)
2) Log received audio frames before STT • In your audio processing loop, log each frame before pushing to STT:
Copy code
async for frame_event in audio_stream:
    <http://logger.info|logger.info>("Audio frame received: %s samples", frame_event.frame.samples_per_channel)
    stt_stream.push_frame(frame_event.frame)  # log before this call
• After disabling, you should see no "Audio frame received" logs. 3) Log STT push calls • Add an explicit log when you push frames:
Copy code
<http://logger.info|logger.info>("Pushing audio frame to STT")
stt_stream.push_frame(frame)
• If mic is disabled, "Pushing audio frame to STT" logs should stop. 4) Log STT transcript events • Log INTERIM/FINAL transcripts:
Copy code
if event.type == SpeechEventType.INTERIM_TRANSCRIPT:
    <http://logger.info|logger.info>("STT Interim: %s", text)
elif event.type == SpeechEventType.FINAL_TRANSCRIPT:
    <http://logger.info|logger.info>("STT Final: %s", text)
• No transcript logs should appear while input is disabled. 5) Optional: Log provider/metrics events • Log
metrics_collected
/
eou_metrics_collected
or provider connection state. Metrics for audio activity should stop when audio is disabled. Quick test sequence 1. Enable audio, confirm logs show frames, pushes, and transcripts. 2. Call
session.input.set_audio_enabled(False)
and log that action. 3. Speak — verify that: ◦ No "Audio frame received" logs appear, ◦ No "Pushing audio frame to STT" logs appear, ◦ No transcript logs appear, ◦ Provider metrics for audio stop. If you tell me which SDK/language (agent vs standalone, Python/Node/etc.), I’ll provide a focused snippet you can drop into your code. Sources: Text and transcriptions | LiveKit docs | Agent-assisted warm transfer | LiveKit docs | Job lifecycle | LiveKit docs | STT Metrics | LiveKit docs
s
Can we switch to a voice-only agent (without avatar) in LiveKit when an error like “usage/limit reached” occurs, and is this supported or recommended?
t
Yes — you can and should switch to a voice-only agent when an avatar service hits a "usage/limit reached" error. Why: • Avatar rendering runs as a separate participant (avatar worker). The main AgentSession and audio pipeline are independent, so avatar failures don’t block voice. • The agent framework is designed to degrade gracefully to audio-only mode so conversation continuity is preserved. • AgentSession emits error events (with a
recoverable
flag) you can listen for to detect usage/limit errors and act. What to do (high-level): • Listen for the AgentSession
ErrorEvent
. • On a non-recoverable/usage-limit error, stop/skip starting the avatar worker and ensure the agent publishes audio directly to the room. • Keep STT/TTS and agent logic running so voice interaction continues. If you want, I can provide: • A short code pattern (node or python) to detect the error and toggle avatar vs voice-only routing, or • Specific log/flag checks to decide recoverable vs non-recoverable errors. Which would you prefer? Sources: examples/avatar_agents | livekit/livekit_composite | DeepWiki | Virtual avatar plugins | LiveKit Docs | Events and error handling | LiveKit docs