- Python
- TypeScript
def voices_clone(client: Cartesia) -> Any:
"""Clone a voice from an audio clip."""
with open("sample.wav", "rb") as clip:
voice = client.voices.clone(
clip=clip,
name="My Voice",
description="A custom voice",
language="en",
)
return voice
async function voicesClone(client: Cartesia): Promise<void> {
/** Clone a voice from an audio clip. */
const clip = fs.createReadStream('sample.wav');
const voice = await client.voices.clone({
clip,
name: 'My Voice',
description: 'A custom voice',
language: 'en',
});
console.log('Cloned voice:', voice.id);
}
Run this example
- Python
- TypeScript
cd cartesia-python
CARTESIA_API_KEY=YOUR_KEY python3 examples/examples.py voices_clone
cd cartesia-js
CARTESIA_API_KEY=YOUR_KEY npx ts-node examples/node_examples.ts voicesClone