Build a real-time voice agent with Pipecat, the open-source Voice AI framework, and AssemblyAI on both speech ends: AssemblyAI-STT-3.7-Realtime-Agent for speech-to-text and AssemblyAI text-to-speech for the agent's voice.
Pipecat's modular pipeline design means you can swap any component without touching the rest. AssemblyAI has first-party Pipecat services for both sides, AssemblyAISTTService and AssemblyAITTSService, so there's no manual WebSocket wiring, and one API key covers both.
Why AssemblyAI in Pipecat?
AssemblyAI-STT-3.7-Realtime-Agent is AssemblyAI's real-time speech-to-text model for voice agents. On AssemblyAI's English voice-agent benchmark of 12,460 voice-agent calls, it posts the lowest word error rate of the 26 streaming models we ran:
| Metric | AssemblyAI AssemblyAI-STT-3.7-Realtime-Agent | Soniox Realtime v6 | ElevenLabs Scribe v3 Live | Deepgram Nova-3 |
|---|---|---|---|---|
| Word error rate (voice-agent benchmark) | 4.53% | 6.02% | 7.38% | 8.64% |
On Pipecat's own open STT benchmark, its predecessor, Universal-3.6 Pro Realtime, posts a 0.96% pooled semantic word error rate, with the final transcript landing a median 307 ms after the user stops speaking. AssemblyAI's published figure for AssemblyAI-STT-3.7-Realtime-Agent is a final transcript 86 ms after the caller stops speaking.
Beyond raw accuracy, it brings three things that matter for live conversation. Turn detection combines semantic context with voice activity, so you get fewer awkward double-responses when users pause mid-thought. Context Carryover means the model hears each turn in the context of your agent's last question. And keyterm prompting is included.
The other end of the pipeline runs on AssemblyAI too. AssemblyAITTSService speaks with assemblyai-tts-1, a model trained on millions of hours of audio, including real conversational data, and faster than other production voice agent TTS models. Production time to first audio is 90 ms. In the launch post's single-client lab test, median time to first byte was 47 ms; that's a lab figure, not what a caller hears over a real network. On the same post's pronunciation set it scored 93.7% entity accuracy, so order numbers and confirmation codes come out as written.
Heads up on model IDs: this tutorial uses the current assemblyai-stt-3-7-realtime-agent string throughout. It needs pipecat-ai 1.17.0 or newer, where it's also the default model for AssemblyAISTTService. Upgrading from Universal-3.6 Pro Realtime is a one-line change to the model name, and universal-3-6-pro stays available if you need to pin the previous model. If you're still on an older legacy model ID, switch to assemblyai-stt-3-7-realtime-agent.
AssemblyAI-STT-3.7-Realtime-Agent hears the user and AssemblyAI text-to-speech answers, both through first-party Pipecat services on one API key.
Prerequisites
- Python 3.11+
- AssemblyAI API key (free account). It covers both speech-to-text and text-to-speech.
- OpenAI API key
- Daily API key (the example bot opens a Daily room for you to talk to it)
Quick start
git clone https://github.com/kelsey-aai/voice-agent-pipecat-universal-3-6-pro.git
cd voice-agent-pipecat-universal-3-6-pro
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt # requires pipecat-ai>=1.17.0
cp .env.example .env
# Edit .env with your API keys
python bot.pySpeak into your microphone after the greeting. For WebRTC or Daily testing, see the integration guide.
AssemblyAITTSService arrived in pipecat-ai 1.15.0, and AssemblyAI-STT-3.7-Realtime-Agent needs 1.17.0+. If your requirements pin anything older, upgrade before running:
pip install -U "pipecat-ai[assemblyai,openai,daily,silero]>=1.17.0"Here's the core of the agent. Note the settings=...Settings(...) structure on both AssemblyAI services: that's the current plugin API. The assistant_aggregator at the end of the pipeline is what enables automatic conversation context:
import os
from pipecat.audio.vad.silero import SileroVADAnalyzer
from pipecat.pipeline.pipeline import Pipeline
from pipecat.processors.aggregators.llm_context import LLMContext
from pipecat.processors.aggregators.llm_response_universal import (
LLMContextAggregatorPair,
LLMUserAggregatorParams,
)
from pipecat.services.assemblyai.stt import AssemblyAISTTService
from pipecat.services.assemblyai.tts import AssemblyAITTSService
from pipecat.services.openai.llm import OpenAILLMService
stt = AssemblyAISTTService(
api_key=os.environ["ASSEMBLYAI_API_KEY"],
settings=AssemblyAISTTService.Settings(
model="assemblyai-stt-3-7-realtime-agent",
min_turn_silence=100,
),
vad_force_turn_endpoint=True, # Pipecat mode (default): VAD + Smart Turn control turns
)
llm = OpenAILLMService(api_key=os.environ["OPENAI_API_KEY"])
tts = AssemblyAITTSService(
api_key=os.environ["ASSEMBLYAI_API_KEY"],
settings=AssemblyAITTSService.Settings(
model="assemblyai-tts-1",
voice="aai-kyla", # Kyla
),
)
context = LLMContext()
user_aggregator, assistant_aggregator = LLMContextAggregatorPair(
context,
user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()),
)
pipeline = Pipeline([
transport.input(),
stt,
user_aggregator,
llm,
tts,
transport.output(),
assistant_aggregator, # Feeds each agent reply back as conversation context automatically
])AssemblyAI-STT-3.7-Realtime-Agent features
Keyterm prompting
Boost accuracy on domain-specific vocabulary, included at no extra cost and with no restart required:
stt = AssemblyAISTTService(
api_key=os.environ["ASSEMBLYAI_API_KEY"],
settings=AssemblyAISTTService.Settings(
model="assemblyai-stt-3-7-realtime-agent",
keyterms_prompt=["AssemblyAI", "Pipecat", "YourBrandName"],
),
)It's essential for medical, legal, and financial applications where names and codes matter.
Conversation context (Context Carryover)
AssemblyAI-STT-3.7-Realtime-Agent keeps a short memory of the dialog and transcribes each user turn in the context of what your agent just said. After your agent asks "What's your email address?", it can produce user@assemblyai.com instead of "user at assemblyai dot com". On Universal-3.5 Pro Realtime, feeding the agent's question to the model cut WER by 10.2% on a 20,000-file voice-agent benchmark.
In Pipecat this is automatic. As long as your pipeline includes the assistant_aggregator from LLMContextAggregatorPair (as above), the plugin feeds each completed agent reply to the model as agent_context. To seed context for the very first user reply, set agent_context at construction time:
settings=AssemblyAISTTService.Settings(
model="assemblyai-stt-3-7-realtime-agent",
agent_context="Hi! Thanks for calling Acme. What's the email on your account?",
)Voice Focus (noisy audio)
Voice Focus is server-side noise suppression that isolates the primary speaker before audio reaches the model. Use it instead of client-side noise cancellation:
settings=AssemblyAISTTService.Settings(
model="assemblyai-stt-3-7-realtime-agent",
voice_focus="far-field", # "near-field" for close-talking mics
)Multilingual support
AssemblyAI-STT-3.7-Realtime-Agent code-switches natively across 32 languages (English, Spanish, French, German, Italian, Portuguese, Korean, Russian, and more), including mid-sentence switches. It's on by default; to steer toward known languages, pass up to 10 Pipecat Language values in language_codes, for example language_codes=[Language.EN, Language.ES].
Speaker labels (optional)
For multi-party conversations, enable per-turn speaker labels:
settings=AssemblyAISTTService.Settings(
model="assemblyai-stt-3-7-realtime-agent",
speaker_labels=True,
)AssemblyAI text-to-speech in Pipecat
AssemblyAITTSService streams over a single WebSocket session for the whole call. It handles the parts of text-to-speech that usually take custom code:
- Sentence-by-sentence requests. Each sentence of the LLM's reply is its own request, so the agent starts speaking after the first sentence rather than after the whole reply.
- Barge-in without reconnecting. When the user interrupts, the service sends
Cancel, drops the audio still in flight and keeps the session open. - Word-timed context. Per-word timings drive Pipecat's spoken-text frames, so an interrupted reply is saved to the LLM context only up to the word the user heard. Our guide to TTS word timestamps explains what those timings are good for.
- Long and quiet calls. It sends a keepalive every 30 seconds while the agent is silent, and it replaces the session between replies before the 1-hour session cap.
- Connect at startup. The service connects when the pipeline starts, so the first reply doesn't wait on a handshake.
Choose a voice and language
voice takes a voice ID from the voice catalog in the AssemblyAI dashboard, a library slug such as aai-kyla, or the slug of a cloned voice. There are thousands of voices to pick from. The service defaults to Audrey; the raw API defaults to aai-kyla in English. Set it explicitly so the voice never changes under you.
language takes a Pipecat Language. The API doesn't detect language, so match it to what your LLM writes. Six languages are supported: English, Spanish, German, French, Italian and Portuguese.
from pipecat.transcriptions.language import Language
tts = AssemblyAITTSService(
api_key=os.environ["ASSEMBLYAI_API_KEY"],
settings=AssemblyAITTSService.Settings(
voice="aai-constanza", # Constanza, a Spanish voice
language=Language.ES,
),
)Changing voice, language or model mid-call reconnects the session.
EU data residency and telephony
To keep text and audio in the EU, point the service at the EU host with url="wss://tts.eu.assemblyai.com/v1/ws". A cloned voice only works in the zone it was created in.
sample_rate defaults to the pipeline's output rate, so a phone pipeline running at 8 kHz gets 8 kHz audio without extra settings. The service accepts 8000, 16000, 22050, 24000, 44100 and 48000 Hz.
One key for STT, LLM and TTS
Point OpenAILLMService at LLM Gateway (base_url="https://llm-gateway.assemblyai.com/v1", with your AssemblyAI key as api_key), and all three models run on one key and one bill. The AssemblyAI TTS on Pipecat docs show the full all-AssemblyAI bot. For a longer build that also covers the Sync API and deploying to Pipecat Cloud, see how to build and deploy a voice agent with Pipecat.
Tuning turn detection
In Pipecat mode (vad_force_turn_endpoint=True, the default), Pipecat's VAD and Smart Turn analyzer decide when the user is done, and max_turn_silence is auto-synced to min_turn_silence. Start with the mode preset and fine-tune from there:
settings=AssemblyAISTTService.Settings(
model="assemblyai-stt-3-7-realtime-agent",
mode="balanced", # "min_latency" · "balanced" · "max_accuracy"
min_turn_silence=100, # raise to 200–500 if entities split across turns
)To let AssemblyAI's own turn detection control turn endings instead, set vad_force_turn_endpoint=False. Then max_turn_silence is respected independently.
Stream real conversations through AssemblyAI's streaming speech-to-text in the Playground and watch turn detection and context carryover work before you wire up the pipeline.
Note: end_of_turn_confidence_threshold and format_turns do not apply to AssemblyAI-STT-3.7-Realtime-Agent. Turn detection is handled by the model and transcripts are always formatted; those parameters belong to the older universal-streaming models.
Deploy to Pipecat Cloud
pip install pipecatcloud
pcc auth login
pcc init
pcc secrets set my-agent-secrets --file .env
pcc deployResources
- AssemblyAI Pipecat integration guide
- Pipecat's AssemblyAI TTS reference
- Pipecat docs
- Pipecat GitHub
- Building on LiveKit instead? The same stack is in our LiveKit voice agent tutorial.
Get a free AssemblyAI account and connect AssemblyAI-STT-3.7-Realtime-Agent ($0.45/hr) and AssemblyAI text-to-speech ($15 per 1M characters) to Pipecat in minutes. No credit card required.
Frequently Asked Questions (FAQs)
Does Pipecat support AssemblyAI text-to-speech?
Yes. AssemblyAITTSService (pipecat.services.assemblyai.tts) ships in pipecat-ai 1.15.0 and later, installed with the assemblyai extra. It streams the agent's replies over one WebSocket session per call, cancels in-flight audio on barge-in without dropping the session, and uses the same API key as AssemblyAISTTService.
What is the best speech-to-text model for a Pipecat voice agent?
AssemblyAI's AssemblyAI-STT-3.7-Realtime-Agent (assemblyai-stt-3-7-realtime-agent) is purpose-built for voice agents. It posts a 4.53% word error rate on AssemblyAI's English voice-agent benchmark, the lowest of the 26 streaming models we ran, and AssemblyAI's published figure puts the final transcript 86 ms after the caller stops speaking. It integrates through AssemblyAI's first-party Pipecat service, where it's the default model from pipecat-ai 1.17.0, with Context Carryover and keyterm prompting included.
Can I run STT, LLM and TTS on one AssemblyAI API key in Pipecat?
Yes. AssemblyAISTTService and AssemblyAITTSService take the same ASSEMBLYAI_API_KEY. Point OpenAILLMService at AssemblyAI's LLM Gateway with that key and base_url="https://llm-gateway.assemblyai.com/v1", and the whole loop runs on one key and one bill.
Which voice does AssemblyAITTSService use by default?
AssemblyAITTSService defaults to Audrey (49c443a4-8a1d-5f7e-b70b-98bdbd9823c3), while the raw AssemblyAI TTS API defaults to aai-kyla in English. Set voice explicitly in AssemblyAITTSService.Settings so an upgrade never changes how your agent sounds. Any voice ID from the AssemblyAI dashboard's voice catalog, or a cloned voice's slug, works.
How do I keep TTS audio in the EU in a Pipecat agent?
Construct AssemblyAITTSService with url="wss://tts.eu.assemblyai.com/v1/ws", so text and audio are processed in the EU data zone. Point your STT and LLM at their EU hosts as well. A cloned voice only works on the host of the zone it was created in.
How much does an AssemblyAI Pipecat voice agent cost?
AssemblyAI-STT-3.7-Realtime-Agent is $0.45/hr, billed on session duration, with keyterm prompting included. AssemblyAI text-to-speech is $15 per 1M characters. Neither caps how many sessions you have open at once (only new sessions per minute are rate-limited, and that limit grows with use), there are no minimums, and your LLM bills separately. AssemblyAI has a free tier so you can build and test before adding a card.