Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.camb.ai/llms.txt

Use this file to discover all available pages before exploring further.

Overview

Generate natural-sounding speech from text using the CAMB.AI SDK. This tutorial covers installation, generating your first audio, choosing a model, and listing voices.

Listen to an Example

Prerequisites

1

Create an account

Sign up at CAMB.AI Studio if you haven’t already.
2

Get your API key

Go to Settings → API Keys in Studio and copy your key. See Authentication for details.
3

Install the SDK

pip install camb-sdk
Skip this step if you’re using the direct API.
4

Set your API key to use in your code

export CAMB_API_KEY="your_api_key_here"

Code

import os
from camb.client import CambAI, save_stream_to_file
from camb.types import StreamTtsOutputConfiguration

client = CambAI(api_key=os.getenv("CAMB_API_KEY"))

# Generate speech and save to file
response = client.text_to_speech.tts(
    text="[laughter] You really got me. I didn't see that coming at all.",
    voice_id=147320,
    language="en-us",
    speech_model="mars-8.1-flash-beta",
    output_configuration=StreamTtsOutputConfiguration(format="wav")
)

save_stream_to_file(response, "output.wav")
print("Audio saved to output.wav")

Listing Voices

List available voices to find the right one for your use case:
voices = client.voice_cloning.list_voices()

for voice in voices[:10]:
    print(f"ID: {voice['id']}, Name: {voice['voice_name']}, Gender: {voice['gender']}")

Parameters

Required

ParameterTypeDescription
textstringText to convert to speech (min 3 characters)
voice_idintegerVoice ID to use (e.g., 147320)

Optional

ParameterTypeDefaultDescription
languagestring"en-us"BCP-47 language code
speech_modelstring"mars-flash"mars-8.1-flash-beta, mars-8.1-pro-beta, mars-flash, mars-pro, or mars-instruct
output_configurationobject{}Output format: wav, mp3, or pcm_s16le

mars-instruct supports embedded emotion tags and SSML-style breaks for fine-grained control. See Emotional Voice Control for examples.

Next Steps

Emotional Voice Control

Add emotional expression and dramatic pacing with mars-instruct.

TTS with Accents

Generate speech in 140+ language accents with the same voice.

Voice Cloning

Clone a voice from reference audio and generate speech with it.

MARS 8 Models

Compare model variants in detail.