Skip to main content
The official Java SDK for Camb.ai provides convenient access to text-to-speech, dubbing, translation, transcription, audio separation, voice cloning, and audio generation. Requests use a fluent builder pattern; async jobs follow a typed submit-poll-fetch workflow with TaskStatus enums.

Installation

Gradle

Add the dependency to your build.gradle:

Maven

Add the dependency to your pom.xml:

Authentication

Get your API key from CAMB.AI Studio and set it as an environment variable:

Quick Start

Streaming Text-to-Speech

The SDK returns an InputStream for TTS audio so you can stream the response directly to disk:
The generated SDK classes in this repository are in the default Java package (no package ...; declaration). To keep this snippet runnable without extra packaging changes, put Main in the default package too.
The snippets in the sections below assume client is already initialized as shown above.

Models / Configuration

Camb.ai uses MARS models configured through speechModel on the streaming TTS request:
To control the output encoding, set outputConfiguration.format with types.OutputFormat:
OutputFormatValue sent to the API
OutputFormat.WAVwav
OutputFormat.FLACflac
OutputFormat.MP3mp3
OutputFormat.ADTSadts

TTS Options

textToSpeech().tts(...) accepts CreateStreamTtsRequestPayload. Set the core request fields plus optional controls with the request builder.
Builder methodDescription
.text(...)Text to synthesize. For MARS Instruct, you can include inline emotion or pacing tags in the text.
.language(...)Locale such as CreateStreamTtsRequestPayloadLanguage.EN_US.
.voiceId(...)Voice profile ID from voiceCloning().listVoices().
.speechModel(...)Model to use, such as MARSFLASH, MARSPRO, or MARSINSTRUCT.
.userInstructions(...)Adds style, tone, pronunciation, or delivery guidance for the request. Available only with MARSINSTRUCT.
.outputConfiguration(...)Output settings such as audio format.
.voiceSettings(...)Voice behavior controls such as speaking rate, reference enhancement, or accent preservation.
.inferenceOptions(...)Advanced generation controls for supported models.
.enhanceNamedEntitiesPronunciation(...)Improves pronunciation for names and other named entities when supported.

Text-to-Speech

The textToSpeech().tts(...) call streams audio as an InputStream. Add userInstructions when using MARSINSTRUCT to control delivery style:

Voice Cloning

Voice cloning uses the voice library to list available voices and create custom clones from short reference audio samples:

List voices

Create a custom voice

Upload a reference recording along with a display name and a gender identifier:

Dubbing

Dubbing is an asynchronous pipeline: you submit a job, poll until it succeeds, then fetch dubbed run information:

Translation

Translation is asynchronous: create a task, poll status, then fetch translated text:

Transcription

Transcription is an asynchronous pipeline. Submit an audio URL, poll until success, then fetch the structured transcript:

Audio separation

Audio separation uploads a local file, polls completion, then returns download URLs for the separated stems:

Text-to-voice

Text-to-voice is asynchronous. Create a voice from a description, poll until success, then read preview URLs:

Text-to-audio

Text-to-audio is asynchronous. Submit a prompt, poll until it succeeds, then download the resulting audio stream:

Stories

The Stories endpoint ingests a document file and generates narrated audio asynchronously. The client returns a union response for submission, so you extract task_id with visit(...):

Translated TTS

Translated TTS is asynchronous. Create a translated TTS task, poll until success, then inspect the success payload via OrchestratorPipelineResult.getAdditionalProperties():

Dictionaries

Dictionaries are shared term mappings that APIs can use to handle terminology consistently across transcription, dubbing, and translation:

List dictionaries

Create from file and manage terms


Custom Providers

Custom hosting providers are implemented as ITtsProvider instances. You call provider.tts(request, requestOptions) directly instead of routing through CambApiClient:

Next Steps

https://mintcdn.com/cambai/2LvnefIkletroPxv/images/pipecat-orange.svg?fit=max&auto=format&n=2LvnefIkletroPxv&q=85&s=40cf8e001b8cadc8a4c3c557dea603d5

Voice Agents

Build real-time voice agents with Pipecat
https://mintcdn.com/cambai/2LvnefIkletroPxv/images/livekit-orange.svg?fit=max&auto=format&n=2LvnefIkletroPxv&q=85&s=c750fcee9b1de69e3c1d0d6ec7eb6b3f

LiveKit Integration

Create voice agents with LiveKit

API Reference

Explore the full TTS API

Voice Library

Browse available voices

Resources