> ## Documentation Index
> Fetch the complete documentation index at: https://daily-docs-source-analytics-user-turn-strategies.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# SLNG

> Text-to-speech services for the SLNG unified voice AI gateway (WebSocket + HTTP)

export const CommunityMaintained = ({maintainer, maintainerUrl, repo}) => <Note>
    <strong>Community-maintained integration.</strong> This service is built and
    maintained by{" "}
    <a href={maintainerUrl} target="_blank" rel="noreferrer">
      {maintainer}
    </a>
    . Pipecat does not test or officially support it. Please report issues and
    request changes on the{" "}
    <a href={repo} target="_blank" rel="noreferrer">
      source repository
    </a>
    . Learn more about{" "}
    <a href="/api-reference/server/services/community-integrations">
      community integrations
    </a>
    .
  </Note>;

<CommunityMaintained maintainer="slng-ai" maintainerUrl="https://github.com/slng-ai" repo="https://github.com/slng-ai/pipecat-slng" />

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

<CardGroup cols={2}>
  <Card title="Source Repository" icon="github" href="https://github.com/slng-ai/pipecat-slng">
    Source code, examples, and issues for the SLNG integration
  </Card>

  <Card title="PyPI Package" icon="cube" href="https://pypi.org/project/pipecat-slng/">
    The `pipecat-slng` package on PyPI
  </Card>

  <Card title="SLNG Website" icon="globe" href="https://slng.ai">
    Learn about the SLNG unified voice AI gateway
  </Card>

  <Card title="SLNG Docs" icon="book" href="https://docs.slng.ai/">
    Documentation for the SLNG platform and APIs
  </Card>
</CardGroup>

## Installation

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

```bash theme={null}
uv add pipecat-slng
# or
pip install 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)

<ParamField path="api_key" type="str" required>
  Authentication key for the SLNG API.
</ParamField>

<ParamField path="model" type="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.
</ParamField>

<ParamField path="voice" type="str" default="None">
  Voice identifier for synthesis (e.g. `aura-2-thalia-en`).
</ParamField>

<ParamField path="base_url" type="str" default="api.slng.ai">
  The API host.
</ParamField>

<ParamField path="encoding" type="str" default="linear16">
  Audio encoding format. One of `"linear16"`, `"mp3"`, `"opus"`, `"mulaw"`, or
  `"alaw"`.
</ParamField>

<ParamField path="sample_rate" type="int" default="None">
  Audio sample rate in Hz. If `None`, uses the pipeline sample rate.
</ParamField>

<ParamField path="region_override" type="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`.
</ParamField>

<ParamField path="world_part_override" type="str" default="None">
  Constrain routing to a broad geographic zone. One of `"ap"`, `"eu"`, `"na"`.
  Sent as the `X-World-Part-Override` header.
</ParamField>

<ParamField path="provider_key" type="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).
</ParamField>

<ParamField path="language" type="Language" default="Language.EN">
  Synthesis language. Defaults to `Language.EN` when not given.
</ParamField>

<ParamField path="speed" type="float" default="None">
  Speech speed multiplier. `None` keeps the server default.
</ParamField>

<ParamField path="settings" type="SlngTTSService.Settings" default="None">
  Runtime-updatable settings override. Merged on top of any explicit kwargs.
</ParamField>

### `SlngHttpTTSService` (HTTP)

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

<ParamField path="base_url" type="str" default="https://api.slng.ai">
  Full base URL (including scheme) of the SLNG API.
</ParamField>

<ParamField path="aiohttp_session" type="aiohttp.ClientSession" default="None">
  Optional aiohttp session. If `None`, one is created in `start()` and closed in
  `stop()`/`cancel()`.
</ParamField>

<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.
</Note>

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

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