Hi I have an outbound agent using sip trunk in twi...
# telephony
b
Hi I have an outbound agent using sip trunk in twilio. I noticed some audio quality issues with tts. Specifically I get sort of fading parts of the words ie missing / fading letters and the same agent config when i use as inbound call is working perfectly. I tried different sip trunk provider wavix but the issue is still there. I tried different tts ie openai, fishaudio, deepgram, elevelabs, cartesia and same is happening for all. is this a samplerate issue or hd codec not enable on cpaas provider? Any help would be appreciated.
r
Make sure you are not using noise cancelation on both the trunk and in the agent. Pick one or the other like Agent only.
b
What I did is downsampled rooms to 8000
Copy code
await session.start(
    agent=agent,
    room=ctx.room,
    room_input_options=room_io.RoomInputOptions(audio_sample_rate=8000),
    room_output_options=room_io.RoomOutputOptions(audio_sample_rate=8000),

)
and my tts
Copy code
from livekit.plugins.azure.tts import ProsodyConfig
speech_config = speechsdk.SpeechConfig(
    subscription=speech_key,
    region=speech_region
)
speech_config.set_speech_synthesis_output_format(
    speechsdk.SpeechSynthesisOutputFormat.Raw8Khz16BitMonoPcm
)
prosody_config = ProsodyConfig(rate=0.9,volume='loud')  # ~10% faster speech

return azure.TTS(
    speech_key=speech_key,
    speech_region=speech_region,
    voice=voice_id,
    language=language,
    prosody=prosody_config,
    http_session=http_session,
)
my sip participant is|
Copy code
request = CreateSIPParticipantRequest(
    sip_trunk_id=trunk_id,
    sip_call_to=phone_number,
    room_name=room_name,
    participant_identity="phone_user",
    participant_name=participant_name,
    play_dialtone=play_dialtone,
    krisp_enabled=True,
    wait_until_answered=True
)
But for some reason it is still robotic. I asked twilio about enabling HD sound but Twilio support told me that Twilio’s Elastic SIP Trunking will always transcode audio to and from 8 kHz G.711, so HD codecs like Opus can’t be preserved end-to-end and this is what’s causing the muffled/watery artifacts we’re hearing. Twilio support told me to instead send 8 kHz, 16-bit PCM or μ-law mono audio that’s already normalized/compressed, free of silence padding or low-frequency noise, and ensure the TTS provider outputs pure PCM or μ-law to minimize distortion in Twilio’s transcoding pipeline. So I am puzzled what can be done to improve this?
is there a better telphony provider. Did you come across the same problem
m
Hi Piotr, I'm wondering if you were able to solve this? How long is your welcome message and did you try to shorten it?
Since you've tried multiple VOIP and TTS providers and faced the same issue, this might be related to a very long welcome message your agent is playing.
b
I don't think it's got anything to do with a very long welcome message. What I'm saying is that in the morning this issue is non-existent and as soon as the evening hits I'm getting lossy audio. I tried different providers for telephony and different TTS nothing seems to help. I wonder if it's either life kit or the telephony users but maybe life get in the evenings in Europe gets more users because of the US.
But hard to say without having a full picture of what's going on so I have to rely on people supporting to resolve this issue
I hope it makes sense