I have auto_egress enabled, but it's creating a tr...
# ask-ai
g
I have auto_egress enabled, but it's creating a track for the background audio as well. How do I differentiate between the agent and the background audio? I need this for processing the audio after the call.
t
Thanks for reaching out, Aumesh. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I’m glad you asked about distinguishing agent audio from background audio when
auto_egress
is enabled! A really helpful feature for this is the dual-channel audio mixing. It works by placing the agent's audio in the left channel and all other sounds, like background audio, in the right channel. To get this up and running, you just need to set the
audio_mixing
parameter to
DUAL_CHANNEL_AGENT
in your egress request. Here’s a quick example:
Copy code
audio_mixing: DUAL_CHANNEL_AGENT
This way, your recordings will have a nice, clear separation between the agent’s voice and any background sounds, which can make things much easier when you’re processing the calls afterward. Sources: examples/voice_agents/background_audio.py | Agent speech and audio | LiveKit Docs | src/main/kotlin/io/livekit/server/EgressServiceClient.kt | livekit-protocol/src/livekit.rs | test/edge.go
g
I want to use auto_egress; however this makes it so the background_noise is in it's own file. I have no way to distinguish between the background_noise player file and the agent file
t
Thanks so much for reaching out! To make sure I fully understand your needs around distinguishing between the background noise player file and the agent file, could you please clarify a few things? • Are you hoping to have separate audio tracks in the egress output—for example, one track for background audio and another for the agent's speech? • What kind of egress are you currently using? Is it room composite, track composite, or something else? • Would you like to separate these audio sources in real time during recording, or are you looking for post-processing options to identify them afterward? • Are there specific audio file formats or egress configurations you're working with? Getting a bit more detail on these points will really help me guide you toward the best solution tailored just for you. Looking forward to your reply! Sources: examples/voice_agents/background_audio.py | test/edge.go
g
The audio tracks are separate files. I am use track composite. I would like to understand which one is which in post processing. The audio file formats are all .ogg
t
To help you identify separate audio tracks in Track Composite egress for post-processing, you can use metadata templating in file paths with details like
{track_id}
or
{publisher_identity}
. This makes it easier to see which participant or source each exported audio file belongs to. If you'd like to process each audio source independently, I recommend trying Track Egress. This feature lets you export each audio track separately as an
.ogg
file. You can get the list of active tracks using the
ListParticipants
API, filter for audio tracks, and then start a Track Egress request for each track using its
track_id
. Feel free to reach out if you'd like more details or examples on how to set this up—I’m here to help! Sources: Universal Egress | README.md | Universal Egress | packages/livekit-server-sdk/src/EgressClient.ts | Egress examples | LiveKit Docs
g
Why is background audio a seperate audio file when doing track egress, shouldn't it be the same as the agent file?
t
Thanks for reaching out! I totally understand how seeing background audio as a separate file in track egress can be a bit confusing. This happens because the background audio is published as its own distinct audio track in the LiveKit room. Track egress is designed to export each track individually without mixing or transcoding, so every track—including the background audio—is treated separately and exported on its own. If you're looking to have the background audio combined with the agent's audio, a great option is to use Track Composite Egress. This feature lets you merge multiple tracks into a single output file, giving you a nicely synchronized audio stream. Feel free to reach out if you'd like me to walk you through setting up composite egress or if you have any questions about managing your track exports—I’m here to help! Sources: Track egress | LiveKit Docs | livekit-protocol/livekit/protocol/egress.py | Agent speech and audio | LiveKit Docs | livekit-agents/livekit/agents/voice/background_audio.py
g
I am using auto_egress so this is not configurable
t
I totally understand how important it is to have your audio just right! When using auto_egress, background audio is treated as a separate track because it’s published as its own independent audio source in the LiveKit room. This setup actually gives you more flexibility, especially if you want to handle background audio differently. Right now, auto_egress doesn’t support combining the background audio with the agent’s audio into a single file. If merging these tracks is something you need, you might want to consider doing that during post-processing by combining the separate audio files. If you’d like, I’m here to help guide you through managing or processing these files—just let me know! Sources: Agent speech and audio | LiveKit Docs | examples/drive-thru/drivethru_agent.py