creamy-match-85520
08/21/2025, 7:33 AMtall-airline-16756
08/21/2025, 7:33 AMtall-airline-16756
08/21/2025, 7:33 AMAvatarSession with your updated image and start it fresh. Just a heads-up: the Hedra integration doesn’t support changing the avatar image on the fly within the same session.
Here’s a simple way to do it:
1. If needed, remove the existing avatar participant first to avoid any conflicts. You can do this using the LiveKit API by removing the participant by their identity.
2. Create a new AvatarSession by using the hedra.AvatarSession class and pass in your new image through the avatar_image parameter (which should be a PIL Image object).
3. Start this new avatar session with your agent session and room.
Here’s a quick example:
from PIL import Image
from livekit.plugins import hedra
# Load your new image
new_image = Image.open("/path/to/new_avatar.jpg")
# Create a new avatar session with the updated image
new_avatar = hedra.AvatarSession(
avatar_image=new_image,
avatar_participant_identity="hedra-avatar-agent" # You can use the same identity or a new one
)
# Start the new avatar session
await new_avatar.start(session, room=ctx.room)
Just remember, once you’ve created an AvatarSession, you can’t tweak it directly. To update the image, you’ll need to start a new session like this. And if you’re working with a frontend, don’t forget you might need to refresh the participant list or listen for updates so the change shows up smoothly.
Sources: Hedra virtual avatar integration guide | LiveKit Docs | livekit-plugins/livekit-plugins-hedra/README.md | complex-agents/role-playing/role_playing_frontend/components/character-port...