Two small starters for voice agents on Deepgram, with voices you can steer: excited, sarcastic, whispering, an Irish accent, a cowboy.
| Step | What | Get it at | Put it in .env as |
|---|---|---|---|
| 1 | Speech-to-text key | console.deepgram.com | DEEPGRAM_API_KEY |
| 2 | LLM key: pick one | console.groq.com or aistudio.google.com | GROQ_API_KEY or GEMINI_API_KEY |
| 3 | TTS steering token (your name and the event password) | intern-steer.deepgram.com/claim | STEER_URL and STEER_TOKEN |
Starter repo: github.com/deepgram/agent-to-agent-basic
| Starter | What it does | Run | Open |
|---|---|---|---|
| Voice agent | You talk to one agent. It picks an emotion for each sentence and its voice acts it out. | voice_agent.py |
http://localhost:7860 |
| Agent to agent | Two agents talk a topic through (by default: launch on Friday, or test for another week?). You can type a twist mid-scene. | agent_to_agent.py |
http://localhost:7861 |
Each starter is one short Python file, plus a page that shows what's happening as it happens. Copy one and make it yours.
You need Python 3.12 or 3.13, Chrome and the keys above.
cp .env.example .env # paste in your keys
uv sync
uv run voice_agent.py # or: uv run agent_to_agent.pyNo uv? python3 -m venv .venv && source .venv/bin/activate && pip install -r requirements.txt, then python voice_agent.py.
Steering (step 3) is optional. Without it you get plain voices. The terminal and the page both show whether steering is on. Everything else about steering is in STEERING.md.
- Voice agent: off by default. You take turns: while the agent talks, the mic is muted, so on laptop speakers it can't hear itself and cut itself off. Pausing mid-sentence is fine: if you carry on before it speaks, it drops that reply and keeps listening. Wearing headphones? Set
BARGE_IN = Truein voice_agent.py and it stops as soon as you talk. - Agent to agent: none. The agents take strict turns and never talk over each other. There's no mic, so you can't interrupt them. A twist you type goes into the next line they write, and the stop button ends the scene.
The LLM starts every sentence with an emotion tag, and steering TTS performs it:
LLM: [excited] Oh, I love that idea! [skeptical 0.6] But will it actually work?
→ ("Oh, I love that idea!", {"excited": 0.8}) → POST /speak → audio
→ ("But will it actually work?", {"skeptical": 0.6}) → POST /speak → audio
Each sentence goes to TTS as soon as it's complete, so the agent starts talking before the LLM finishes.
- Voice agent: Flux STT → LLM → steering TTS → playback.
- Agent to agent: each agent is a system prompt and a voice. While one agent speaks, the next is already writing its line, so there are no gaps.
On the page:
- The orb's color shows the current emotion.
- The pipeline lights up the stage that's working and shows its timing.
- The ribbon adds one tile per sentence, colored by its emotion. Hover over a tile to read the sentence.
The settings are at the top of each starter file. After editing web/, reload the page; after editing a .py file, restart the server.
| To change | Edit |
|---|---|
| Name, personality, greeting | NAME, PERSONA, GREETING in voice_agent.py |
| Let people interrupt the agent (use headphones) | BARGE_IN = True in voice_agent.py |
| The agents, topic, number of turns | AGENTS, TOPIC, TURNS in agent_to_agent.py |
| Voice (there are 50) | VOICE, or Agent(..., voice=...). The list is in STEERING.md |
| An accent or character that's always on | BASE_DIALS, e.g. {"accent_scotland": 0.7} or {"cowboy": 0.6} |
| What the LLM is told about emotions | emotion_rules() in kit/llm.py |
| Another model, or OpenAI | LLM_MODEL in .env, or OPENAI_API_KEY (plus OPENAI_BASE_URL for any OpenAI-compatible server) |
| Emotion emoji and colors | web/shared/look.js |
Some ideas:
- Let the agents hear you by giving
AgentToAgenttheEarsfromvoice_agent.py. - Give the voice agent tools.
- Teach the LLM steering's
[[pause=0.5]]markup (STEERING.md).
voice_agent.py the voice agent
agent_to_agent.py two agents talking
kit/ shared plumbing
stt.py Flux STT: you started talking, what you said, your turn ended
llm.py streams the LLM and splits it into (sentence, dials)
tts.py steering TTS, or plain Flux TTS when steering is off
speaker.py plays audio at real-time speed and keeps page events in sync with it
app.py web server: serves web/, one tab at a time on /ws
web/ the two pages, and shared/ (mic, playback, orb, pipeline, ribbon)
One WebSocket (/ws) carries audio as binary and events as JSON. speak and turn_done arrive when you hear them, not when they're generated.
| Event | Meaning |
|---|---|
ready |
You connected; carries the agents, voices, LLM and steering status |
user_start / user_partial / user_end |
You started talking / what you've said so far / you finished |
interrupted |
The voice agent was cut off: you typed, or talked over it with BARGE_IN on |
thinking / llm_first / llm_done |
The LLM started / wrote its first sentence (ms) / finished |
sentence |
A sentence and its dials |
tts / tts_audio |
A TTS request went out / its first audio came back (ms) |
speak / turn_done |
A sentence starts playing / the turn finished |
note / stopped / finished |
Agent to agent: your twist arrived / you pressed stop / the scene ended |
error |
Something failed |
The page sends mic audio as binary, text (a message to the voice agent, or a twist for agent to agent), and start / stop (agent to agent).
- The voice agent keeps cutting itself off:
BARGE_IN = Trueon speakers lets the mic hear the agent. Use headphones, or set it back toFalse. - "Steering OFF": check
STEER_URLandSTEER_TOKENin.env. Everything still works, with plain voices. - "another tab took over": only one tab can be connected at a time.
- No sound: use Chrome on localhost, and click the page first.
- 429 errors: both starters share one steering token, which allows 2 requests at a time. Run one starter at a time.