Relay Speech — Python SDK
Official Python client for the Relay Speech (OpenTTS) gateway. One API, all TTS providers — Cartesia, ElevenLabs, Sarvam, and more.
pip install relayspeech
Quickstart
from relayspeech import RelaySpeech
client = RelaySpeech(
api_key="rs_live_...", # your Relay Speech key
provider="cartesia", # default provider
provider_api_key="sk-cartesia-..."
)
audio = client.tts.bytes(
text="Hello from Relay Speech.",
voice_id="694f9389-aac1-45b6-b726-9d9369183238",
)
open("hello.pcm", "wb").write(audio)
Environment variables (RELAY_SPEECH_API_KEY, CARTESIA_API_KEY, ELEVENLABS_API_KEY, SARVAM_API_KEY)
are picked up automatically.
REST streaming
with open("out.pcm", "wb") as f:
for chunk in client.tts.stream(text="Streaming demo.", voice_id="..."):
f.write(chunk)
Async
from relayspeech import AsyncRelaySpeech
async with AsyncRelaySpeech(api_key="...", provider="elevenlabs",
provider_api_key="...") as client:
async for chunk in await client.tts.stream(text="Hi", voice_id="..."):
...
WebSocket (low-latency, full duplex)
async with AsyncRelaySpeech(api_key="...", provider="cartesia",
provider_api_key="...") as client:
async with client.tts.websocket() as ws:
async for chunk in await ws.send(
text="One sentence at a time.",
voice_id="...",
enable_cache=True,
):
speaker.write(chunk)
Reuse the same ws for many sentences — the gateway holds the upstream provider
connection open and caches each chunk independently.
Output format
from relayspeech import OutputFormat, AudioContainer, AudioEncoding
audio = client.tts.bytes(
text="…",
voice_id="…",
output_format=OutputFormat(
container=AudioContainer.WAV,
encoding=AudioEncoding.PCM_S16LE,
sample_rate=24000,
),
)
Errors
| Exception | When |
|---|---|
RelaySpeechAuthError |
Invalid / missing Relay Speech key (401) |
RelaySpeechProviderError |
Upstream provider failed (5xx) |
RelaySpeechAPIError |
Any other non-2xx response |
RelaySpeechConnectionError |
Network / WebSocket transport failure |
All inherit from RelaySpeechError.
Metadata
Release files for relayspeech 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| relayspeech-0.1.0.tar.gz | 9.7 kB | Without provenance | Details for relayspeech-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| relayspeech-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for relayspeech-0.1.0-py3-none-any.whl |
Total release size: 22.8 kB
Release files / relayspeech-0.1.0.tar.gz
| Download URL | relayspeech-0.1.0.tar.gz |
|---|---|
| Size | 9.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5c0ad597fb3f8a2f8cb24031a12961aeb67d48628d4fe1a4f2aec0c57f9c818c
|
|
BLAKE2b-256 checksum How to use checksums |
0e82f6bbb1ba369f89f226a517aeb3f2089209230d22cbd0b38fcb8605de770c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.10.11 Darwin/24.6.0
|
Release files / relayspeech-0.1.0-py3-none-any.whl
| Download URL | relayspeech-0.1.0-py3-none-any.whl |
|---|---|
| Size | 13.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
de1ca576a8180a712bc461f9be0a889671b0788f655c67830d71ee6cdf68aee5
|
|
BLAKE2b-256 checksum How to use checksums |
853526842f773d6b102cb7c68a22ff290d3b58d75a61475df719e5b583bf7035
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.10.11 Darwin/24.6.0
|
Security for relayspeech 0.1.0
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.