Installation
requests, websockets, click, audiosample
Initialization
Constructor parameters
Base URL for the REST API. Falls back to
DEEPDUB_BASE_URL environment variable.Base URL for the WebSocket API. Falls back to
DEEPDUB_BASE_WEBSOCKET_URL environment variable.Base URL for the WebSocket streaming API. Falls back to
DEEPDUB_BASE_WEBSOCKET_STREAMING_URL environment variable.Use EU region endpoints (
restapi.eu.deepdub.ai, wsapi.eu.deepdub.ai). Falls back to DD_EU environment variable ("1" to enable).Region endpoints
Text-to-Speech
tts() — Synchronous generation
Generate speech and receive the complete audio as bytes.
bytes — binary audio data in the specified format.
Parameters
Audio reference for instant voice cloning. Accepts a file
Path, raw bytes, or a base64-encoded string. Either this or voice_prompt_id must be provided.Model ID. Defaults to
dd-etts-4.0 — see Available Models.Audio output format. REST API supports:
mp3, opus, mulaw. WebSocket additionally supports: wav (default), s16le.Output sample rate in Hz. Supported:
8000, 16000, 22050, 24000, 44100, 48000. The REST and WebSocket APIs additionally accept 32000 and 36000, which the Python SDK rejects — call those APIs directly if you need them.Base accent locale (e.g.,
en-US). Must be provided together with accent_locale and accent_ratio.Target accent locale (e.g.,
fr-FR). Must be provided together with accent_base_locale and accent_ratio.Accent blend ratio (0.0–1.0). Must be provided together with
accent_base_locale and accent_locale.Full example with all parameters
Voice cloning from audio reference
Async / WebSocket TTS
async_tts() — Streaming generation
Stream audio chunks over WebSocket for low-latency playback. Must be used within an async_connect() context.
bytes — audio chunks as they are generated.
Parameters
Same astts(), plus:
Multiple concurrent generations
The WebSocket connection supports multiplexing — run multiple TTS requests on the same connection:Streaming Input
For real-time text streaming (sending text incrementally), useasync_stream_connect():
Gender Classification
Classify the gender of a speaker from an audio sample:Audio data as raw bytes, base64-encoded string, or file Path. Automatically trimmed to 1 second.
Voice Management
list_voices() — List all voice prompts
dict with a voicePrompts key containing a list of voice prompt objects.
add_voice() — Upload a voice sample
dict with the created voice prompt information.
Parameters
CLI Reference
The SDK includes a command-line interface:Environment Variables
Error Handling
Exception with the error message from the server:
