How can I turn off the default microphone audio ca...
# ask-ai
w
How can I turn off the default microphone audio capture and instead send my own microphone buffer to the agent? I want to manually collect the mic audio frames and forward them to the LiveKit client for agent processing.
t
Thanks for reaching out, Sandip. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're asking how to stop LiveKit's default mic capture and instead collect mic frames yourself and feed them to the agent. Here’s a concise, actionable plan you can implement. 1. Prevent automatic mic publishing • Do not call any SDK methods that auto-enable the mic (e.g.,
setMicrophoneEnabled(true)
). 1. Capture mic audio manually (client) • Use platform APIs (Web:
navigator.mediaDevices.getUserMedia()
+
AudioContext
) to read PCM frames. • Example pattern (JS): create a MediaStreamSource, use a ScriptProcessor or AudioWorklet to get float PCM buffers, package them with sample rate / channels / timestamp, and send to your backend (WebSocket/WS). 1. Create a custom AudioSource on the agent/backend • Instantiate an
AudioSource
(e.g.,
rtc.AudioSource
) and create a
LocalAudioTrack
from it. 1. Push your frames into the AudioSource • Receive the client frames on the backend and convert to the expected PCM format. • Construct audio frames with correct fields (sample rate, num channels, samples per channel, timestamp) and call the source capture method (e.g.,
source.capture_frame(frame)
/
await source.capture_frame(frame)
). 1. Publish the custom track so the agent receives it • Publish the
LocalAudioTrack
via
publishTrack
/
localParticipant.publish_track(...)
. The agent will receive the audio like any standard track. Notes and alternatives • If you only need the audio for processing (not playback inside the room), you can also send raw buffers via LiveKit data messages, but for full voice interaction the
AudioSource
→
LocalAudioTrack
→
publish
flow is the supported approach. • Ensure sample rates, channel counts, and timestamp units match the SDK's expectations when converting buffers. If you want, tell me: • which SDK/platform you’re using (Web, iOS, Android, or server SDK), and • whether you need example code for the capture, conversion (float → PCM16), or backend push — I’ll provide the specific snippet. Sources: Camera & microphone | LiveKit docs | Processing raw media tracks | LiveKit docs | Capturing the First Few Seconds of a Call for Processing | Agent Session Management & Turn Detection | livekit/livekit_composite | Dee... | Voice Assistant Examples | livekit/livekit_composite | DeepWiki