Skip to main content
Your dedicated Gradium Text-to-Speech deployment runs on Baseten and speaks the same streaming WebSocket protocol as the hosted Gradium API. Only the connection details change: the URL and the authentication header.
This page documents a private deployment and is not listed in the site navigation. Keep the link handy.

Differences from the hosted API

Prerequisites

  • The WebSocket URL of your deployment (provided by Baseten / Gradium), of the form wss-host.example.com/websocket.
  • A Baseten API key with access to the deployment.
  • Python 3.10+ with the Gradium SDK, version 0.6.1 or later (pip install "gradium>=0.6.1"). Earlier versions cannot override the TTS route and will not reach a self-hosted deployment.

Quickstart

The SDK repository ships a ready-made client for self-hosted deployments: examples/self_hosted/example_tts.py. It connects to the deployment, synthesizes the given text, and writes the audio to a file:
--api-key takes your Baseten API key — the example client sends it in Baseten’s Authorization: Api-Key ... header, not in the hosted API’s x-api-key header.

Minimal client

The example boils down to two adjustments to the standard GradiumClient, both worth copying into your own code:
  1. tts_route="" — on the hosted API the client appends speech/tts to the base URL; on Baseten the TTS WebSocket is served at the deployment URL directly.
  2. Auth header override — Baseten authenticates with Authorization: Api-Key <key>.
All three SDK shapes work against the deployment exactly as described in the Text-to-Speech guide: tts_realtime for concurrent send/receive, tts_stream for an async iterator of audio chunks, and tts for buffered one-shot synthesis.

Setup parameters

  • voice_id: The id of the voice to use, from Available voices below. Omit it to use the deployment’s default voice.
  • output_format: "wav" or "pcm". PCM output is 48kHz, 16-bit signed integer, mono.
  • json_config: Advanced voice settings such as temperature and speed. See Voice Settings.
  • rewrites: Inline text rewrite rules, as a list of [original, rewrite, case_sensitive] entries. See Text Rewriting.

Direct WebSocket

From a non-Python runtime, talk to the WebSocket directly. The message flow is the same as the TTS WebSocket reference: send setup, wait for ready, send text and end_of_stream, receive audio / text messages until end_of_stream.
The only difference from the hosted reference: pronunciation_id is not available — use inline rewrites instead.

Troubleshooting

Available voices

The deployment image ships with 346 voices plus a built-in default voice (used when voice_id is omitted). All 66 flagship voices are included — the tables below list them per language; the full id list follows. Pass the id as the voice_id setup field — click an id to copy it. You can also listen to and test the voices in the official Gradium Studio.
Every id below is baked into the deployment image and usable as the voice_id setup field, including the flagship voices listed above.