import logging
from dotenv import load_dotenv
from [Link] import (
AutoSubscribe,
JobContext,
JobProcess,
WorkerOptions,
cli,
llm,
)
from [Link] import VoicePipelineAgent
from [Link] import openai, deepgram, silero
load_dotenv(dotenv_path=".[Link]")
logger = [Link]("voice-agent")
def prewarm(proc: JobProcess):
[Link]["vad"] = [Link]()
async def entrypoint(ctx: JobContext):
initial_ctx = [Link]().append(
role="system",
text=(
"You are a voice assistant created by Ajay. Your interface with users
will be voice. "
"You should respond quickly and use friendly, human-like conversation. "
"You will act like a friend, addressing people like 'brother', 'friend',
'mother', 'father', 'uncle', 'sister', etc., depending on the role requested by the
user. "
"If a user asks you to act like a specific character, such as 'brother' or
'father', you will immediately take on that persona and communicate as that
character, including using their tone, expressions, and mannerisms. "
"You will do your best to sound as human-like as possible, reflecting the
behavior of the character the user asks you to act like. "
"Always use short, concise, and polite responses in Hindi."
),
)
[Link](f"connecting to room {[Link]}")
await [Link](auto_subscribe=AutoSubscribe.AUDIO_ONLY)
# Wait for the first participant to connect
participant = await ctx.wait_for_participant()
[Link](f"starting voice assistant for participant {[Link]}")
# This project is configured to use Deepgram STT, OpenAI LLM and TTS plugins
# Other great providers exist like Cartesia and ElevenLabs
# Learn more and pick the best one for your app:
# [Link]
assistant = VoicePipelineAgent(
vad=[Link]["vad"],
stt=[Link](),
llm=[Link](model="gpt-4o-mini"),
tts=[Link](),
chat_ctx=initial_ctx,
)
[Link]([Link], participant)
# The agent should be polite and greet the user when it joins :)
await [Link]("Hey Ajay, how can I help you today?",
allow_interruptions=True)
if __name__ == "__main__":
cli.run_app(
WorkerOptions(
entrypoint_fnc=entrypoint,
prewarm_fnc=prewarm,
),
)