worried-gold-23479
11/24/2025, 12:28 PMtall-airline-16756
11/24/2025, 12:28 PMtall-airline-16756
11/24/2025, 12:28 PMsetMicrophoneEnabled(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