Installation
Initialization
string
required
Your Deepdub API key. Must start with
dd-.string
default:"websocket"
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:
string
required
Language locale code (e.g.,
en-US, fr-FR, he-IL).string
required
Voice prompt ID to use for generation.
string
default:"dd-etts-3.0"
Model ID. Available:
dd-etts-3.0, dd-etts-2.5.string
Optional UUID for tracking. Auto-generated if not provided.
string
Output format:
mp3, wav, opus, or mulaw.number
Sample rate in Hz. WebSocket protocol only supports this with
mp3 format. Use HTTP protocol for other formats.number
Generation temperature (0.0–1.0).
number
Voice variation level (0.0–1.0).
number
Playback speed multiplier (0.5–2.0).
number
Target audio duration in seconds.
number
Random seed for deterministic output.
boolean
Enhance voice prompt characteristics.
boolean
Enable super stretch for longer audio.
boolean
Enable real-time priority processing.
string
Base64-encoded audio for instant voice cloning. HTTP protocol only.
object
Accent blending:
{ accentBaseLocale, accentLocale, accentRatio }.function
Callback receiving each audio chunk as a
Buffer. WebSocket protocol only.boolean
default:"false"
When
true, chunks passed to onChunk have WAV headers stripped (raw PCM). WebSocket protocol only.