creamy-window-79763
07/09/2025, 10:50 AMtall-airline-16756
07/09/2025, 10:50 AMtall-airline-16756
07/09/2025, 10:50 AMfrom livekit.agents import JobContext, WorkerOptions, cli
from livekit.agents.pipeline import VoicePipelineAgent
from livekit.plugins import deepgram, openai, silero
async def entrypoint(ctx: JobContext):
agent = VoicePipelineAgent(
vad=silero.VAD.load(),
stt=deepgram.STT(),
llm=openai.LLM(),
tts=openai.TTS(),
)
# Connect and start the agent with room context
await ctx.connect(auto_subscribe=AutoSubscribe.AUDIO_ONLY)
agent.start(ctx.room)
# Use await agent.say()
await agent.say("Hey, how can I help you today?", allow_interruptions=True)
Sources: delay-handling/README.mdoccreamy-window-79763
07/09/2025, 10:52 AMtall-airline-16756
07/09/2025, 10:52 AMclass MyAgent(Agent):
def __init__(self) -> None:
super().__init__(
instructions="You are a helpful assistant.",
stt=deepgram.STT(),
llm=openai.LLM(model="gpt-4o"),
tts=openai.TTS(),
vad=silero.VAD.load()
)
async def greet_user(self):
await self.session.say("Hey there! I'm ready to help you out - what can I do for you today?")
# Usage
agent = MyAgent()
await agent.greet_user()
I see you're working on setting up an agent with a greeting! Just a friendly tip: make sure your agent is all set up and connected to a room before you call say()
. That way, everything will run smoothly. Need any help walking through the setup?
Sources: chain-of-thought-tts/agent.py | Agent speech | LiveKit Docscreamy-window-79763
07/09/2025, 10:54 AMtall-airline-16756
07/09/2025, 10:55 AMfrom livekit.agents import Agent, function_tool
class MyAgent(Agent):
@function_tool
async def greet_user(self):
await self.say("Hello, how are you today?")
Hey there! Let me walk you through this cool code snippet. We've got an Agent with a friendly greeting method. By using the @function_tool
decorator and await self.say()
, we're setting up our agent to warmly welcome users with a simple "Hello, how are you today?" Pretty neat, right? 😊
Sources: pipeline-tts/tts_comparison.py | Tool definition and use | LiveKit Docscreamy-window-79763
07/09/2025, 11:08 AMtall-airline-16756
07/09/2025, 11:09 AM