we are using livekit with livekit's SIP and plivo ...
# ask-ai
f
we are using livekit with livekit's SIP and plivo as telephony provider, once i run background sound, it works fine on livekit -> livekit ( webcall ) but the audio breaks in telephony, when no one is speaking in telephony, the bg noise is sent in small chunks, what can be the issue? is it something related to noise cancellation? note: the voice breaking is from bot -> user
t
Thanks for reaching out, Gaurav. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m looking at the issue where background audio from your bot plays fine in LiveKit-to-LiveKit calls but becomes choppy (sent in small chunks) to telephony users via Plivo. Below is what’s most likely happening and practical steps to try. Summary of likely cause • The choppiness is most likely caused by telephony-level silence detection/DTX (discontinuous transmission) or comfort-noise insertion on the SIP/Plivo side. Telephony systems can stop or reduce packet transmission during low-activity audio, which breaks continuous background sound. This is not caused by LiveKit’s noise cancellation on inbound user audio. What to try (prioritized) 1. Use a consistently active audio source ◦ Play a background file with uniform amplitude and no gaps (looped ambience). This prevents the trunk from classifying segments as silence. 1. Disable or reduce DTX/VAD on the telephony side (Plivo) if possible ◦ Check Plivo settings for disabling DTX/voice activity detection or aggressive silence suppression for the SIP trunk. 1. Send a low-level carrier under the ambience ◦ Inject a very low-level constant tone or low-level noise beneath the bg audio so the stream never looks “silent” to the codec. 1. Try a wideband codec (G.722) if supported ◦ Ask Plivo to enable G.722/HD Voice for your trunk — wideband codecs often handle continuous non-speech audio better than narrowband codecs. 1. Verify behavior with plain speech vs. bg audio ◦ Confirm that normal speech (no background sound) is stable; if only background audio is affected, that reinforces DTX/silence-detection as the root. If you want, I can help with next steps: • Which bg audio file/format are you using (sample rate, mono/stereo, file type)? • Can you confirm whether Plivo allows disabling DTX or which codec (G.711/G.722) is currently negotiated? Sources: Bringing Zoom's end-to-end optimizations to WebRTC | Enhanced noise cancellation | LiveKit docs | HD voice for SIP | LiveKit docs | Agent speech and audio | LiveKit docs
f
No this is definitely happening from livekit's end since i can hear the breaking of voice in egress as well.
t
Thanks — I hear you: you’re seeing the breaking on LiveKit egress as well. To diagnose whether LiveKit is the source, I need a few details and a short test from you. Please provide: • The exact reproduction steps (how you start the bg audio, whether it’s injected as a track or played into a participant, web SDK vs server-side, sample rate/bitrate). • The audio file format and specs (sample rate, mono/stereo, codec when you upload/serve it). • Which LiveKit SDK/version you’re using and whether this is in the browser or a server/worker. • The negotiated codec for the SIP session (G.711, G.722, opus, etc.) and whether you force codec settings anywhere. • Whether any audio processing is enabled on the track (e.g.,
noiseSuppression
,
echoCancellation
,
autoGainControl
, or LiveKit’s NC features). • A short recorded example: one 10–20s sample of the original bg file plus a recorded capture of the egress audio where the breaking is audible. Quick tests you can run and report results for: • Play the same bg file into a plain LiveKit-to-LiveKit peer (no SIP) and confirm whether you hear breaks there. • Publish the bg track with
autoGainControl
,
noiseSuppression
, and
echoCancellation
toggled off, then test egress again. • Publish a constant tone (sine wave) instead of the bg audio to see if the breaking persists. Send me the answers and the short audio samples and I’ll analyze them and recommend the next steps (specific settings or a targeted reproduction I can walk you through).
f
1. i do not have these issues with livekit-to-livekit, it only happens in SIP 2. how do i publish the track
autoGainControl
,
noiseSuppression
, and
echoCancellation
with these options i cannot find them in python sdk. 3. the codec being used is G722 on the telephony end, we send audio to livekit as pcm bytes. 4. I am on 1.0.18 5. Attached example audio
t
Thanks — I’m addressing your points: you only see the issue on SIP egress, you’re on v1.0.18, using G.722, sending PCM bytes, and you can’t find the audio-processing flags in Python. Short answers and next steps 1) Audio-processing flags in Python SDK • You cannot set
autoGainControl
,
noiseSuppression
, or
echoCancellation
when publishing from the Python/server SDK. Those are client-side capture options (browser/mobile). For server-side publishing, focus on the PCM input you feed LiveKit. 2) Likely root cause given your clues • G.722 on the SIP leg is sensitive to sample rate, frame alignment, and packet timing. If PCM frames are mis-sized, misaligned, or inconsistent, transcoding/packetization to G.722 can produce the choppy egress you hear — even if LiveKit-to-LiveKit is fine. 3) Concrete checks and fixes to try now • Ensure PCM format: 16-bit signed little-endian (S16LE), mono, sample rate matching what you create in AudioSource. • Use 16 kHz for G.722. Set AudioSource sample rate to 16000 and publish frames that match this. • Send consistent frame durations (10ms or 20ms). For 20ms at 16 kHz: 320 samples → 640 bytes per frame (S16LE mono). Align every capture_frame to this boundary. • If you’re injecting raw PCM, try switching to a WAV file or the BackgroundAudioPlayer (which handles proper framing/decoding) and re-test. • Try publishing a constant tone (sine) at low level for 10–20s; if that still chops, it points to timing/packetization rather than content. 4) What I need from you to continue diagnosing • Confirm the PCM specs you’re sending (sample rate, channels, bit depth, endianness) and an example of code (how you create AudioSource and call capture_frame). • Confirm whether you already send 20ms-aligned frames and their exact byte size. • I can analyze the attached example — please confirm the attached file is the original PCM you send (S16LE @16k) and also provide the recorded egress capture if you have it. If you want, share the code snippet that creates the AudioSource and the capture_frame loop and I’ll point out any specific changes to ensure proper framing and timing. Sources: SIP overview | LiveKit docs | Camera & microphone | LiveKit docs | Agent speech and audio | LiveKit docs | Codecs and more | LiveKit docs