Voice Cloning
Create custom voice clones from audio samples, then use them with TTS to generate speech in that voice.
Clone limits
FreeProPremium1 clone5 clones20 clones
Typical workflow
Voice cloning is a two-step process: prepare a sample, then create the clone.
End-to-end example
const { sample, error: sampleErr } = await sonus.voices.prepareSample({
url: 'https://example.com/voice-sample.mp3',
})
if (sampleErr) throw sampleErr
const { voice, error: voiceErr } = await sonus.voices.create({
name: 'My Voice',
audio: sample.audio,
format: sample.format,
sampleRate: sample.sampleRate,
})
if (voiceErr) throw voiceErr
const { sound, error: ttsErr } = await sonus.tts.generate({
text: 'Hello in my cloned voice!',
voiceId: voice.id,
provider: 'fish',
})sonus.voices.prepareSample({ url })Download and prepare an audio sample for voice cloning. Audio must be 3\u201340 seconds.
| Parameter | Type | Description |
|---|---|---|
urlrequired | string | URL to an audio file (3–40 seconds) |
const { sample, error } = await sonus.voices.prepareSample({
url: 'https://example.com/voice-sample.mp3',
})sonus.voices.create({ name, audio, format, sampleRate, skipAsr? })Create a voice clone from a prepared audio sample.
| Parameter | Type | Description |
|---|---|---|
namerequired | string | Name for the voice clone |
audiorequired | string | Base64-encoded audio from prepareSample |
formatrequired | string | Audio format from prepareSample |
sampleRaterequired | number | Sample rate from prepareSample |
skipAsr | boolean | Skip automatic speech recognition (default: false) |
const { voice, error } = await sonus.voices.create({
name: 'My Custom Voice',
audio: sample.audio,
format: sample.format,
sampleRate: sample.sampleRate,
})sonus.voices.list()List all your voice clones.
const { voices, error } = await sonus.voices.list()sonus.voices.delete(id)Delete a voice clone by ID.
const { ok, error } = await sonus.voices.delete('voice_abc123')