colossal-airport-32984
08/07/2025, 7:32 AMtall-airline-16756
08/07/2025, 7:32 AMtall-airline-16756
08/07/2025, 7:32 AMavatar.png
, avatar.jpg
, or avatar.jpeg
in the same directory as your agent script.
2. Import Required Libraries: Include the necessary imports in your Python script: from PIL import Image
import os
from livekit.plugins import hedra
3. Load the Avatar Image: Use the following code to load the image: avatar_dir = os.path.dirname(os.path.abspath(__file__))
avatar_image = None
for ext in ['.png', '.jpg', '.jpeg']:
image_path = os.path.join(avatar_dir, f'avatar{ext}')
if os.path.exists(image_path):
avatar_image = Image.open(image_path)
break
if not avatar_image:
raise FileNotFoundError("No avatar image found. Please place an avatar.png, avatar.jpg, or avatar.jpeg in the directory.")
4. Create the Avatar Session: Initialize the session with your static image: avatar_session = hedra.AvatarSession(
avatar_participant_identity="static-avatar",
avatar_image=avatar_image,
)
5. Start the Avatar Session: Start the session within the LiveKit room: await avatar_session.start(session, room=job_context.room)
This will display the static image as the avatar in the LiveKit room. Let me know if you need further assistance!icy-nightfall-64225
08/07/2025, 7:33 AMtall-airline-16756
08/07/2025, 7:33 AM