LiveKit complements Groq's high-performance speech recognition capabilities by providing text-to-speech and real-time communication features. This integration enables you to build end-to-end AI voice applications with:
When prompted for your OpenAI and Deepgram API key, press Enter to skip as we'll be using custommized plugins for Groq and ElevenLabs for fast inference speed.
lk app create --template voice-pipeline-agent-python
.env.local
file to replace OPENAI_API_KEY
and DEEPGRAM_API_KEY
with the following:GROQ_API_KEY=<your-groq-api-key>
ELEVEN_API_KEY=<your-elevenlabs-api-key>
requirements.txt
file and add the following line:livekit-plugins-elevenlabs>=0.7.9
agent.py
file with the following to configure Groq for STT with whisper-large-v3
, Groq for LLM with llama-3.3-70b-versatile
, and ElevenLabs for TTS:import logging
from dotenv import load_dotenv
from livekit.agents import (
AutoSubscribe,
JobContext,
JobProcess,
WorkerOptions,
cli,
llm,
)
from livekit.agents.pipeline import VoicePipelineAgent
from livekit.plugins import silero, openai, elevenlabs
load_dotenv(dotenv_path=".env.local")
logger = logging.getLogger("voice-agent")
def prewarm(proc: JobProcess):
proc.userdata["vad"] = silero.VAD.load()
async def entrypoint(ctx: JobContext):
initial_ctx = llm.ChatContext().append(
role="system",
text=(
"You are a voice assistant created by LiveKit. Your interface with users will be voice. "
"You should use short and concise responses, and avoiding usage of unpronouncable punctuation. "
"You were created as a demo to showcase the capabilities of LiveKit's agents framework."
),
)
logger.info(f"connecting to room {ctx.room.name}")
await ctx.connect(auto_subscribe=AutoSubscribe.AUDIO_ONLY)
# Wait for the first participant to connect
participant = await ctx.wait_for_participant()
logger.info(f"starting voice assistant for participant {participant.identity}")
agent = VoicePipelineAgent(
vad=ctx.proc.userdata["vad"],
stt=openai.STT.with_groq(model="whisper-large-v3"),
llm=openai.LLM.with_groq(model="llama-3.3-70b-versatile"),
tts=elevenlabs.TTS(),
chat_ctx=initial_ctx,
)
agent.start(ctx.room, participant)
# The agent should be polite and greet the user when it joins :)
await agent.say("Hey, how can I help you today?", allow_interruptions=True)
if __name__ == "__main__":
cli.run_app(
WorkerOptions(
entrypoint_fnc=entrypoint,
prewarm_fnc=prewarm,
),
)
python3 -m venv venv
source venv/bin/activate
python3 -m pip install -r requirements.txt
python3 agent.py dev
lk app create --template voice-assistant-frontend
pnpm install
pnpm dev
Challenge: Configure your voice assistant and the frontend to create a travel agent that will help plan trips!
For more detailed documentation and resources, see: