Voice cloning
Reproduce a specific speaker from a reference clip, inline on each request or as a voice you create once and speak in by id.
Overview
Voice cloning lets you reproduce a specific speaker from a reference clip.
POST /v1/audio/speech takes the clip as ref_audio with its transcript in
ref_text, and the model speaks input in that voice.
There are two ways to supply the clip. Inline, the clip travels in the body of
every speech request. As a created voice, POST /v1/audio/voices stores the
clip once, and the voice's id goes in voice afterwards.
Cloning reproduces a real person, so you need that person's audio and their permission. For a distinctive voice that is not a specific person's, see Voice design.
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",
"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-encoded. |
ref_text | string | Transcript of exactly what is said in ref_audio. |
Send ref_audio and ref_text without a voice.
Create a cloned voice
To create a voice from a clip, send the clip as a multipart upload to
POST /v1/audio/voices with its transcript, a name, and the model that speaks
it.
curl https://api.sprag.ai/v1/audio/voices \
-H "Authorization: Bearer $SPRAG_API_KEY" \
-F model=chorus \
-F [email protected] \
-F "ref_text=The quick brown fox jumps over the lazy dog." \
-F name=Priya \
-F consent_ref=release-2026-0142| Field | Required | Notes |
|---|---|---|
file | Yes | The reference clip. |
model | Yes | chorus. |
ref_text | Yes | Transcript of exactly what is said in the clip. |
name | Yes | A display name, unique among your organization's voices. |
description | No | Free-form notes, returned on the voice. |
consent_ref | No | A pointer to your record of the speaker's permission, such as a release form number or a contract id. Stored with the voice. |
The response is a voice with category set to cloned.
{
"object": "audio.voice",
"id": "voice_4c7d...",
"name": "Priya",
"created_at": 1758067200,
"description": null,
"category": "cloned"
}A name already in use returns 409. A clip that is empty or cannot be measured
returns 400. A clip too large to synthesize from returns 413.
If your organization already holds as many voices as its plan allows, the
request returns HTTP 403 with the error code voice_limit_exceeded.
Speak in a cloned voice
Pass the voice's id as voice on POST /v1/audio/speech, with model set to
chorus and no ref_audio. A created voice and inline ref_audio cannot be
combined in one request.
curl https://api.sprag.ai/v1/audio/speech \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $SPRAG_API_KEY" \
-d '{
"model": "chorus",
"input": "This sentence is spoken in the cloned voice.",
"voice": "voice_4c7d...",
"response_format": "mp3"
}' \
--output priya.mp3If the request carries your API key, GET /v1/audio/voices?model=chorus lists
the voices your organization created after the presets.
DELETE /v1/audio/voices/{voice_id} deletes the voice and its stored clip.
Write the transcript
Set ref_text to what is said in ref_audio, word for word.
A clip you can transcribe exactly is a better reference than a longer one transcribed approximately. When you trim a recording, cut at a boundary you can transcribe with confidence.
If you do not have a transcript, produce one with speech to text and check it before sending it.
Encode the reference clip
ref_audio takes a base64 data: URL, so the clip is inlined into the request
body. POST /v1/audio/voices takes the file itself as a multipart upload and
needs no encoding.
REF_B64=$(base64 < reference.wav | tr -d '\n')Common containers such as WAV, MP3, FLAC, OGG, M4A, AAC, AIFF, and WebM are accepted. A clean recording of a single speaker, consistent in tone and level, clones better than a noisy or highly dynamic one. An inline clip travels in every request, so a shorter clip means a smaller request body.
Consent
Treat a reference clip like any other biometric sample. Get explicit permission
from the speaker for the use you intend, hold a record of it, and do not reuse
a clip for a purpose the speaker did not agree to. The
terms of service make that responsibility yours. On a created voice,
consent_ref stores a pointer to that record.