Skip to main content

Overview

Translate text and generate speech in one API call. Input text in any language, get audio output in your target language.
This is different from the standard TTS API which only changes accents. Translated TTS actually translates your text before speaking.

Hear the Translations

Same English input, automatically translated and spoken in each language:

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-ai
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
import time
import requests
from camb.client import CambAI
from camb.types.language_enums import Languages

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

def translate_and_speak():
    # Translate English to Spanish and generate speech
    # Language codes: 1 = English (US), 54 = Spanish (Spain)
    response = client.translated_tts.create_translated_tts(
        text="Hello, welcome to our service. We're glad to have you here.",
        source_language=Languages.EN_US,  # English (US)
        target_language=Languages.ES_ES,  # Spanish (Spain)
        voice_id=144300      # Voice ID (required)
    )

    task_id = response.task_id
    print(f"Task created: {task_id}")

    # Poll for completion
    while True:
        status = client.translated_tts.get_translated_tts_task_status(task_id=task_id)
        print(f"Status: {status.status}")

        if status.status == "SUCCESS":
            # Get the audio URL and download
            result = client.text_to_speech.get_tts_run_info(
                run_id=status.run_id,
                output_type="file_url"
            )
            audio_response = requests.get(result.output_url)
            with open("translated_output.wav", "wb") as f:
                f.write(audio_response.content)
            print("Saved to translated_output.wav")
            break
        elif status.status == "FAILED":
            print("Translation failed!")
            break

        time.sleep(2)

translate_and_speak()

Parameters

ParameterDescription
textInput text to translate
source_languageNumeric language ID of input (e.g., 1 for English)
target_languageNumeric language ID for output (e.g., 54 for Spanish)
voice_idVoice ID to use for speech generation (required)

Common Language IDs

LanguageID
English (US)1
Spanish (Spain)54
French (France)76
German (Germany)31
Japanese (Japan)88
Hindi (India)81
Portuguese (Brazil)111
Chinese (Mandarin)139

Use Cases


Next Steps

Emotional Voice Control

Add emotional expression to translated speech.

TTS with Accents

Speak in 140+ accents without translating.

Text to Speech

Generate speech from text using the SDK.

Voice Cloning

Clone a voice from reference audio.

API Reference

Full Translated TTS API specification.