Skip to main content

Overview

Generate royalty-free sound effects or music from natural language descriptions. Describe what you want to hear and get audio output.

Listen to Examples

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
from camb.client import CambAI, save_stream_to_file

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

def generate_sound():
    # Create sound effect from text prompt
    # audio_type: "sound" for effects, "music" for music
    response = client.text_to_audio.create_text_to_audio(
        prompt="Sword clashing against a metal shield in a medieval battle",
        duration=3.0,
        audio_type="sound"
    )

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

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

        if status.status == "SUCCESS":
            result = client.text_to_audio.get_text_to_audio_result(status.run_id)
            save_stream_to_file(result, "sound_effect.wav")
            print("Saved to sound_effect.wav")
            break
        elif status.status == "FAILED":
            print("Task failed!")
            break

        time.sleep(2)

generate_sound()

Parameters

ParameterDescriptionValues
promptNatural language description of desired audioAny text
durationLength of audio in seconds1.0 - 30.0
audio_typeType of audio to generate"sound" or "music"

Use Cases


Next Steps

Text to Speech

Generate speech from text using the SDK.

TTS with Accents

Speak in 140+ language accents with the same voice.

Voice Cloning

Clone a voice from reference audio.

API Reference

Full Text-to-Sound API specification.