Overview
ElevenLabs provides high-quality text-to-speech synthesis with three service implementations:ElevenLabsTTSService(WebSocket) — Real-time streaming with word-level timestamps, audio context management, and interruption handling. Recommended for interactive applications.ElevenLabsHttpTTSService(HTTP) — Simpler batch-style synthesis. Suitable for non-interactive use cases or when WebSocket connections are not possible.ElevenLabsDialogueTTSService(WebSocket) — Uses the multi-context Text-to-Dialogue endpoint, which serves the Eleven v3 and v4 dialogue models (eleven_v3,eleven_v3_conversational,eleven_v4_turbo). The default model iseleven_v4_turbo. These models support inline audio tags. Requires workspace access to the Text-to-Dialogue API.
ElevenLabs TTS API Reference
Complete API reference for all parameters and methods
Example Implementation
Complete example with WebSocket streaming
ElevenLabs Documentation
Official ElevenLabs TTS API documentation
Voice Library
Browse and clone voices from the community
Text-to-Dialogue Example
Complete example using Eleven v3 and v4 models
Text-to-Dialogue Documentation
Official ElevenLabs Text-to-Dialogue API documentation
Installation
Prerequisites
- ElevenLabs Account: Sign up at ElevenLabs
- API Key: Generate an API key from your account dashboard
- Voice Selection: Choose voice IDs from the voice library
Configuration
ElevenLabsTTSService
str
required
ElevenLabs API key.
str
default:"None"
deprecated
Deprecated since 0.0.105, removed in 2.0.0. Use
settings=ElevenLabsTTSService.Settings(voice=...) instead.str
default:"None"
deprecated
Deprecated since 0.0.105, removed in 2.0.0. Use
settings=ElevenLabsTTSService.Settings(model=...) instead.str
default:"wss://api.elevenlabs.io"
WebSocket endpoint URL. Override for custom or proxied deployments.
int
default:"None"
Output audio sample rate in Hz. When
None, uses the pipeline’s configured
sample rate. Must be 8000, 16000, 22050, 24000, 32000, 44100, or 48000; any
other rate logs a warning and the service requests 24000 Hz audio, which then
plays at the wrong speed.bool
default:"None"
Whether to enable ElevenLabs’ auto mode, which reduces latency by disabling
server-side chunk scheduling and buffering. Recommended when sending complete
sentences or phrases. When
None (default), auto mode is automatically
enabled for SENTENCE aggregation and disabled for TOKEN aggregation —
because token streaming relies on the server-side chunk scheduler to
accumulate enough text for natural-sounding synthesis.bool
default:"None"
Whether ElevenLabs parses SSML tags in the text. When
None, the parameter
isn’t sent and the ElevenLabs default applies.bool
default:"None"
Whether to enable ElevenLabs server-side logging. Set to
False for zero
retention mode (enterprise only). When None, the parameter isn’t sent and
the ElevenLabs default applies.TextAggregationMode
default:"None"
Controls how incoming text is aggregated before synthesis.
SENTENCE (used
when None) buffers text until sentence boundaries, producing more natural
speech. TOKEN streams tokens directly for lower latency. Import from
pipecat.services.tts_service.bool
default:"None"
deprecated
Deprecated since 0.0.104, removed in 2.0.0. Use
text_aggregation_mode
instead.InputParams
default:"None"
deprecated
Deprecated since 0.0.105, removed in 2.0.0. Use
settings=ElevenLabsTTSService.Settings(...) instead.List[PronunciationDictionaryLocator]
default:"None"
deprecated
Deprecated since 1.6.0, removed in 2.0.0. Use the
text_transforms
parameter with replace_text instead. Pronunciation dictionary substitutions
can rewrite the spoken words in ways that no longer match the text sent to
synthesis, which breaks the alignment-based word-completion tracking used to
attribute spoken text back to the conversation context.ElevenLabsHttpTTSService
The HTTP service accepts the same parameters as the WebSocket service excepturl, auto_mode, and enable_ssml_parsing, with these differences:
aiohttp.ClientSession
required
An aiohttp session for HTTP requests. You must create and manage this
yourself.
str
default:"https://api.elevenlabs.io"
HTTP API base URL (instead of
url for WebSocket).List[PronunciationDictionaryLocator]
default:"None"
deprecated
Deprecated since 1.6.0, removed in 2.0.0. Use the
text_transforms
parameter with replace_text instead. Pronunciation dictionary substitutions
can rewrite the spoken words in ways that no longer match the text sent to
synthesis, which breaks the alignment-based word-completion tracking used to
attribute spoken text back to the conversation context.ElevenLabsDialogueTTSService
str
required
ElevenLabs API key.
str
default:"wss://api.elevenlabs.io"
WebSocket endpoint URL. Override for custom or proxied deployments.
int
default:"None"
Output audio sample rate in Hz. When
None, uses the pipeline’s configured
sample rate. Accepts the same rates as ElevenLabsTTSService.bool
default:"None"
Whether to enable ElevenLabs server-side logging. Set to
False for zero
retention mode (enterprise only).int
default:"None"
Seed for reproducible generation.
TextAggregationMode
default:"None"
Text-to-Dialogue concatenates consecutive inputs verbatim, so only
SENTENCE
aggregation is supported. Any other value is ignored with a warning.ElevenLabsDialogueTTSService.Settings
default:"None"
Runtime-configurable settings. See Text-to-Dialogue
settings below.
Settings
Runtime-configurable settings passed via thesettings constructor argument using ElevenLabsTTSService.Settings(...). These can be updated mid-conversation with TTSUpdateSettingsFrame. See Service Settings for details.
None values aren’t sent, so the ElevenLabs API defaults apply. See
ElevenLabs voice
settings
for details on how these parameters interact.Text-to-Dialogue settings
ElevenLabsDialogueTTSService.Settings(...) accepts a smaller set. Text-to-Dialogue reads only stability; it silently ignores the other voice settings the text-to-speech endpoint accepts.
Usage
Basic Setup
With Voice Customization
Updating Settings at Runtime
Voice settings can be changed mid-conversation usingTTSUpdateSettingsFrame:
HTTP Service
Text-to-Dialogue (Eleven v3 and v4)
Notes
- Models that accept
language: Six models take a language code —eleven_flash_v2_5andeleven_turbo_v2_5cover 32 languages;eleven_v3andeleven_v3_conversationalcover 74; andeleven_v4andeleven_v4_turbocover 84 (adding Asturian, Burmese, Cantonese, Māori, Maltese, Mongolian, Occitan, Odia, Tajik, and Uzbek to the v3 set). Any other model,eleven_multilingual_v2included, detects the language from the text itself; settinglanguagethere logs a warning and the code is dropped. A code the model doesn’t cover is dropped the same way. - WebSocket vs HTTP: Both services report word-level timestamps. The WebSocket service keeps one connection open and streams text into it, making it better for interactive conversations. The HTTP service makes a separate request for each piece of text.
- Text aggregation: Sentence aggregation is enabled by default (
text_aggregation_mode=TextAggregationMode.SENTENCE). Buffering until sentence boundaries produces more natural speech. Settext_aggregation_mode=TextAggregationMode.TOKENto stream tokens directly for lower latency. Theauto_modeparameter is automatically configured based on the aggregation mode for optimal quality. - Word timestamp accuracy: Word timestamps reflect the original input text by default, preserving non-Latin scripts in transcripts and LLM context. Text normalization (
apply_text_normalization) does not affect which alignment field is used. - Choosing a service: Use
ElevenLabsTTSServicefor the Flash, Turbo v2.5, and Multilingual models — it has a fuller set of voice controls. UseElevenLabsDialogueTTSServicefor Eleven v3 and v4 dialogue models. - Text-to-Dialogue access:
ElevenLabsDialogueTTSServicerequires workspace access to ElevenLabs’ Text-to-Dialogue WebSocket API. - Audio tags: Eleven v3 and v4 perform inline audio tags such as
[laughs]and[excited]. They come back as spoken characters in the alignment, so they reach the LLM context as text unless a text filter removes them. - Set a voice up front: Text-to-Dialogue rejects keepalives that don’t name a registered context. If no
voiceis set when the service connects, the connection idles out after 20 seconds. - Pronunciation dictionaries: The
pronunciation_dictionary_locatorsparameter is deprecated as of v1.6.0. Use thetext_transformsparameter withreplace_textinstead. Pronunciation dictionary substitutions can rewrite the spoken words in ways that no longer match the text sent to synthesis, which breaks the alignment-based word-completion tracking. Client-sidereplace_texttransforms are tracked correctly and maintain word timestamp accuracy. - Pronunciation hints:
ElevenLabsTTSServiceandElevenLabsHttpTTSServicesupport SSML<phoneme>tags on v2 models (eleven_flash_v2,eleven_turbo_v2) only. The WebSocket service requiresenable_ssml_parsing=True; the HTTP service always reads SSML.ElevenLabsDialogueTTSService(v3 models) reads IPA between slashes instead of SSML tags.