i am using room composite egress to export livekit...
# ask-ai
n
i am using room composite egress to export livekit room sessions as audio only files. the sessions are always between an agent and a user. can i export the files so that the agent's and user's audios are in separated audio channels?
t
Thanks for reaching out, Karl. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Room composite egress offers some options for audio channel separation in audio-only exports, and I’m happy to walk you through them! You can set the
audio_mixing
parameter to one of these: • DEFAULT_MIXING: This mixes all participants into a single audio stream. • DUAL_CHANNEL_AGENT: Places the agent’s audio on the left channel and all other participants on the right channel. • DUAL_CHANNEL_ALTERNATE: Alternates each new audio track between the left and right channels. That said, it doesn’t support fully separate channels for each participant individually. If having completely separate audio tracks per participant is important for your needs, I’d recommend looking into Track Egress or Track Composite Egress. These options let you export individual audio tracks for each participant, though you’d need to start separate egress requests for each one. Please feel free to reach out if you’d like some help or guidance on setting these up—I’m here to assist!
n
how can i set the mixing to DUAL_CHANNEL_AGENT in python?
t
I'd be happy to help you set
audio_mixing
to DUAL_CHANNEL_AGENT in Python for your room composite egress. To do this, you’ll want to configure the
RoomCompositeEgressRequest
with
audio_only=True
and set
audio_mixing=AudioMixing.DUAL_CHANNEL_AGENT
. This setup will beautifully place the agent's audio in the left channel and all other participants' audio in the right channel, making it easy to distinguish between them. Here’s a simple example to guide you:
Copy code
from livekit.protocol.egress import AudioMixing, RoomCompositeEgressRequest

request = RoomCompositeEgressRequest(
    room_name="your-room-name",
    layout="your-layout",
    audio_only=True,
    audio_mixing=AudioMixing.DUAL_CHANNEL_AGENT
)
Also, just a quick reminder to make sure your Python SDK is up-to-date for everything to run smoothly. If you need details on compatibility or installation, the LiveKit Python SDK repository is a great resource. Sources: livekit-protocol/livekit/protocol/egress.py | protobufs/livekit_egress.proto | test/edge.go | src/main/kotlin/io/livekit/server/EgressServiceClient.kt | Composite and web recordings | LiveKit docs
n
Are there any other prerequisites for the DUAL_CHANNEL_AGENT to work? Currently my resulting audio files have matching left and right tracks with both of them containing the agent's and user's audio. This is my egress request:
Copy code
egress_request = api.RoomCompositeEgressRequest(
    room_name=room_name,
    audio_only=True,
    audio_mixing=api.AudioMixing.DUAL_CHANNEL_AGENT,
    file_outputs=[
        api.EncodedFileOutput(
            file_type=api.EncodedFileType.OGG,
            filepath="{room_id}/{time}/session_recording.ogg",
            s3=api.S3Upload(
                region=region,
                access_key=access_key_id,
                secret=secret_access_key,
                bucket=bucket,
                assume_role_arn=session_exporter_role_arn,
            ),
        )
    ],
)
t
To make sure the DUAL_CHANNEL_AGENT audio mixing works smoothly, let's check a couple of important things together: • Audio-Only Output: It's important that the egress request includes
audio_only=True
. This setting helps the
audio_mixing
parameter do its job properly. • Agent Participant: There should be a participant clearly identified as the agent in the session. The agent's audio will come through the left channel, and everyone else's audio will be mixed into the right channel. Looking at your code, I see you’ve already got
audio_only=True
set up correctly—great job! Now, just double-check that the agent participant is properly marked in the session. If you’re still running into trouble, please don’t hesitate to reach out. I’m here to help you get this sorted! Sources: protobufs/livekit_egress.proto | livekit-protocol/src/livekit.rs | test/edge.go
p
Did you end up finding a solution, @numerous-receptionist-14192?
t
It looks like you might be referring to a different conversation or user. If there's anything else you'd like help with or if you have more questions, please don't hesitate to reach out—I’m here for you!
n
Yes, I did! Turns out it's an experimental feature which, in addition to configuring the mixing to dual channel, has to be enabled by the LiveKit team if using their cloud. You can send them a message and they can configure it per project.
p
Perfect - thanks a lot🙏 Super helpful!