> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pipecat.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# ElevenLabs Text-to-Speech

> TTS with ElevenLabsTTSService (WebSocket), ElevenLabsHttpTTSService (HTTP), and ElevenLabsDialogueTTSService for Eleven v3 and v4.

## 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 is `eleven_v4_turbo`. These models support inline audio tags. Requires workspace access to the Text-to-Dialogue API.

> [card] [ElevenLabs TTS API Reference](https://reference-server.pipecat.ai/en/latest/api/pipecat.services.elevenlabs.tts.html)
>
> Complete API reference for all parameters and methods

> [card] [Example Implementation](https://github.com/pipecat-ai/pipecat/blob/main/examples/voice/voice-elevenlabs.py)
>
> Complete example with WebSocket streaming

> [card] [ElevenLabs Documentation](https://elevenlabs.io/docs/api-reference/text-to-speech/v-1-text-to-speech-voice-id-multi-stream-input)
>
> Official ElevenLabs TTS API documentation

> [card] [Voice Library](https://elevenlabs.io/voice-library)
>
> Browse and clone voices from the community

> [card] [Text-to-Dialogue Example](https://github.com/pipecat-ai/pipecat/blob/main/examples/voice/voice-elevenlabs-dialogue.py)
>
> Complete example using Eleven v3 and v4 models

> [card] [Text-to-Dialogue Documentation](https://elevenlabs.io/docs/api-reference/text-to-dialogue/ttd-multi-websocket)
>
> Official ElevenLabs Text-to-Dialogue API documentation

## Installation

```bash theme={null}
uv add "pipecat-ai[elevenlabs]"
```

## Prerequisites

1. **ElevenLabs Account**: Sign up at [ElevenLabs](https://elevenlabs.io/app/sign-up)
2. **API Key**: Generate an API key from your account dashboard
3. **Voice Selection**: Choose voice IDs from the [voice library](https://elevenlabs.io/voice-library)

Set the following environment variable:

```bash theme={null}
export ELEVENLABS_API_KEY=your_api_key
```

## Configuration

### ElevenLabsTTSService

**api\_key** `str` *required*

ElevenLabs API key.

**voice\_id** `str` *deprecated* (default: None)

*Deprecated since 0.0.105, removed in 2.0.0.* Use
`settings=ElevenLabsTTSService.Settings(voice=...)` instead.

**model** `str` *deprecated* (default: None)

*Deprecated since 0.0.105, removed in 2.0.0.* Use
`settings=ElevenLabsTTSService.Settings(model=...)` instead.

**url** `str` (default: wss\://api.elevenlabs.io)

WebSocket endpoint URL. Override for custom or proxied deployments.

**sample\_rate** `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.

**auto\_mode** `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.

**enable\_ssml\_parsing** `bool` (default: None)

Whether ElevenLabs parses SSML tags in the text. When `None`, the parameter
isn't sent and the ElevenLabs default applies.

**enable\_logging** `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.

**text\_aggregation\_mode** `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`.

**aggregate\_sentences** `bool` *deprecated* (default: None)

*Deprecated since 0.0.104, removed in 2.0.0.* Use `text_aggregation_mode`
instead.

**params** `InputParams` *deprecated* (default: None)

*Deprecated since 0.0.105, removed in 2.0.0.* Use
`settings=ElevenLabsTTSService.Settings(...)` instead.

**pronunciation\_dictionary\_locators** `List[PronunciationDictionaryLocator]` *deprecated* (default: None)

*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.

**pause\_frame\_processing** `bool` (default: True)

Whether to hold incoming frames after a turn until its audio has played. Set
to `False` to let contexts synthesize concurrently on the one socket, such as
two `TTSSpeakFrame`s pushed at once or back-to-back turns. Audio still plays
in order.

**settings** `ElevenLabsTTSService.Settings` (default: None)

Runtime-configurable settings. See [Settings](#settings) below.

### ElevenLabsHttpTTSService

The HTTP service accepts the same parameters as the WebSocket service except `url`, `auto_mode`, `enable_ssml_parsing`, and `pause_frame_processing`, with these differences:

**aiohttp\_session** `aiohttp.ClientSession` *required*

An aiohttp session for HTTP requests. You must create and manage this
yourself.

**base\_url** `str` (default: [https://api.elevenlabs.io](https://api.elevenlabs.io))

HTTP API base URL (instead of `url` for WebSocket).

**pronunciation\_dictionary\_locators** `List[PronunciationDictionaryLocator]` *deprecated* (default: None)

*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

**api\_key** `str` *required*

ElevenLabs API key.

**url** `str` (default: wss\://api.elevenlabs.io)

WebSocket endpoint URL. Override for custom or proxied deployments.

**sample\_rate** `int` (default: None)

Output audio sample rate in Hz. When `None`, uses the pipeline's configured
sample rate. Accepts the same rates as `ElevenLabsTTSService`.

**enable\_logging** `bool` (default: None)

Whether to enable ElevenLabs server-side logging. Set to `False` for zero
retention mode (enterprise only).

**seed** `int` (default: None)

Seed for reproducible generation.

**text\_aggregation\_mode** `TextAggregationMode` (default: None)

Text-to-Dialogue concatenates consecutive inputs verbatim, so only `SENTENCE`
aggregation is supported. Any other value is ignored with a warning.

**pause\_frame\_processing** `bool` (default: True)

Whether to hold incoming frames after a turn until its audio has played. Set
to `False` to let contexts synthesize concurrently on the one socket, such as
two `TTSSpeakFrame`s pushed at once or back-to-back turns. Audio still plays
in order.

**settings** `ElevenLabsDialogueTTSService.Settings` (default: None)

Runtime-configurable settings. See [Text-to-Dialogue
settings](#text-to-dialogue-settings) below.

### Settings

Runtime-configurable settings passed via the `settings` constructor argument using `ElevenLabsTTSService.Settings(...)`. These can be updated mid-conversation with `TTSUpdateSettingsFrame`. See [Service Settings](https://docs.pipecat.ai/pipecat/fundamentals/service-settings.md) for details.

| Parameter | Type | Default | Description |
| - | - | - | - |
| `model` | `str` | `"eleven_flash_v2_5"` | ElevenLabs model identifier. The WebSocket service logs a warning for Eleven v3 and v4 models, which its endpoint doesn't serve; use `ElevenLabsDialogueTTSService` or the HTTP service for those. *(Inherited from base settings.)* |
| `voice` | `str` | `None` | Voice identifier. *(Inherited from base settings.)* |
| `language` | `Language \| str` | `None` | Language code. Applies only to the models that accept one; see Notes. *(Inherited from base settings.)* |
| `stability` | `float` | `None` | Voice consistency (0.0–1.0). Lower values are more expressive, higher values are more consistent. |
| `similarity_boost` | `float` | `None` | Voice clarity and similarity to the original (0.0–1.0). |
| `style` | `float` | `None` | Style exaggeration (0.0–1.0). Higher values amplify the voice's style. |
| `use_speaker_boost` | `bool` | `None` | Enhance clarity and target speaker similarity. |
| `speed` | `float` | `None` | Speech rate. WebSocket: 0.7–1.2. HTTP: 0.25–4.0. |
| `apply_text_normalization` | `Literal` | `None` | Text normalization: `"auto"`, `"on"`, or `"off"`. On `ElevenLabsTTSService`, changing it at runtime reconnects. |
| `optimize_streaming_latency` | `int` | `None` | HTTP service only. Latency optimization level (0–4). Higher values reduce latency at the cost of quality. |

> [!NOTE]
>
> `None` values aren't sent, so the ElevenLabs API defaults apply. See
> [ElevenLabs voice
> settings](https://elevenlabs.io/docs/api-reference/text-to-speech/v-1-text-to-speech-voice-id-multi-stream-input)
> for details on how these parameters interact.

### Text-to-Dialogue settings

`ElevenLabsDialogueTTSService.Settings(...)` accepts a smaller set. Text-to-Dialogue reads only `stability` and, on v4 models, `clone_strength`; it silently ignores the other voice settings the text-to-speech endpoint accepts.

| Parameter | Type | Default | Description |
| - | - | - | - |
| `model` | `str` | `"eleven_v4_turbo"` | Must be an Eleven v3 or v4 model (`eleven_v3`, `eleven_v3_conversational`, or `eleven_v4_turbo`); anything else logs a warning. |
| `voice` | `str` | `None` | Voice identifier. |
| `language` | `Language \| str` | `None` | Language code. Eleven v4 Turbo covers 84 languages; v3 covers 74, and v2.5 models cover 32. |
| `stability` | `float` | `None` | Voice stability (0.0–1.0). `0.0` is most expressive but can hallucinate, `0.5` stays closest to the reference recording, and `1.0` is most consistent but least responsive to audio tags. |
| `clone_strength` | `float` | `None` | Professional Voice Clone strength (0.0–1.0): how closely the voice follows its clone samples, and whether a v4 Professional Voice Clone runs as a PVC or an IVC. ElevenLabs recommends `0` for most use cases. Sent only to `eleven_v4` models; on other models it is dropped with a warning. |
| `apply_text_normalization` | `Literal` | `None` | Whether ElevenLabs converts numbers, dates, and currencies to words before speaking them: `"on"` always converts, `"off"` skips the conversion, and `"auto"` lets ElevenLabs decide. Left unset, ElevenLabs applies `"auto"`. Changing it at runtime reconnects the service. |

## Usage

### Basic Setup

```python theme={null}
import os

from pipecat.services.elevenlabs.tts import ElevenLabsTTSService

tts = ElevenLabsTTSService(
    api_key=os.getenv("ELEVENLABS_API_KEY"),
    settings=ElevenLabsTTSService.Settings(
        voice="21m00Tcm4TlvDq8ikWAM",  # Rachel
    ),
)
```

### With Voice Customization

```python theme={null}
from pipecat.transcriptions.language import Language

tts = ElevenLabsTTSService(
    api_key=os.getenv("ELEVENLABS_API_KEY"),
    settings=ElevenLabsTTSService.Settings(
        voice="21m00Tcm4TlvDq8ikWAM",
        model="eleven_flash_v2_5",
        language=Language.ES,
        stability=0.7,
        similarity_boost=0.8,
        speed=1.1,
    ),
)
```

### Updating Settings at Runtime

Voice settings can be changed mid-conversation using `TTSUpdateSettingsFrame`:

```python theme={null}
from pipecat.frames.frames import TTSUpdateSettingsFrame
from pipecat.services.elevenlabs.tts import ElevenLabsTTSSettings

await worker.queue_frame(
    TTSUpdateSettingsFrame(
        delta=ElevenLabsTTSSettings(
            stability=0.3,
            speed=1.1,
        )
    )
)
```

### HTTP Service

```python theme={null}
import aiohttp
from pipecat.services.elevenlabs.tts import ElevenLabsHttpTTSService

async with aiohttp.ClientSession() as session:
    tts = ElevenLabsHttpTTSService(
        api_key=os.getenv("ELEVENLABS_API_KEY"),
        settings=ElevenLabsHttpTTSService.Settings(
            voice="21m00Tcm4TlvDq8ikWAM",
        ),
        aiohttp_session=session,
    )
```

### Text-to-Dialogue (Eleven v3 and v4)

```python theme={null}
from pipecat.services.elevenlabs.dialogue.tts import ElevenLabsDialogueTTSService

tts = ElevenLabsDialogueTTSService(
    api_key=os.getenv("ELEVENLABS_API_KEY"),
    settings=ElevenLabsDialogueTTSService.Settings(
        voice=os.getenv("ELEVENLABS_VOICE_ID"),
        model="eleven_v4_turbo",
        stability=0.5,
    ),
)
```

## Notes

* **Models that accept `language`**: Six models take a language code — `eleven_flash_v2_5` and `eleven_turbo_v2_5` cover 32 languages; `eleven_v3` and `eleven_v3_conversational` cover 74; and `eleven_v4` and `eleven_v4_turbo` cover 84 (adding Asturian, Burmese, Cantonese, Māori, Maltese, Mongolian, Occitan, Odia, Tajik, and Uzbek to the v3 set). Any other model, `eleven_multilingual_v2` included, detects the language from the text itself; setting `language` there 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. Set `text_aggregation_mode=TextAggregationMode.TOKEN` to stream tokens directly for lower latency. The `auto_mode` parameter 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 `ElevenLabsTTSService` for the Flash, Turbo v2.5, and Multilingual models — it has a fuller set of voice controls. Use `ElevenLabsDialogueTTSService` for Eleven v3 and v4 dialogue models. `ElevenLabsTTSService` logs a warning at construction when given an Eleven v3 or v4 model, because its WebSocket endpoint doesn't serve them; `ElevenLabsHttpTTSService` also serves them over HTTP.
* **Text-to-Dialogue access**: `ElevenLabsDialogueTTSService` requires 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 `voice` is set when the service connects, the connection idles out after 20 seconds.
* **Pronunciation dictionaries**: The `pronunciation_dictionary_locators` parameter is deprecated as of v1.6.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. Client-side `replace_text` transforms are tracked correctly and maintain word timestamp accuracy.
* **Pronunciation hints**: `ElevenLabsTTSService` and `ElevenLabsHttpTTSService` support SSML `<phoneme>` tags on v2 models (`eleven_flash_v2`, `eleven_turbo_v2`) only. The WebSocket service requires `enable_ssml_parsing=True`; the HTTP service always reads SSML. `ElevenLabsDialogueTTSService` (v3 models) reads IPA between slashes instead of SSML tags.

## Event Handlers

ElevenLabs TTS supports the standard [service connection events](https://docs.pipecat.ai/api-reference/server/events/service-events.md):

| Event | Description |
| - | - |
| `on_connected` | Connected to ElevenLabs WebSocket |
| `on_disconnected` | Disconnected from ElevenLabs WebSocket |
| `on_connection_error` | WebSocket connection error occurred |

```python theme={null}
@tts.event_handler("on_connected")
async def on_connected(service):
    print("Connected to ElevenLabs")
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.