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
Create an account
Sign up at CAMB.AI Studio if you haven’t already.
Get your API key
Go to Settings → API Keys in Studio and copy your key. See Authentication for details.
Install the SDK
Code
Choosing a Model
CAMB.AI offers three MARS 8 model variants:| Model | Best For | Sample Rate |
|---|---|---|
mars-flash | Real-time voice agents, low-latency apps | 22.05 kHz |
mars-pro | Audio production, high-quality content | 48 kHz |
mars-instruct | Fine-grained control over tone and style | 22.05 kHz |
mars-instruct accepts a user_instructions parameter to control delivery:
Listing Voices
List available voices to find the right one for your use case:Parameters
Required
| Parameter | Type | Description |
|---|---|---|
text | string | Text to convert to speech (min 3 characters) |
voice_id | integer | Voice ID to use (e.g., 147320) |
Optional
| Parameter | Type | Default | Description |
|---|---|---|---|
language | string | "en-us" | BCP-47 language code |
speech_model | string | "mars-flash" | mars-flash, mars-pro, or mars-instruct |
output_configuration | object | {} | Output format: wav, mp3, or pcm_s16le |
user_instructions | string | - | Tone/style guidance (mars-instruct only) |
mars-instruct supports embedded emotion tags and SSML-style breaks for fine-grained control. See Emotional Voice Control for examples.