LiveKit SDK is creating duplicate audio processing...
# ask-ai
s
LiveKit SDK is creating duplicate audio processing how can we prevent it
t
Thanks for reaching out, MBMBMB. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks so much for reaching out! To help you better with the duplicate audio processing issue, could you please share a bit more detail? For instance: • Which platform or SDK version are you using? • Is this duplication happening for everyone, or just in certain situations? • Have you applied any custom audio processing or special configurations? Your insights will really help us get to the bottom of this and find the best solution for you.
s
python open ai realtim
t
Thank you for reaching out! Just to make sure I understand correctly, are you asking about using the LiveKit SDK with Python for real-time audio processing? If that's the case, could you please share a bit more about the duplicate audio issue you're experiencing? For example: • Are you working with any particular libraries or frameworks? • What steps or settings have you tried so far? • Does this happen all the time, or just sometimes? Knowing these details will really help me guide you better and find a solution together.
s
When we subscribe to a track, the LiveKit SDK is creating TWO "start reading stream" instances
t
Thanks so much for the clarification! To help us get to the bottom of why two "start reading stream" instances are being created when you subscribe to a track, could you please share a bit more info with us? • Which version of the LiveKit SDK are you currently using? • Are there any custom configurations or tweaks you've made in your setup? • Does this happen with all tracks or just certain ones? • If you have any logs or error messages handy, could you share those as well? Having these details will really help us understand what’s going on and find the best solution for you.
s
Current Setup: 1. LiveKit SDK Versions: • livekit==1.0.11 (core SDK) • livekit-agents==1.1.5 • livekit-plugins-openai==1.1.5 2. Custom Configurations: • AgentSession: Configured with allow_interruptions=True, min_interruption_duration=0.1, min_endpointing_delay=0.15 • RoomInputOptions: Using close_on_disconnect=False • Noise Cancellation: BVC (Background Voice Cancellation) is commented out for performance • Auto-subscribe: We connect with default auto-subscribe enabled (ctx.connect() has no parameters) • Custom Duplicate Prevention: We've implemented extensive manual tracking of subscribed microphone tracks per participant 3. Issue Specifics: • This happens specifically with microphone tracks (not other track types) • The duplicates appear when: • Moving from Home room to a roleplay room • The user starts speaking after entering the room • The SDK creates duplicate AudioStream._run and _ParticipantAudioInputStream._forward_task tasks Key Observations: The issue seems to be that when a microphone track is subscribed, the LiveKit SDK internally creates TWO instances of audio processing pipelines. This is evidenced by the double "start reading stream" messages in the logs. The duplicate tasks only become problematic when audio data actually flows (i.e., when the user speaks), which explains why they appear "20+ seconds later" - they're created at subscription time but only become active when audio is processed. This could be a bug in LiveKit SDK 1.0.11 or an interaction between the agents framework and the core SDK. The fact that we see exactly 2 instances suggests it might be related to how the SDK handles audio streams internally (possibly creating separate pipelines for different purposes like transcription and audio forwarding).
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!