Skip to main content

Overview

SlngTTSService and SlngHttpTTSService synthesize speech through SLNG, 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.

Source Repository

Source code, examples, and issues for the SLNG integration

PyPI Package

The pipecat-slng package on PyPI

SLNG Website

Learn about the SLNG unified voice AI gateway

SLNG Docs

Documentation for the SLNG platform and APIs

Installation

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

Prerequisites

SLNG Account Setup

Before using the SLNG TTS services, you need:
  1. SLNG Account: Get an API key at 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.
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"
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().
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(...).
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 for the authoritative, up-to-date list.

Usage

Streaming (WebSocket)

Non-streaming (HTTP)

Compatibility

Tested with Pipecat v1.3.0. Check the source repository for the latest tested version and changelog.