How to record session and save it locally wiht pyt...
# ask-ai
c
How to record session and save it locally wiht python livekit agents and egress?
t
Thanks for reaching out, ZaidKaraymeh. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To record a session and save it locally using Python LiveKit agents and Egress, here are a couple of friendly options you can try: 1. Egress with Local Storage: - You can run the Egress service right on your local machine (like using Docker). - Just mount a folder from your computer into the Egress container. - Then, set up Egress to save files to that folder. - Use a
RoomCompositeEgressRequest
with a
filepath
that points to your mounted folder. Here’s a handy Docker command example:
Copy code
docker run --rm \
    -v ~/my-local-recordings:/out \
    -e EGRESS_CONFIG_FILE=/out/config.yaml \
    livekit/egress
2. RecorderIO for Agent Audio: - If you want to capture the agent’s internal audio streams (input/output) directly, you can use the
RecorderIO
class to save it to a local file. Check out this example code:
Copy code
from livekit.agents.voice.recorder_io import RecorderIO

recorder_io = RecorderIO(agent_session=session)
await recorder_io.start(output_path="/tmp/agent_audio.ogg")
For recording the whole session, I’d recommend going with Egress and a mounted local volume. If you’d like, I’m happy to walk you through setting up either of these methods step-by-step—just let me know! Sources: Session recording and transcripts | LiveKit Docs | Recording agent sessions | LiveKit Docs | README.md | livekit-agents/livekit/agents/voice/recorder_io/recorder_io.py