Skip to main content
The official Python SDK for Camb.ai provides convenient access to text-to-speech, dubbing, translation, transcription, audio separation, voice cloning, and audio generation. It ships synchronous and asynchronous clients with streaming audio helpers and typed language enums.

Installation

Requires Python 3.9 or later.

Authentication

Get your API key from Camb.ai Studio and set it as an environment variable. The client reads it via os.getenv("CAMB_API_KEY") so your key never has to appear in source code. The SDK ships two clients. Use CambAI for scripts, data pipelines, and anything thread-managed. Use AsyncCambAI for web servers (FastAPI, Sanic) and high-concurrency applications where blocking would hurt throughput.

Quick Start

The quickest way to get started is streaming TTS audio directly to a file. tts() returns a byte iterator that save_stream_to_file writes in one call:
For async applications, use AsyncCambAI and save_async_stream_to_file. The interface is identical to the sync client:

Models

Camb.ai offers MARS models tuned for different quality and latency requirements. Pass the model name as speech_model in any TTS call. If you omit it, the API uses a default model.
Best for: Voice agents, real-time applicationsSample rate: 22.05 kHz

TTS Options

The text_to_speech.tts(...) method accepts the core request fields plus optional controls for model behavior and output format. Example with mars-instruct delivery guidance:

Voices

List Voices

Call list_voices() to retrieve all voices available on your account, including pre-built library voices and any custom voices you have created. The id field is what you pass as voice_id in TTS calls.

Create a Custom Voice

To clone a voice, upload a short reference audio sample alongside a name and gender. Setting enhance_audio=True applies preprocessing that improves cloning quality on recordings with background noise.

Language Support

Camb.ai supports up to 312 languages depending on the MARS model — see Language Support for the full per-model locale list. You can pass locale strings directly, but using the Languages enum is recommended because it provides autocomplete in your editor and prevents typos in language codes.
To fetch the full list of supported languages at runtime, use the languages sub-client. Source languages are what you can transcribe or translate from; target languages are what you can translate or dub into.
Languages supported per model are listed at MARS Models.

Dubbing

The dubbing pipeline takes a publicly accessible video URL, translates the audio track into your target language, and synthesizes speech using a clone of the original speaker’s voice. Dubbing is asynchronous: you submit the job, poll for completion, and then fetch the result.
To dub into multiple languages in a single job, replace target_language with the target_languages list:

Get Transcript

Once a dubbing job completes, you can retrieve the full transcript for any target language using the run_id returned by get_dubbing_status.

Translation

The translation API accepts a list of text strings and returns them translated into the target language in the same order. Like dubbing, translation is asynchronous. You submit a job and poll until the status reaches SUCCESS.
create_translation accepts a list of strings under texts. All strings are translated in a single job and returned in order.

Transcription

Submit an audio or video file for transcription and retrieve the result once processing completes. You can pass a remote URL via media_url or upload a local file via media_file. The result supports optional word-level timestamps.
To transcribe a local file rather than a URL, open it in binary mode and pass it via media_file:

Audio Separation

Audio separation splits a mixed audio track into its vocal and background components. After the job completes, the result contains separate download URLs for each stem so you can use them independently.

Text-to-Voice

Text-to-Voice creates a brand-new synthetic voice from a written description of the desired vocal characteristics. The API generates several audio samples so you can audition variations before deciding which voice ID to use in production.
The result contains multiple sample audio URLs. Preview them and use the voice_id of your preferred sample with client.text_to_speech.tts.

Text-to-Audio

Text-to-Audio generates sound effects or ambient soundscapes from a descriptive text prompt. The job is asynchronous, and the result is a streamable audio file you can save with save_stream_to_file once processing completes.

Stories

The Stories API takes a document file, structures its content into a narrative, and returns a fully narrated audio output. You can provide a custom narrator voice ID; if omitted, the API selects a default voice appropriate for the source language.

Translated TTS

Translated TTS combines translation and speech synthesis into a single asynchronous job. The text is translated into the target language and then spoken using the voice you specify, without needing to run translation and TTS as separate steps.

Dictionaries

Dictionaries contain custom term mappings that the API applies automatically when running dubbing or translation jobs. They are particularly useful for brand names, product terminology, and proper nouns that need consistent handling across languages.

List Dictionaries

Call get_dictionaries() to retrieve all dictionaries on your account along with their metadata:

Create from File

Upload a CSV file to create a new dictionary. The file should contain source and target term pairs in a format the API expects:

Manage Terms

Use add_term_to_dictionary to insert individual term translations and delete_dictionary_term to remove them by ID. Each term takes a source, a target, and the language the target is in:

Custom Provider

If you are running MARS on your own infrastructure through Baseten, you can initialize the client with a provider configuration instead of a Camb.ai API key. See Custom Cloud Providers for deployment instructions.

Baseten

Deploy the MARS model to your Baseten account, then point the client at your deployment URL. Baseten calls require a base64-encoded reference audio sample to be passed with every request:
Baseten deployments require reference_audio (base64-encoded WAV) and reference_language in additional_body_parameters.

Next Steps

https://mintcdn.com/cambai/2LvnefIkletroPxv/images/pipecat-orange.svg?fit=max&auto=format&n=2LvnefIkletroPxv&q=85&s=40cf8e001b8cadc8a4c3c557dea603d5

Voice Agents

Build real-time voice agents with Pipecat
https://mintcdn.com/cambai/2LvnefIkletroPxv/images/livekit-orange.svg?fit=max&auto=format&n=2LvnefIkletroPxv&q=85&s=c750fcee9b1de69e3c1d0d6ec7eb6b3f

LiveKit Integration

Create voice agents with LiveKit

API Reference

Explore the full TTS API

Voice Library

Browse available voices

Resources