Voice cloning
Reproduce a specific speaker from a reference clip and its transcript.
Overview
Send a reference clip of a speaker plus a transcript of that clip, and Chorus
speaks your input in that voice.
Cloning is inline: there is no voice to create first, and nothing is stored. Send the clip in the request body every time you synthesize with it.
Cloning reproduces a real person, so you need that person's audio and their permission. If you want a distinctive voice rather than a specific person's, use voice design instead, which raises no consent question.
Clone from a reference clip
curl https://api.sprag.ai/v1/audio/speech \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $SPRAG_API_KEY" \
-d '{
"model": "chorus-clone",
"input": "This sentence is spoken in the cloned voice.",
"ref_audio": "data:audio/wav;base64,UklGRiQAAABXQVZF...",
"ref_text": "The quick brown fox jumps over the lazy dog.",
"response_format": "mp3"
}' \
--output cloned.mp3| Field | Type | Notes |
|---|---|---|
ref_audio | string | Inline data: URL of the reference clip, base64. |
ref_text | string | Transcript of exactly what is said in ref_audio. |
chorus-clone is the model that takes reference audio. The chorus alias
accepts it too; chorus-voices and chorus-design return 400. Send
ref_audio without voice: on the alias, a preset id pulls the request to
the preset model, which rejects reference audio.
The transcript
Set ref_text to what is actually said in ref_audio, word for word.
A clip you can transcribe exactly is generally a better reference than a longer one transcribed approximately. When you trim a recording, cut to a boundary you can transcribe with confidence rather than taking more audio and paraphrasing.
If you do not have a transcript, produce one first with speech to text and check it before using it here.
Encode the reference clip
ref_audio takes a data: URL, so the clip is inlined into the request body
rather than uploaded separately.
REF_B64=$(base64 < reference.wav | tr -d '\n')A web URL returns 400, and so does a data: URL without ;base64. The media
type in the URL is not read; the bytes are sniffed, so a mislabeled container
still works.
wav, mp3, flac, ogg, m4a, aac, aiff, and webm are recognized. Anything else is transcoded before synthesis. Nothing constrains duration, sample rate, or channel count; the only cap is the 100 MiB request body, and a clip still too large after transcoding returns 413.
Clip quality is not enforced either. A clean recording of a single speaker, consistent in tone and level, generally clones better than a noisy or highly dynamic one. Base64 inflates the payload by about a third and the clip is re-sent on every request, so keep clips short to hold request sizes down.
Consent
Treat a reference clip like any other biometric sample. Get explicit permission from the speaker for the use you have in mind, keep a record of it, and do not reuse a clip for a purpose the speaker did not agree to. The request carries no consent field and the API keeps no record of the speaker, so nothing in the API prevents a cloned voice from saying something the person never said. Managing that risk is your responsibility.