Prerequisites
All you need is:- Free trial API key:
dd-00000000000000000000000065c9cbfe - A voice preset — see Voice Presets for the full list
Generate speech over WebSocket
WebSocket is the default and the fastest way to generate speech. You open the connection once and reuse it for every request, so each request skips the HTTP and TLS setup. Audio comes back in chunks while it is still being generated, so playback can start before the whole clip is ready. Both examples below use Generate Audio Streamed atwss://wsgw.deepdub.ai/open and save the audio to output.wav.
With the SDK
- Python
- JavaScript
Without the SDK
Any WebSocket client works. Send one JSON request, then decode the base64data of each message until isFinished is true.
- Python
- JavaScript
Advanced generation options
Fine-tune your audio with accent blending and tuned parameters. These go in the same WebSocket request:Other ways to generate
Use these for testing, when you need a single file and latency does not matter, or when WebSocket is not available in your environment.REST with cURL
REST with cURL
One HTTP request per clip. The response body is the audio. REST supports
mp3, opus, and mulaw.Python SDK, one call
Python SDK, one call
client.tts() returns the whole clip as bytes in one call, without a connection to manage.JavaScript SDK, one call
JavaScript SDK, one call
generateToBuffer() waits for the whole clip. It still runs over the WebSocket.Next steps
Generate Audio Streamed
Every WebSocket request field, response message, and error.
Voice Presets
Browse curated voice presets from our library of thousands of voices.
Python SDK Reference
Full Python SDK reference with all methods and async streaming.
JavaScript SDK Reference
Full Node.js SDK reference with streaming chunks and concurrent generation.
API Reference
Text-to-Speech and Speech-to-Text endpoints, parameters, and response formats.
