Skip to content

Repository files navigation

Camb.ai PHP SDK

The official PHP SDK for interacting with Camb AI's powerful voice and audio generation APIs. Create expressive speech, unique voices, and rich soundscapes with just a few lines of PHP.

✨ 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.
  • Access to voice cloning, translation, and more (refer to full API documentation).

📦 Installation

To install the bindings via Composer, add the following to composer.json:

{
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/Camb-ai/cambai-php-sdk.git"
    }
  ],
  "require": {
    "camb-ai/cambai-php-sdk": "*@dev"
  }
}

Then run composer install.

🔑 Authentication & Accessing Clients

To use the Camb AI SDK, you'll need an API key.

require_once __DIR__ . '/vendor/autoload.php';

use Camb.ai\CambAIClient;

$client = new CambAIClient("YOUR_CAMB_API_KEY");

🚀 Getting Started: Examples

NOTE: For more examples, refer to the examples/ directory.

1. Text-to-Speech (TTS)

use Camb.ai\Model\CreateTTSRequestPayload;
use Camb.ai\Model\Languages;

$payload = new CreateTTSRequestPayload();
$payload->setText("Hello from Camb AI!");
$payload->setVoiceId(20303);
$payload->setLanguage(Languages::EN_US);

$response = $client->tts()->createTts($payload);
echo "Task ID: " . $response->getTaskId();

2. Text-to-Voice (Generative Voice)

use Camb.ai\Model\CreateTextToVoiceRequestPayload;

$payload = new CreateTextToVoiceRequestPayload();
$payload->setText("Creating a unique voice.");
$payload->setVoiceDescription("A deep, resonant male voice.");

$result = $client->getTextToVoiceApi()->createTextToVoiceTextToVoicePost($payload);

3. Text-to-Audio (Sound Generation)

use Camb.ai\Model\CreateTextToAudioRequestPayload;

$payload = new CreateTextToAudioRequestPayload();
$payload->setPrompt("A gentle breeze.");
$payload->setDuration(5.0);

$result = $client->getTextToAudioApi()->createTextToAudioTextToSoundPost($payload);

4. End-to-End Dubbing

use Camb.ai\Model\EndToEndDubbingRequestPayload;
use Camb.ai\Model\Languages;

$payload = new EndToEndDubbingRequestPayload();
$payload->setVideoUrl("https://example.com/video.mp4");
$payload->setSourceLanguage(Languages::EN_US);
$payload->setTargetLanguages([Languages::FR_FR]);

$result = $client->getDubApi()->endToEndDubbingDubPost($payload);

5. Custom Provider (Baseten) support

You can swap the backend TTS provider while keeping the same interface (e.g. for Baseten).

require_once 'examples/BasetenTtsProvider.php';

$basetenProvider = new BasetenTtsProvider("baseten_key", "https://model-url...");
$client->setTtsProvider($basetenProvider);

// Calls Baseten provider instead of default Camb.ai API
$client->tts()->createTts($payload);

License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages