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

# SLNG Text-to-Speech

> SlngTTSService and SlngHttpTTSService synthesize TTS through SLNG, a unified voice AI gateway routing multiple providers.

> [!NOTE]
>
> **Community-maintained integration.** This service is built and
> maintained by
> [slng-ai](https://github.com/slng-ai)
> . Pipecat does not test or officially support it. Please report issues and
> request changes on the
> [source repository](https://github.com/slng-ai/pipecat-slng)
> . Learn more about
> [community integrations](https://docs.pipecat.ai/api-reference/server/services/community-integrations.md)
> .

## Overview

`SlngTTSService` and `SlngHttpTTSService` synthesize speech through
[SLNG](https://slng.ai), a unified voice AI gateway that routes to multiple
TTS providers (Deepgram, ElevenLabs, Rime, Sarvam, and more) through a single
API key. Swapping the `model` string switches providers with no other code
changes. Use the WebSocket `SlngTTSService` for low-latency, interruptible
streaming synthesis, or the HTTP `SlngHttpTTSService` for simple,
non-streaming request/response synthesis.

> [card] [Source Repository](https://github.com/slng-ai/pipecat-slng)
>
> Source code, examples, and issues for the SLNG integration

> [card] [PyPI Package](https://pypi.org/project/pipecat-slng/)
>
> The `pipecat-slng` package on PyPI

> [card] [SLNG Website](https://slng.ai)
>
> Learn about the SLNG unified voice AI gateway

> [card] [SLNG Docs](https://docs.slng.ai/)
>
> Documentation for the SLNG platform and APIs

## Installation

This is a community-maintained package distributed separately from `pipecat-ai`:

```bash theme={null}
uv add pipecat-slng
```

## Prerequisites

### SLNG Account Setup

Before using the SLNG TTS services, you need:

1. **SLNG Account**: Get an API key at [slng.ai](https://slng.ai)
2. **API Key**: Used to authenticate all requests to SLNG

### Required Environment Variables

* `SLNG_API_KEY`: Your SLNG API key for authentication

## Configuration

Both services share the same `Settings` dataclass (`SlngTTSSettings`) and most
constructor parameters. The key difference is transport: `SlngTTSService`
connects over WebSocket and exposes the full config surface, while
`SlngHttpTTSService` issues one HTTP POST per utterance.

### `SlngTTSService` (WebSocket)

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

Authentication key for the SLNG API.

**model** `str` (default: slng/deepgram/aura:2-en)

The TTS model to use. Use a `slng/...` prefix for SLNG-hosted routes, or an
external provider route (e.g. `deepgram/aura:2`) proxied through SLNG.

**voice** `str` (default: None)

Voice identifier for synthesis (e.g. `aura-2-thalia-en`).

**base\_url** `str` (default: api.slng.ai)

The API host.

**encoding** `str` (default: linear16)

Audio encoding format. One of `"linear16"`, `"mp3"`, `"opus"`, `"mulaw"`, or
`"alaw"`.

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

Audio sample rate in Hz. If `None`, uses the pipeline sample rate.

**region\_override** `str` (default: None)

Pin requests to a specific datacenter. One of `"ap-southeast-2"`,
`"eu-north-1"`, `"us-east-1"`. Sent as the `X-Region-Override` header and
takes precedence over `world_part_override`.

**world\_part\_override** `str` (default: None)

Constrain routing to a broad geographic zone. One of `"ap"`, `"eu"`, `"na"`.
Sent as the `X-World-Part-Override` header.

**provider\_key** `str` (default: None)

Your own upstream provider API key (BYOK). Sent as the `X-Slng-Provider-Key`
header so the provider bills your account directly. Only supported on external
catalog routes (no `slng/` prefix). See the [BYOK
docs](https://docs.slng.ai/execution-layer/byok).

**language** `Language` (default: Language.EN)

Synthesis language. Defaults to `Language.EN` when not given.

**speed** `float` (default: None)

Speech speed multiplier. `None` keeps the server default.

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

Runtime-updatable settings override. Merged on top of any explicit kwargs.

### `SlngHttpTTSService` (HTTP)

`SlngHttpTTSService` accepts the same parameters as `SlngTTSService` with these
differences:

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

Full base URL (including scheme) of the SLNG API.

**aiohttp\_session** `aiohttp.ClientSession` (default: None)

Optional aiohttp session. If `None`, one is created in `start()` and closed in
`stop()`/`cancel()`.

> [!NOTE]
>
> The HTTP bridge request body accepts only `{text, voice}` — there is no
> `config` object — so `encoding`, `sample_rate`, `language`, and `speed` are
> not configurable over HTTP. `region_override`/`world_part_override` are sent
> as the `region`/`world-part` query parameters. WAV responses are decoded to
> raw PCM; compressed responses (MP3/Ogg) yield an `ErrorFrame`. Use the
> streaming `SlngTTSService` if you need codec control.

### Settings

Runtime-configurable settings passed via the `settings` constructor argument
using `SlngTTSSettings(...)`.

| Parameter | Type | Default | Description |
| - | - | - | - |
| `voice` | `str` | `None` | Voice identifier for speech synthesis. |
| `language` | `Language` | `Language.EN` | Language for speech synthesis. |
| `speed` | `float` | `None` | Speech speed multiplier. `None` uses the server default. |

> [!NOTE]
>
> Changing `voice`, `speed`, or `language` mid-session on the WebSocket service
> reconnects to re-run the init handshake — expect a brief reconnect. See the
> [source repository](https://github.com/slng-ai/pipecat-slng) for the
> authoritative, up-to-date list.

## Usage

### Streaming (WebSocket)

```python theme={null}
import os
from pipecat_slng import SlngTTSService

tts = SlngTTSService(
    api_key=os.getenv("SLNG_API_KEY"),
    model="slng/deepgram/aura:2-en",
    voice="aura-2-thalia-en",
)

# ... add tts to your pipeline
```

### Non-streaming (HTTP)

```python theme={null}
import os
from pipecat_slng import SlngHttpTTSService

tts = SlngHttpTTSService(
    api_key=os.getenv("SLNG_API_KEY"),
    model="slng/deepgram/aura:2-en",
    voice="aura-2-thalia-en",
)

# ... add tts to your pipeline
```

## Compatibility

Tested with Pipecat v1.3.0. Check the [source
repository](https://github.com/slng-ai/pipecat-slng) for the latest tested
version and changelog.


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