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.

Example Prompts

  • “A futuristic sci-fi laser sound effect”
  • “Rain falling on a tin roof”
  • “Upbeat jazz elevator music”
  • “Thunder and lightning storm”
  • “Footsteps on gravel”

Python

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="A futuristic sci-fi laser sound effect",
        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.mp3")
            print("Saved to sound_effect.mp3")
            break
        elif status.status == "FAILED":
            print("Task failed!")
            break

        time.sleep(2)

generate_sound()

TypeScript

import { CambClient, saveStreamToFile } from '@camb-ai/sdk';

const client = new CambClient({
    apiKey: process.env.CAMB_API_KEY
});

async function generateSound() {
    // Create sound effect from text prompt
    // audio_type: "sound" for effects, "music" for music
    console.log('Creating sound effect...');
    const response = await client.textToAudio.createTextToAudio({
        prompt: 'A futuristic sci-fi laser sound effect',
        duration: 3.0,
        audio_type: 'sound'
    });

    const taskId = response.task_id;
    console.log(`Task created: ${taskId}`);

    // Poll for completion
    while (true) {
        const status = await client.textToAudio.getTextToAudioStatus({
            task_id: taskId
        });

        console.log(`Status: ${status.status}`);

        if (status.status === 'SUCCESS') {
            const result = await client.textToAudio.getTextToAudioResult({
                run_id: status.run_id
            });
            await saveStreamToFile(result, 'sound_effect.mp3');
            console.log('Saved to sound_effect.mp3');
            break;
        } else if (status.status === 'FAILED') {
            console.log('Task failed!');
            break;
        }

        await new Promise(r => setTimeout(r, 2000));
    }
}

generateSound();

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

  • Game Development: Generate unique sound effects
  • Video Production: Create custom audio for videos
  • Podcasts: Add background music or transitions
  • Prototyping: Quick audio assets for demos