Skip to main content

pipecat-sonex

SonexLabs TTS for pipecat-ai real-time voice pipelines.

PyPI Python License: MIT

Tested with Pipecat v1.7.0.

Maintained by SonexLabs — contact: support@sonexlabs.com


pipecat-sonex provides SonexTTSService — a pipecat-native TTS service that connects any pipecat pipeline to the SonexLabs Panini TTS API.

SonexTTSService extends pipecat's official TTSService base class, so it works exactly like CartesiaTTSService, ElevenLabsTTSService, and other first-party services:

  • The base class handles sentence aggregation, LLM token buffering, interruption recovery, TTSStartedFrame / TTSStoppedFrame, and metrics.
  • You only need to configure credentials and voice.
  • Voice and language can be changed mid-conversation via TTSUpdateSettingsFrame.

Streaming and connection reuse

Requests go to SonexLabs' /v1/speech/stream endpoint, so audio is delivered as chunked HTTP as soon as each sentence is generated instead of waiting for the full utterance, reducing time-to-first-audio. The underlying aiohttp.ClientSession uses a TCPConnector with keepalive_timeout set, so connections are pooled and reused across requests rather than reconnecting for every sentence.


Installation

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

Quick start

1. List available voices

curl https://api.sonexlabs.com/v1/voices \
  -H "Authorization: Bearer $SONEX_API_KEY"

Copy a voice_id from the response — it is required.

2. Add to your pipeline

from pipecat_sonex import SonexTTSService

tts = SonexTTSService(
    api_key="vsk_...",
    voice="9b8fsavyez",     # Diya (English), from GET /v1/voices — required, no default
)

Language is optional — leave it unset and Panini auto-detects from the input text. For telephony (Twilio/Exotel/Vobiz), pass sample_rate=8000 — see Constructor parameters.

Drop it into any pipeline the same way as any other pipecat TTS service:

pipeline = Pipeline([
    transport.input(),
    stt,
    context_aggregator.user(),
    llm,
    tts,                    # ← SonexTTSService here
    transport.output(),
    context_aggregator.assistant(),
])

Constructor parameters

Parameter Type Default Description
api_key str — SonexLabs API key (vsk_...)
voice str — Required. Voice ID from GET /v1/voices
language str "" Optional. Leave unset to auto-detect.
speed float 1.0 Speech rate multiplier (practical range: 0.75–1.5)
sample_rate int 24000 Pipeline output rate in Hz. Not sent to the API — Panini always returns audio at its native rate; pipecat resamples to this value. Use 8000 for Twilio/Exotel telephony.
endpoint str https://api.sonexlabs.com API base URL
settings SonexTTSSettings None Runtime-updatable settings (takes precedence)

Runtime settings update

Change voice or language mid-conversation:

from pipecat.frames.frames import TTSUpdateSettingsFrame
from pipecat_sonex import SonexTTSSettings

await task.queue_frames([
    TTSUpdateSettingsFrame(delta=SonexTTSSettings(voice="lkwlapu6ab"))  # Priya, from GET /v1/voices
])

Examples

All examples are in the examples/ directory. Copy .env.example to .env and fill in your credentials before running.

Minimal (foundational example)

The smallest possible pipeline — just speaks one line and exits:

pip install "pipecat-ai[webrtc]" pipecat-sonex python-dotenv fastapi uvicorn
python examples/01_say_one_thing.py
# Open http://localhost:7860/client/ and click Connect

WebRTC + OpenAI LLM

Full browser-to-server voice bot using SmallWebRTC transport:

pip install "pipecat-ai[openai,deepgram,silero,webrtc]" pipecat-sonex python-dotenv fastapi uvicorn
python examples/webrtc_openai.py
# Open http://localhost:7860 and click Connect

Twilio telephony

pip install "pipecat-ai[openai,deepgram,silero,twilio]" pipecat-sonex python-dotenv fastapi uvicorn
python examples/telephony_twilio.py
# Expose with ngrok, point Twilio webhook to https://<host>/incoming-call

Exotel telephony

pip install "pipecat-ai[openai,deepgram,silero]" pipecat-sonex python-dotenv fastapi uvicorn
python examples/telephony_exotel.py
# Expose with ngrok, set Exotel Passthru URL to wss://<host>/ws/exotel

Vobiz telephony

VobizFrameSerializer is bundled in pipecat_sonex.vobiz — no extra package needed:

pip install "pipecat-ai[openai,deepgram,silero]" pipecat-sonex python-dotenv fastapi uvicorn
python examples/telephony_vobiz.py
# Set Vobiz WebSocket URL to wss://<host>/ws/vobiz

LiveKit

For a LiveKit room-based voice bot example, see the separate pipecat-sonex-livekit repo.


API reference

See the full API documentation at docs.sonexlabs.com/api-reference.


License

MIT — see LICENSE.

Metadata

Release files for pipecat-sonex 0.2.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pipecat-sonex 0.2.7
File Size Uploaded Provenance
pipecat_sonex-0.2.7.tar.gz 16.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pipecat-sonex 0.2.7
File Interpreter ABI Platform
pipecat_sonex-0.2.7-py3-none-any.whl Python 3 none any Details

Total release size: 27.9 kB

Release files / pipecat_sonex-0.2.7.tar.gz

Download URL pipecat_sonex-0.2.7.tar.gz
Size 16.4 kB
Tags Source
SHA-256 checksum
How to use checksums
a21c34627f4d1fd43780faab3de012ade51d7e888a92c3c1d5f96de87c0336f6
BLAKE2b-256 checksum
How to use checksums
a8aa205121e96f7fec470151d3d8b715ebe02b5d95a22953a3ddb4a4740f208b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.12

Release files / pipecat_sonex-0.2.7-py3-none-any.whl

Download URL pipecat_sonex-0.2.7-py3-none-any.whl
Size 11.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
153f9f25a910c031c05e644548b90dc6e9c95b922596895ad47ba809a732b4e3
BLAKE2b-256 checksum
How to use checksums
2d8bb4c81e8eb01310dabce81318fbe55de99a1740dcb65c8dc1f141b69e42db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.12

Security for pipecat-sonex 0.2.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page