Skip to main content

SLNG STT/TTS services for Pipecat (WebSocket + HTTP)

Project description

pipecat-slng

CI

Built and maintained by the SLNG team (slng.ai).

WebSocket STT and TTS services for Pipecat, backed by SLNG — a unified voice AI gateway that routes to multiple STT/TTS providers (Deepgram, ElevenLabs, Rime, Sarvam, and more) through a single API key. Swap the model string to switch providers; no other code changes needed.

Tested with Pipecat v1.3.0.

Installation

uv add pipecat-slng
# or
pip install pipecat-slng

Environment variables

SLNG_API_KEY=your_slng_api_key      # get one at https://slng.ai
OPENAI_API_KEY=your_openai_api_key  # only needed for the example bot (LLM)

Copy .env.example to .env to get started.

Usage (streaming WebSocket — recommended)

SlngSTTService and SlngTTSService run over WebSocket: low-latency, supports mid-utterance interruption, and exposes the full SLNG config surface (encoding, sample_rate, language, speed).

import os

from pipecat_slng import SlngSTTService, SlngTTSService

stt = SlngSTTService(
    api_key=os.getenv("SLNG_API_KEY"),
    model="slng/deepgram/nova:3-en",
)

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

Common runtime knobs are top-level kwargs (e.g. language=, speed=, enable_vad=, enable_partials=). For richer overrides pass a SlngSTTSettings(...) / SlngTTSSettings(...) to settings=.

Defaults when not specified: STT uses language=Language.EN, enable_vad=True, enable_partials=True; TTS uses language=Language.EN and the server's default speed.

Two behaviors worth knowing:

  • Confidence filter (STT). When the provider surfaces a confidence score, transcripts below 0.5 are dropped.
  • Runtime settings updates. Changing voice, speed, or language mid-session (via Pipecat settings updates) reconnects the WebSocket to re-run the init handshake — expect a brief reconnect, not a silent no-op.

HTTP TTS (non-streaming fallback)

For simple request/response synthesis where streaming is not required, use SlngHttpTTSService. It issues one HTTP POST per utterance and returns the full audio body in one frame.

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",
)

HTTP contract limits. Per the SLNG Unified TTS HTTP OpenAPI, the request body accepts only {text, voice} — there is no config object. Encoding, sample_rate, language, and speed are therefore not configurable over HTTP; the server returns its default audio format. The service auto-detects WAV (decoded to raw PCM at the file's sample rate) and plain PCM (passed through at the pipeline's sample rate). Compressed responses (MP3/Ogg) yield an ErrorFrame — use the streaming SlngTTSService if you need codec control.

An aiohttp.ClientSession is created internally if you don't pass one; supply aiohttp_session=... to reuse a shared session.

Region routing

Both services support gateway region routing via region_override (pin to a datacenter: ap-southeast-2 | eu-north-1 | us-east-1) and world_part_override (broad zone: ap | eu | na). When both are set, region_override wins. WebSocket services send these as the X-Region-Override / X-World-Part-Override headers; the HTTP service uses the region / world-part query parameters (per the bridge contract).

stt = SlngSTTService(
    api_key=os.getenv("SLNG_API_KEY"),
    model="slng/deepgram/nova:3-en",
    region_override="eu-north-1",
)

Example

A complete cascade bot (STT → LLM → TTS, WebSocket TTS by default) lives in examples/bot.py:

cp .env.example .env   # fill in SLNG_API_KEY and OPENAI_API_KEY
uv run --extra example examples/bot.py

Then open http://localhost:7860/client in your browser and start talking. The bot uses the SmallWebRTC transport by default; pass -t daily to use Daily instead (requires installing pipecat-ai[daily]).

Development

uv sync --all-extras
uv run pytest          # unit tests (live smoke tests skip without SLNG_API_KEY)
uv run ruff check .
uv run ty check .

About SLNG

SLNG (https://slng.ai) is a unified voice AI gateway. Learn more in the SLNG docs.

License

BSD-2-Clause — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pipecat_slng-0.3.0.tar.gz (226.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pipecat_slng-0.3.0-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file pipecat_slng-0.3.0.tar.gz.

File metadata

  • Download URL: pipecat_slng-0.3.0.tar.gz
  • Upload date:
  • Size: 226.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pipecat_slng-0.3.0.tar.gz
Algorithm Hash digest
SHA256 ed5df1462444994f27ed528eec3dc906ab8ca6a3c61c83a8a8189991eadff4ec
MD5 719bf667a0c13bd054728b8b4207d227
BLAKE2b-256 de3eec325171aea2de4c1039ac422ab7179e94334d609c023e3d81f36af6dc17

See more details on using hashes here.

File details

Details for the file pipecat_slng-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: pipecat_slng-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 17.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pipecat_slng-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 62570bf7248d52ca4c4a096172ee79f2c14a011dd98a578e7f53d37bb499e185
MD5 37e0748e34037d1ecb5158e013b3f643
BLAKE2b-256 4d2ee68c00eb1e517aef0f4dd89aad448fef0235fe0f924fce109d21ddd05bfb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page