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 PyPISLNG 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 frompipecat-ai:
Prerequisites
SLNG Account Setup
Before using the SLNG TTS services, you need:- SLNG Account: Get an API key at slng.ai
- 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 sameSettings 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)
Authentication key for the SLNG API.
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 identifier for synthesis (e.g.
aura-2-thalia-en).The API host.
Audio encoding format. One of
"linear16", "mp3", "opus", "mulaw", or
"alaw".Audio sample rate in Hz. If
None, uses the pipeline sample rate.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.Constrain routing to a broad geographic zone. One of
"ap", "eu", "na".
Sent as the X-World-Part-Override header.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.Synthesis language. Defaults to
Language.EN when not given.Speech speed multiplier.
None keeps the server default.Runtime-updatable settings override. Merged on top of any explicit kwargs.
SlngHttpTTSService (HTTP)
SlngHttpTTSService accepts the same parameters as SlngTTSService with these
differences:
Full base URL (including scheme) of the SLNG API.
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 thesettings 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. |
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.