🚀 Introducing MARS8 Series — Four Powerful Variants | Available on All Major Clouds | Learn about the model here
🚀 Introducing MARS8 Series — Four Powerful Variants | Available on All Major Clouds | Learn about the model here
Creates a new voice clone by uploading an audio file reference.
curl --request POST \
--url https://client.camb.ai/apis/create-custom-voice \
--header 'Content-Type: multipart/form-data' \
--header 'x-api-key: <api-key>' \
--form 'voice_name=<string>' \
--form gender=0 \
--form file='@example-file' \
--form description=null \
--form age=30 \
--form enhance_audio=false \
--form language=null{
"voice_id": 123
}Documentation Index
Fetch the complete documentation index at: https://docs.camb.ai/llms.txt
Use this file to discover all available pages before exploring further.
import requests
import os
import time
def create_custom_voice(file_path, voice_name, gender, age, description=None, language=None):
"""
Creates a custom voice clone from an audio sample
Parameters:
file_path (str): Path to the audio file containing the voice sample
voice_name (str): Name to assign to the custom voice
gender (int): Gender identifier (1=male, 2=female, etc.)
age (int): Approximate age of the speaker
description (str, optional): Detailed description of the voice
language (str, optional): Language code of the voice (e.g., "en-US")
Returns:
dict: Response from the API containing voice details
"""
# Validate file exists
if not os.path.exists(file_path):
raise FileNotFoundError(f"Audio file not found at: {file_path}")
# Prepare file for upload
files = {'file': open(file_path, 'rb')}
# Prepare metadata
data = {
'voice_name': voice_name,
'gender': gender,
'age': age
}
# Add optional parameters if provided
if description:
data['description'] = description
if language:
data['language'] = language
try:
# Make API request
response = requests.post(
"https://client.camb.ai/apis/create-custom-voice",
files=files,
data=data,
headers={
"x-api-key": os.environ.get("API_KEY") # Get API key from environment variable
}
)
# Close file handle
files['file'].close()
# Check for errors
response.raise_for_status()
# Return response data
return response.json()
except requests.exceptions.HTTPError as http_err:
print(f"HTTP error occurred: {http_err}")
if response.text:
print(f"Response details: {response.text}")
return None
except Exception as err:
print(f"Error creating custom voice: {err}")
return None
finally:
# Ensure file is closed even if an error occurs
if 'file' in files and not files['file'].closed:
files['file'].close()
# Example usage
if __name__ == "__main__":
result = create_custom_voice(
file_path="narrator_sample.wav",
voice_name="Professional Narrator",
gender=1,
age=45,
description="Clear, articulate voice with professional tone. Ideal for documentary narration.",
language="1"
)
if result:
print(f"Custom voice created successfully with ID: {result['voice_id']}")
/tts endpoint to convert text to speech in your custom voice.
/list-voices endpoint, alongside public and shared voices.
The x-api-key is a custom header required for authenticating requests to our API. Include this header in your request with the appropriate API key value to securely access our endpoints. You can find your API key(s) in the 'API' section of our studio website.
The name or label to be assigned to the voice.
Represents the gender of the speaker in the provided audio. Values are encoded as integers.
0, 1, 2, 9 The reference audio file that will be used to create the custom voice. The file should have clear speech to ensure optimal cloning accuracy. Supported formats include .aac, .flac, .mp3 and .wav.
A brief summary of the custom voice—e.g. its intended use, tone or character traits.
The estimated or actual age of the speaker in the reference audio.
x >= 1If set to true, the system will apply audio enhancement techniques such as noise reduction and volume normalization to improve voice clarity.
The language of the reference audio file. This field is optional.
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150 Successful Response
curl --request POST \
--url https://client.camb.ai/apis/create-custom-voice \
--header 'Content-Type: multipart/form-data' \
--header 'x-api-key: <api-key>' \
--form 'voice_name=<string>' \
--form gender=0 \
--form file='@example-file' \
--form description=null \
--form age=30 \
--form enhance_audio=false \
--form language=null{
"voice_id": 123
}