Nebul Docs

Text to Speech

Convert text to natural-sounding speech across 23 languages, with voice cloning and fine-grained delivery control

Preview

Text to speech is in preview: the API surface and behavior may change before general availability.

The Text to Speech endpoint (POST /v1/audio/speech) turns text into spoken audio. ResembleAI/chatterbox-multilingual, a 500M-parameter model, serves it: 23 languages, voice cloning from a reference clip, and fine-grained control over expressiveness and pacing. The response is raw audio bytes, WAV by default, MP3 on request.

Every example reads your key from NEBUL_API_KEY; export it first. The Quick Start covers key setup.

Request

POST https://api.inference.nebul.io/v1/audio/speech

ParameterTypeRequiredDescription
modelStringYesThe model ID, ResembleAI/chatterbox-multilingual.
inputStringYesThe text to speak.
languageStringNoISO 639-1 code, e.g. en, nl, zh. Defaults to en.
response_formatStringNowav (default) or mp3.
exaggerationNumberNoEmotional intensity, 0.25 to 2.0. Defaults to 0.5.
cfg_weightNumberNoPacing, 0.0 to 1.0. Defaults to 0.5. Lower is faster.
temperatureNumberNoRandomness, 0.05 to 5.0. Defaults to 0.8.
seedIntegerNoRandom seed for generation.
audio_promptObjectNoReference audio for voice cloning: {"data": "<base64 wav>", "mime_type": "audio/wav"}. See Voice Cloning.

Example

Speak one sentence:

import os

import requests

response = requests.post(
    "https://api.inference.nebul.io/v1/audio/speech",
    headers={
        "Authorization": f"Bearer {os.environ['NEBUL_API_KEY']}",
        "Content-Type": "application/json",
    },
    json={
        "model": "ResembleAI/chatterbox-multilingual",
        "input": "Hello, this is a test of the text to speech service.",
        "language": "en",
        "response_format": "wav",
    },
)

with open("output.wav", "wb") as f:
    f.write(response.content)

The call returns in about a second with Content-Type: audio/wav. The default output is 24 kHz, 16-bit, mono PCM; output.wav plays in any audio player.

Output formats

response_format: "mp3" returns 64 kbps mono MP3 with Content-Type: audio/mpeg, roughly a quarter the size of the WAV. Use WAV for processing pipelines that want raw PCM; use MP3 when the audio ships to browsers or apps.

Delivery control

Three parameters shape how the voice delivers the text:

  • exaggeration sets emotional intensity. 0.3-0.4 reads neutral and professional; 0.7-0.8 tells a story; above 1.0 is theatrical.
  • cfg_weight sets pacing. 0.2-0.3 speaks fast and casual; 0.7-0.8 is slow and deliberate.
  • temperature sets variability. Lower values keep the voice consistent across generations; higher values vary it.

For expressive content, raise exaggeration and lower cfg_weight together so the delivery stays natural:

response = requests.post(
    "https://api.inference.nebul.io/v1/audio/speech",
    headers={"Authorization": f"Bearer {os.environ['NEBUL_API_KEY']}"},
    json={
        "model": "ResembleAI/chatterbox-multilingual",
        "input": "This is a dramatic and expressive speech!",
        "language": "en",
        "response_format": "wav",
        "exaggeration": 1.2,
        "cfg_weight": 0.3,
        "temperature": 0.9,
    },
)

with open("dramatic.wav", "wb") as f:
    f.write(response.content)

For narration and business content, go the other way: exaggeration 0.3 with cfg_weight 0.7.

Languages

Pass the language of your text; the model handles 23:

CodeLanguageCodeLanguageCodeLanguage
arArabicheHebrewplPolish
daDanishhiHindiptPortuguese
deGermanitItalianruRussian
elGreekjaJapanesesvSwedish
enEnglishkoKoreanswSwahili
esSpanishmsMalaytrTurkish
fiFinnishnlDutchzhChinese
frFrenchnoNorwegian
json={
    "model": "ResembleAI/chatterbox-multilingual",
    "input": "Hallo, hoe gaat het? Dit is een test van de spraakdienst.",
    "language": "nl",
    "response_format": "wav",
}

Match language to the text: the same Dutch sentence with language: "en" comes out with an English accent.

Voice cloning

Provide a reference clip and the output copies its voice:

import base64

with open("reference.wav", "rb") as f:
    audio_b64 = base64.b64encode(f.read()).decode()

response = requests.post(
    "https://api.inference.nebul.io/v1/audio/speech",
    headers={"Authorization": f"Bearer {os.environ['NEBUL_API_KEY']}"},
    json={
        "model": "ResembleAI/chatterbox-multilingual",
        "input": "This sentence is spoken in a cloned voice.",
        "language": "en",
        "response_format": "wav",
        "audio_prompt": {
            "data": audio_b64,
            "mime_type": "audio/wav",
        },
    },
)

Ten to twenty seconds of clean, single-speaker audio makes the best reference. WAV, MP3, M4A, and FLAC all work as the reference clip. Requirements, limitations, and privacy notes live on the Voice Cloning page.

Model

Examples on this page use ResembleAI/chatterbox-multilingual, the default text-to-speech model. The Model Catalog lists any other speech models with their specs. For transcribing speech instead of generating it, see Speech to Text.

On this page