TaskStatus enums.
Installation
Gradle
Add the dependency to yourbuild.gradle:
Maven
Add the dependency to yourpom.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 anInputStream 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.client is already initialized as shown above.
Models / Configuration
Camb.ai uses MARS models configured throughspeechModel on the streaming TTS request:
outputConfiguration.format with types.OutputFormat:
OutputFormat | Value sent to the API |
|---|---|
OutputFormat.WAV | wav |
OutputFormat.FLAC | flac |
OutputFormat.MP3 | mp3 |
OutputFormat.ADTS | adts |
TTS Options
textToSpeech().tts(...) accepts CreateStreamTtsRequestPayload. Set the core request fields plus optional controls with the request builder.
| Builder method | Description |
|---|---|
.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
ThetextToSpeech().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 agender 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 extracttask_id with visit(...):
Translated TTS
Translated TTS is asynchronous. Create a translated TTS task, poll until success, then inspect the success payload viaOrchestratorPipelineResult.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 asITtsProvider instances. You call provider.tts(request, requestOptions) directly instead of routing through CambApiClient:
Next Steps
Voice Agents
Build real-time voice agents with Pipecat
LiveKit Integration
Create voice agents with LiveKit
API Reference
Explore the full TTS API
Voice Library
Browse available voices