Installation
Initialization
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:
Sample rate in Hz. WebSocket protocol only supports this with
mp3 format. Use HTTP protocol for other formats.When
true, chunks passed to onChunk have WAV headers stripped (raw PCM). WebSocket protocol only.