Skip to main content

TTS (Text-to-Speech)

TTS is used in pipeline mode to synthesize the agent’s response audio. If you use an engine such as OpenAIRealtime or ElevenLabsConvAI, speech synthesis is handled internally by the engine. Each TTS ships as both a namespaced class (from getpatter.tts import elevenlabselevenlabs.TTS()) and a flat alias (from getpatter import ElevenLabsTTS). They are equivalent — the flat aliases are convenient for short examples, the namespaced form avoids name collisions when mixing providers.

Quickstart

The same agent using namespaced imports:

Supported providers

Model / voice / format enums

Each provider exports typed StrEnums for valid model IDs, voice presets, and output formats alongside the provider class. They keep model= / voice= / output_format= arguments tab-completable and reject typos at construction time, while still accepting raw strings for forward compatibility:

ElevenLabs

Streaming HTTP TTS via ElevenLabs. Default model "eleven_flash_v2_5" (~75 ms TTFB, drop-in replacement for eleven_turbo_v2_5). Other valid model_id literals: "eleven_v3", "eleven_turbo_v2_5", "eleven_multilingual_v2", "eleven_monolingual_v1".

Telephony factories — for_twilio() / for_telnyx()

When ElevenLabs runs in pipeline mode behind a phone carrier you can negotiate the carrier-native codec at the ElevenLabs HTTP layer and skip per-chunk SDK-side transcoding. The factory variants do that for you:
CartesiaTTS.for_twilio() / for_telnyx() and ElevenLabsConvAI.for_twilio() / for_telnyx() work the same way. Use them whenever you know the call will go out over Twilio or Telnyx — they shave tens of milliseconds off TTFB and drop CPU on long calls. Plivo pins mulaw 8 kHz in its answer XML, so the .for_twilio() factories apply unchanged.

WebSocket variant

ElevenLabsWebSocketTTS is an opt-in low-latency drop-in for ElevenLabsTTS that uses the /stream-input WebSocket endpoint. It saves ~50 ms of HTTP request setup per utterance and avoids TLS cold-starts on bursty traffic. See the ElevenLabs WebSocket setup page for full details.
The WebSocket endpoint does not support eleven_v3* models — use the HTTP ElevenLabsTTS for v3.

OpenAI

OpenAITTSVoice and OpenAITTSModel are exported alongside the provider class:
OpenAI TTS returns audio at 24 kHz — Patter automatically resamples to target_sample_rate (16 kHz by default; pass target_sample_rate=8000 to deliver μ-law-ready PCM directly to Twilio).

Cartesia

Raw PCM streaming via Cartesia’s sonic-2 bytes endpoint. See Cartesia setup.

Rime

Arcana (high fidelity) and Mist (low latency) via Rime’s HTTP endpoint. See Rime setup.

LMNT

Blizzard and Aurora via the LMNT HTTP API. See LMNT setup.

xAI

Grok text-to-speech (default voice eve) with 26 built-in voices, inline speech tags, custom voice cloning, and telephony-native output. See xAI TTS setup.

Missing credentials

Each class raises ValueError at construction time if no API key is resolved:

What’s Next

STT

Speech-to-text providers.

LLM

Language model providers.