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. Every TTS class is imported by name from the package barrel: import { ElevenLabsTTS } from "getpatter".

Quickstart

Supported providers

Model / voice / format enums

Each provider exports typed const-objects for valid model IDs, voice presets, and output formats alongside the provider class. They keep model / voice / outputFormat options 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 modelId literals: "eleven_v3", "eleven_turbo_v2_5", "eleven_multilingual_v2", "eleven_monolingual_v1".

Telephony factories — forTwilio() / forTelnyx()

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.forTwilio() / forTelnyx() and ElevenLabsConvAI.forTwilio() / forTelnyx() 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 forTwilio() factories apply unchanged.
WebSocket variant: ElevenLabsWebSocketTTS is a drop-in alternative that streams audio over a WebSocket connection, saving ~50 ms of HTTP setup + TLS cold-start per utterance. See ElevenLabs WebSocket TTS for the full reference and limitations.

OpenAI

OpenAITTSVoice and OpenAITTSModel are exported alongside the provider class.
OpenAI TTS returns audio at 24 kHz — Patter automatically resamples to targetSampleRate (16 kHz by default; pass targetSampleRate: 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 throws at construction time if no API key is resolved:

What’s Next

STT

Speech-to-text providers.

LLM

Language model providers.