forked from livekit/agents
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathagent_worker.py
More file actions
39 lines (27 loc) · 1004 Bytes
/
agent_worker.py
File metadata and controls
39 lines (27 loc) · 1004 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import logging
import os
from dotenv import load_dotenv
from PIL import Image
from livekit.agents import Agent, AgentServer, AgentSession, JobContext, cli
from livekit.plugins import hedra, openai
logger = logging.getLogger("hedra-avatar-example")
logger.setLevel(logging.INFO)
load_dotenv()
server = AgentServer()
@server.rtc_session()
async def entrypoint(ctx: JobContext):
session = AgentSession(
llm=openai.realtime.RealtimeModel(voice="alloy"),
resume_false_interruption=False,
)
# upload an avatar image or use an avatar id from hedra
avatar_image = Image.open(os.path.join(os.path.dirname(__file__), "avatar.jpg"))
hedra_avatar = hedra.AvatarSession(avatar_image=avatar_image)
await hedra_avatar.start(session, room=ctx.room)
await session.start(
agent=Agent(instructions="Talk to me!"),
room=ctx.room,
)
session.generate_reply(instructions="say hello to the user")
if __name__ == "__main__":
cli.run_app(server)