-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathelevenlabs_tts.py
39 lines (32 loc) · 1.24 KB
/
elevenlabs_tts.py
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
from pathlib import Path
from dotenv import load_dotenv
from livekit.agents import JobContext, WorkerOptions, cli
from livekit.agents.voice import Agent, AgentSession
from livekit.plugins import deepgram, openai, elevenlabs, silero
load_dotenv(dotenv_path=Path(__file__).parent.parent / '.env')
class ElevenLabsAgent(Agent):
def __init__(self) -> None:
super().__init__(
instructions="""
You are a helpful assistant communicating through voice. You're helping me test ... yourself ... since you're the AI agent.
Don't use any unpronouncable characters.
""",
stt=deepgram.STT(),
llm=openai.LLM(model="gpt-4o"),
tts=elevenlabs.TTS(
encoding="pcm_44100",
model="eleven_multilingual_v2"
),
vad=silero.VAD.load()
)
async def on_enter(self):
await self.session.say(f"Hi there! Is there anything I can help you with?")
async def entrypoint(ctx: JobContext):
await ctx.connect()
session = AgentSession()
await session.start(
agent=ElevenLabsAgent(),
room=ctx.room
)
if __name__ == "__main__":
cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint))