Installation
Initialization
Your Deepdub API key. Must start with
dd-.Transport protocol:
"websocket" for real-time streaming, or "http" for REST API.Protocol comparison
Use WebSocket (default) for real-time streaming and low-latency playback. Use HTTP when you need
voiceReference for instant voice cloning or sampleRate with non-mp3 formats.
Connection
For WebSocket protocol, you must callconnect() before generating audio:
Generate to buffer
Generate audio and receive aBuffer of WAV data:
Promise<Buffer> — WAV audio data.
Generate to file
Generate audio and save directly to a file:Promise<void>
Generation parameters
BothgenerateToBuffer and generateToFile accept these options:
Language locale code (e.g.,
en-US, fr-FR, he-IL).Voice prompt ID to use for generation.
Model ID. Available:
dd-etts-3.0, dd-etts-2.5.Optional UUID for tracking. Auto-generated if not provided.
Output format:
mp3, wav, opus, or mulaw.Sample rate in Hz. WebSocket protocol only supports this with
mp3 format. Use HTTP protocol for other formats.Generation temperature (0.0–1.0).
Voice variation level (0.0–1.0).
Playback speed multiplier (0.5–2.0).
Target audio duration in seconds.
Random seed for deterministic output.
Enhance voice prompt characteristics.
Enable super stretch for longer audio.
Enable real-time priority processing.
Base64-encoded audio for instant voice cloning. HTTP protocol only.
Accent blending:
{ accentBaseLocale, accentLocale, accentRatio }.Callback receiving each audio chunk as a
Buffer. WebSocket protocol only.When
true, chunks passed to onChunk have WAV headers stripped (raw PCM). WebSocket protocol only.