How can I solve the issue of missing the initial p...
# ask-ai
r
How can I solve the issue of missing the initial part of the audio when using the Twilio SIP provider? This problem does not occur when using WebRTC.
t
Thanks for reaching out, Yu. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hi there! It sounds like the missing initial audio with Twilio SIP, but not with WebRTC, might be due to how early media is handled during call setup. By default, SIP participants in LiveKit don’t emit audio while connecting. A helpful step is to enable the
play_dialtone: true
option in the
CreateSIPParticipant
request. This will start the audio track early and play a dial tone during call setup, which often helps with preserving that initial audio. Also, it’s a good idea to double-check your Twilio trunk settings—especially the "Early Media" handling in the origination URL configuration. This setting controls whether audio is forwarded before the call is fully answered. Making sure your SIP trunk sends the right answer supervision signals (like 180 Ringing and 200 OK) can really make a difference in getting media to start on time. Could you please let me know if you’ve enabled
play_dialtone
in your setup? And are you noticing this issue only on outbound calls, or does it happen with inbound Twilio SIP calls as well? I’m here to help you get this sorted out! Sources: packages/sip--um-actually/src/setup-twilio.ts | Agents telephony integration | LiveKit Docs | OpenAI and LiveKit partner to turn Advanced Voice into an API | Make outbound calls | LiveKit Docs | pkg/sip/outbound.go
r
I'm self-hosting the agent and connect to livekit-cloud, should the play_dialtone option related to the agent entrypoint?
t
I’d love to help clarify how the
play_dialtone
option works! It’s not directly linked to the agent entrypoint itself, but it plays an important role in certain SIP operations—like when making outbound calls or transferring calls—by providing audible feedback, such as a dial tone, while the call is being set up. You can enable this option in the
CreateSIPParticipant
request or during call transfers using the
transfer_sip_participant
API. In your self-hosted setup, using
play_dialtone
can really enhance the user experience by ensuring early media is played during SIP call setup. If you’re working on implementing an agent, including this option in your SIP operation logic—like for DTMF-triggered transfers—can give participants helpful real-time feedback. Please feel free to reach out if you’d like me to walk you through any part of this or provide specific examples tailored to your setup. I’m here to help! Sources: SIP APIs | LiveKit Docs | Make outbound calls | LiveKit Docs | livekit-agents/livekit/agents/job.py | livekit-protocol/livekit/protocol/sip.pyi | protobufs/rpc/sip.proto
r
I'm not doing outbound call. user phone <-> ours twilio number <-> livekit sip <-> agent (self-hosting) scenario: user calls ours twilio number (inbound) initial part of the audio is missing
t
Thanks so much for providing those details! Since we’re looking at inbound calls, could you please help me understand a bit more by confirming a few things? • Are you using any specific Twilio SIP trunk settings, like early media or answer supervision (for example, 180 Ringing, 200 OK)? • Is this issue happening on every inbound call, or just sometimes? • Have you set up any custom configurations in your LiveKit SIP integration or agent that might impact how audio is handled? Getting a clearer picture with these details will really help us pinpoint what’s going on and find the best way to fix the missing initial audio. I’m here to help every step of the way!
r
1. no setting early media 2. happening on every inbound call from twilio, but webrtc is fine 3. in entrypoint: ctx.connect() -> generate first text -> session.say(text)
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!