How to choose audio formats
Input formats
The ref_audio file accepts the following codecs:
For best cloning quality, use WAV or FLAC. Telephony codecs (MULAW, ALAW) work but cap the achievable fidelity at the source.
Output formats
Specify the output codec via output_audio_codec. The default is wav.
OPUS restricts the sample rate. When output_audio_codec is opus and speech_sample_rate is explicitly set, it must be one of 8000, 16000, 24000, or 48000 Hz. Other rates fail with 400 Bad Request. When speech_sample_rate is omitted, opus output is returned at the native 24000 Hz.
Sample rate
Use speech_sample_rate to set the output sample rate in Hz:
8000, 16000, 22050, 24000, 32000, 44100, 48000
If omitted, the API returns audio at the model’s native rate (24,000 Hz). Set the sample rate to match your downstream pipeline:
Sample rates above 24000 Hz (32000, 44100, 48000) are supported for broadcast-quality output, matching the Bulbul v3 REST API.
File size guidance
Higher sample rates and uncompressed codecs produce larger output files. As a rough guide for a 10-second clip:
For high-volume API usage, choose a compressed codec (mp3, opus, aac) unless your downstream pipeline specifically requires uncompressed audio.
Decoding the response
The audio field is a base64-encoded string of the raw bytes for the codec you requested. Decode it and write it to a file with the appropriate extension:
The API is multipart/form-data. From Node 18+, FormData and Blob are available globally, so no extra library is needed to build the request body.