In a user-agent conversation, is there a way to sh...
# ask-ai
a
In a user-agent conversation, is there a way to show the agent visualization in the recording? and not only the user participant.
t
Thanks for reaching out, Ron. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'd love to help you include agent visualization in your user-agent conversation recordings! Here are a couple of friendly approaches you can try: • Audio Visualization: If your agent uses audio (like a voice assistant), you can bring it to life with components such as
BarVisualizer
(React),
AgentBarAudioVisualizer
(Swift), or similar tools. These will create a dynamic audio waveform that beautifully reflects the agent’s speech and state. • Video Visualization: If your agent provides a video track (like a virtual avatar), you can showcase it using a video track renderer like
VideoTrack
. It’s a great way to make the experience more engaging! When it comes to recordings: • Room Recording: If you're using LiveKit’s server-side recording, the good news is that the agent's audio and video tracks are automatically included—making your job easier! • Client-Side Recording: Just make sure the visualization component is rendered in the UI that you’re recording on the frontend, so everything you want is captured. If you'd like, I’m here to provide more details or even some examples to help you get started. Just let me know! Sources: Docs::Agents | Bringing AI avatars to voice agents | Bringing AI avatars to voice agents | Bringing AI avatars to voice agents
a
Can you give me code example or a link that shows the agent visualization in the recording? I'm using LiveKit’s server-side recording but in the recording i see only the user. I'm using composite-room recording.
t
I'd love to help you include agent visualization in your composite-room recordings using LiveKit’s server-side recording. Here’s a straightforward way to get that set up: 1. Start Room Composite Egress: First, make sure your egress is set with
audio_only=False
so it captures both audio and video. You can use the
RoomCompositeEgressRequest
API to kick off the recording. Here’s a handy Python example for you:
Copy code
from livekit import api

async def start_recording():
    req = api.RoomCompositeEgressRequest(
        room_name="your-room-name",
        audio_only=False,
        preset=api.EncodingOptionsPreset.H264_720P_30,
        file_outputs=[
            api.EncodedFileOutput(
                file_type=api.EncodedFileType.MP4,
                filepath="recordings/session.mp4",
                s3=api.S3Upload(
                    bucket="your-bucket-name",
                    region="us-east-1",
                    access_key="your-access-key",
                    secret="your-secret-key",
                ),
            )
        ],
    )
    lkapi = api.LiveKitAPI()
    await lkapi.egress.start_room_composite_egress(req)
1. Render Agent Visualization: Next, make sure the agent’s visualization—like an audio waveform or video avatar—is showing up in your room layout. If you’re working with React, the
BarVisualizer
component is a great way to do this:
Copy code
import { useVoiceAssistant, BarVisualizer } from "@livekit/components-react";

function AgentVisualizer() {
  const { state: agentState, audioTrack } = useVoiceAssistant();

  return (
    
      
      {agentState}

    
  );
}
1. Verify Recording: Finally, double-check that your composite recording includes all media tracks published to the room, including the agent’s visualization—this will happen as long as it’s part of your room layout. If you’d like to dive deeper, the Egress recording documentation is a fantastic resource. And of course, feel free to reach out if you want me to walk you through anything else or provide more examples—I’m here to help! Sources: Session recording and transcripts | LiveKit Docs | Recording agent sessions | LiveKit Docs | OpenAI and LiveKit partner to turn Advanced Voice into an API | Bringing AI avatars to voice agents | Docs::Agents
a
I already tried what you said, but in the recording I see only the user and not the agent visualization in my code I tried also layout="grid" this is part of the recording code: I request = api.RoomCompositeEgressRequest( room_name=room_name, layout="speaker", #"grid", preset=api.EncodingOptionsPreset.PORTRAIT_H264_1080P_30, #portrait 1080X1920 #landscape: api.EncodingOptionsPreset.H264_720P_30, audio_only=False, file_outputs=[ api.EncodedFileOutput( file_type=api.EncodedFileType.MP4, filepath=f"{filename_prefix}.mp4", s3=api.S3Upload( access_key=os.getenv("DO_SPACES_KEY", ""), secret=os.getenv("DO_SPACES_SECRET", ""), region=region, bucket=bucket_name, endpoint=f"https://{endpoint}", force_path_style=True ), ) ] ) logger.info(f"Starting recording for room: {room_name}") response = await self._livekit_api.egress.start_room_composite_egress(request) My using of the barVisualizer: interface AgentAudioTileProps { state: AgentState; audioTrack: TrackReference; className?: string; } export const AgentTile = ({ state, audioTrack, className, ref, }: React.ComponentProps<'div'> & AgentAudioTileProps) => { return ( <div ref={ref} className={cn(className)}> <BarVisualizer barCount={5} state={state} options={{ minHeight: 5 }} trackRef={audioTrack} className={cn('flex aspect-video w-40 items-center justify-center gap-1')} > <span className={cn([ 'bg-muted min-h-4 w-4 rounded-full', 'origin-center transition-colors duration-250 ease-linear', 'data-[lk-highlighted=true]:bg-foreground data-[lk-muted=true]:bg-muted', ])} /> </BarVisualizer> </div> ); };
t
I'm here to help you get the agent visualization showing up in your composite-room recordings! Let's walk through a few important checks together: 1. Verify Agent Video Track Publication: Please make sure the agent is actually publishing its video track to the room. The recording system looks for video tracks and decoded frames before it starts recording, so if there’s no video track published, it won’t appear in the recording. 2. Check Track Subscription: Double-check that your frontend application is subscribing to the agent’s video track. If the track isn’t subscribed to, it won’t be part of the composite recording. 3. Validate Avatar Worker Configuration: If you’re using an avatar worker to publish the agent’s video, ensure it’s set up with the
lk.publish_on_behalf
attribute pointing to the agent’s identity. This helps the video track associate correctly with the agent. 4. Confirm Visualizer is Enabled: For audio visualization, please verify that audio visualization is turned on when creating the Room. For example, in Flutter, you can use
RoomOptions(enableVisualizer: true)
. 5. Check Recording Initiation Timing: Keep in mind that composite recording starts when video frames are decoded or after a timeout of 5-10 seconds. If the agent’s video track is published after this window, it might not be included. 6. Verify Participant Identification: Make sure the agent participant is correctly identified as an agent (participant kind = agent) in the room. Visualization components specifically look for agent participants. If you’d like, I’m more than happy to help you with any of these steps or provide some additional code examples. Just let me know! Sources: Docs::Agents | template-default/src/Room.tsx | Composite and web recordings | LiveKit Docs | src/components/playground/Playground.tsx | Docs::Agents