Skip to main content

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 at wss://wsgw.deepdub.ai/open and save the audio to output.wav.

With the SDK

Without the SDK

Any WebSocket client works. Send one JSON request, then decode the base64 data of each message until isFinished is true.
Keep the socket open and send the next request on it. A request on an open connection skips the handshake, which is what makes WebSocket the fastest option. If your text arrives token by token from an LLM, as in a voice agent, use LLM Integration / Voice Agents instead.

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.
One HTTP request per clip. The response body is the audio. REST supports mp3, opus, and mulaw.
client.tts() returns the whole clip as bytes in one call, without a connection to manage.
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.