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-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
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_languageSource language (e.g., Languages.EN_US). The raw API also accepts locale-tag strings like "en-us"; numeric IDs still work but are deprecated.
target_languageTarget language (e.g., Languages.ES_ES).
voice_idVoice ID to use for speech generation (required)

Common Languages

LanguageEnumLocale (raw API)
English (US)Languages.EN_USen-us
Spanish (Spain)Languages.ES_ESes-es
French (France)Languages.FR_FRfr-fr
German (Germany)Languages.DE_DEde-de
Japanese (Japan)Languages.JA_JPja-jp
Hindi (India)Languages.HI_INhi-in
Portuguese (Brazil)Languages.PT_BRpt-br
Chinese (Mandarin)Languages.ZH_CNzh-cn
See Language Support for the full list.

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.