Initial working
This commit is contained in:
@@ -0,0 +1 @@
|
||||
# This file makes the src directory a Python package
|
||||
@@ -0,0 +1,40 @@
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from livekit import agents
|
||||
from livekit.agents import AgentSession, Agent, RoomInputOptions
|
||||
from livekit.plugins import openai, noise_cancellation, silero, deepgram, cartesia
|
||||
from livekit.plugins.turn_detector.multilingual import MultilingualModel
|
||||
|
||||
load_dotenv()
|
||||
|
||||
|
||||
class Assistant(Agent):
|
||||
def __init__(self) -> None:
|
||||
super().__init__(instructions="You are a helpful voice AI assistant.")
|
||||
|
||||
|
||||
async def entrypoint(ctx: agents.JobContext):
|
||||
session = AgentSession(
|
||||
stt=deepgram.STT(),
|
||||
llm=openai.LLM(model="gpt-4o-mini"),
|
||||
tts=cartesia.TTS(),
|
||||
vad=silero.VAD.load(),
|
||||
turn_detection=MultilingualModel(),
|
||||
)
|
||||
|
||||
await session.start(
|
||||
room=ctx.room,
|
||||
agent=Assistant(),
|
||||
room_input_options=RoomInputOptions(
|
||||
# LiveKit Cloud enhanced noise cancellation
|
||||
# - If self-hosting, omit this parameter
|
||||
# - For telephony applications, use `BVCTelephony` for best results
|
||||
noise_cancellation=noise_cancellation.BVC(),
|
||||
),
|
||||
)
|
||||
|
||||
await ctx.connect()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
agents.cli.run_app(agents.WorkerOptions(entrypoint_fnc=entrypoint))
|
||||
Reference in New Issue
Block a user