Skip to main content
The Camb AI Python SDK is designed to provide a flexible and powerful interface to the Camb AI API. It supports both Synchronous and Asynchronous programming models and allows for integration with various TTS providers (like Baseten and Vertex).

Python SDK Link: Camb AI Python SDK

Installation Command:
pip install camb-sdk

Features:

  • Dubbing: Dub your videos into multiple languages with voice cloning!
  • Expressive Text-to-Speech: Convert text into natural-sounding speech using a wide range of pre-existing voices.
  • Generative Voices: Create entirely new, unique voices from text prompts and descriptions.
  • Soundscapes from Text: Generate ambient audio and sound effects from textual descriptions.
  • Voice Cloning, Translation, and more (refer to full API documentation).

Directly Usable Examples: Camb AI Python SDK Examples

Core Components

1. AsyncCambAI (Asynchronous Client)

The non-blocking client built on httpx.AsyncClient and asyncio. Ideal for web servers (FastAPI, Sanic), real-time applications, and high-concurrency scenarios.
from camb.client import AsyncCambAI
client = AsyncCambAI(api_key="...")

2. CambAI (Synchronous Client)

The standard blocking client. Use this for scripts, data processing pipelines, or applications where concurrency is managed via threads or isn’t a priority.
from camb.client import CambAI
client = CambAI(api_key="...")

Supported Models & Architecture

MARS Pro (48kHz)

The flagship model. It consists of two main stages:
  1. Prosody Model: Generates the rhythm, stress, and intonation of speech.
  2. Decoder: Converts these features into high-fidelity 48kHz audio.

MARS Flash (22.05kHz)

A distilled, faster version of MARS.
  • Lower Latency: optimized for near-real-time responses.
  • Sample Rate: 22.05kHz.

MARS Instruct (22.05kHz)

Designed for fine-grained control over the output.
  • Instruction Following: Can take specific style or tone instructions.

Handling Streaming Responses

Both clients support streaming to handle large audio files efficiently or play audio as it generates.
  • Sync: Returns a standard Iterator[bytes].
  • Async: Returns an AsyncIterator[bytes].

Private & Custom TTS Providers

The SDK supports routing Text-to-Speech generation requests to private or custom deployments of the MARS model. This is ideal for enterprise use cases requiring strict data privacy, dedicated throughput, or custom model fine-tuning.

Supported Providers

  • Baseten: For deployments on Baseten.co infrastructure.
  • Vertex AI (In Progress): For deployments on Google Cloud Vertex AI.

Baseten Deployment

For Baseten, initialize the client with your API key and the specific model URL. Reference Example Link: Baseten Provider Example
from camb.client import CambAI

client = CambAI(
    tts_provider="baseten",
    provider_params={
        "api_key": "YOUR_BASETEN_API_KEY",
        "mars_pro_url": "https://model-xxxxxx.api.baseten.co/environments/production/predict"
    }
)

Usage Example

When using Baseten, passing reference_audio in the additional_body_parameters is required.
import base64
from camb.client import save_stream_to_file

# Prepare audio reference
with open("reference.wav", "rb") as f:
    ref_audio_b64 = base64.b64encode(f.read()).decode("utf-8")

response = client.text_to_speech.tts(
    text="Generating audio from a private Baseten deployment.",
    language="en-us",
    speech_model="mars-pro",
    request_options={
        "additional_body_parameters": {
            "reference_audio": ref_audio_b64,
            "reference_language": "en-us"
        },
        "timeout_in_seconds": 300
    }
)

save_stream_to_file(response, "baseten_output.mp3")

How it Works

  1. The SDK bypasses standard Camb AI API endpoints.
  2. It authenticates directly with Baseten using the provided API Key.
  3. It streams generated audio directly from the model instance.

Vertex AI Deployment

Support for Vertex AI is currently in progress.
client = CambAI(
    tts_provider="vertex",
    provider_params={
        "project_id": "your-gcp-project-id",
        "location": "us-central1"
    }
)