Skip to navigation

Instant Voice Cloning API

Beta
View as Markdown

Instant Voice Cloning is in beta, including HTTP streaming (POST /voices/clone/stream) and WebSocket streaming (GET /voices/clone/ws).

Use the official sarvamai Python and TypeScript SDKs — the same client shape as Bulbul Text-to-Speech (voice_cloning.convert / convert_stream, plus voice_cloning_streaming for WebSocket). See Libraries & SDKs. Requires sarvamai ≥ 0.1.37 (Python) or ≥ 1.1.12 (TypeScript) for the Instant Voice Cloning surface.

Instant Voice Cloning can follow either path:

  1. Saved voice (recommended for reuse): create once with POST /voices/create (or client.voice_cloning.create_voice), then pass voice_id on every generate call.
  2. Inline reference clip: send ref_audio (optional ref_text) on each generate call — no saved voice required.

Generate speech with one of:

  • POST /voices/clone / voice_cloning.convert — one-shot JSON response with base64 audio
  • POST /voices/clone/stream / voice_cloning.convert_stream — binary audio stream as sentences become ready
  • GET /voices/clone/ws / voice_cloning_streaming — WebSocket for incremental text and multi-turn sessions

Send exactly one of ref_audio or voice_id on each generate request. Sending both returns 400.

Base URL and authentication. See the API Reference for the current base URL and auth header. Generate a key from Key Management in the dashboard. The SDKs take the same key as api_subscription_key / apiSubscriptionKey.

What you get

How it works

1

Create a voice

Send a clean reference clip to POST /voices/create or client.voice_cloning.create_voice. The response returns a voice_id.

2

Generate speech

Call voice_cloning.convert / POST /voices/clone with text and either voice_id or ref_audio. language_code is optional — omit it to detect the language from the text, or pass it when pronunciation has to be exact. Use HTTP streaming / WebSocket for progressive audio.

3

Decode or play the audio

For the one-shot endpoint, decode the base64-encoded audio / audio_b64 in the JSON response. For HTTP stream, iterate the binary chunks from convert_stream; for WebSocket, decode each base64 frame from voice_cloning_streaming.

Prefer the Python and TypeScript SDKs. Endpoint-level schemas and extra language snippets are on the API Reference.

Quickstart

Install the SDK (pip install "sarvamai>=0.1.37" or npm install sarvamai@1.1.12), then create a voice and synthesize:

import base64
from sarvamai import SarvamAI
client = SarvamAI(api_subscription_key="YOUR_SARVAM_API_KEY")
with open("reference.wav", "rb") as f:
created = client.voice_cloning.create_voice(
file=f,
name="my-voice",
language="en-IN",
)
voice_id = created.data.voice_id
response = client.voice_cloning.convert(
voice_id=voice_id,
text="नमस्ते, मैं आपकी कैसे मदद कर सकता हूँ?",
)
with open("output.wav", "wb") as out:
out.write(base64.b64decode(response.audio_b64 or response.audio))

language_code is optional. These examples omit it so the service detects Hindi from the text. Pass language_code when pronunciation has to be exact — see Supported languages.

The one-shot response contains audio / audio_b64 and request_id. See the API Reference for the complete request and response schemas.

Manage saved voices

Voices are shared with Content Studio for the same workspace.

EndpointWhat it does
POST /voices/createCreate a cloned voice from a reference clip in one shot. The response returns the new voice_id and the auto-generated transcript (reference_text) together - the voice is ready to use with POST /voices/clone immediately, and appears under Studio My voices.
GET /voicesList the cloned voices in your workspace (filter by name, gender, accent; paginated). Each item’s id is the same value you pass as voice_id on POST /voices/clone. It lists voices created by anyone in the workspace; the creator, when known, appears as created_by_email.
GET /voices/{voice_id}Full details for one voice, including its transcript and time-limited signed URLs for the reference and preview audio. The path param is the same svc-{uuid} as list id / create voice_id.
DELETE /voices/delete/{voice_id}Delete a voice. Its audio assets are removed and the voice stops being listed or usable in the API and in Studio.

The Starter plan (pay as you go) keeps up to 50 cloned voices across your organization, in Content Studio and the API. Pro and Enterprise plans have higher limits. On any plan, deleting a voice frees a slot. In Content Studio, only the person who created a voice, an organization owner or admin, or a workspace admin can delete it.

Limits and pricing

RequestLimit
Create voice file size50 MB
Inline ref_audio on generate (REST / stream / WS)10 MB, max 15 seconds
Recommended reference duration10-15 seconds
Generate speech text (REST / HTTP stream)1000 characters
WebSocket text per message2500 characters

Generation is billed per character of text. See Pricing.

Voice cloning requires consent. Only clone a voice you have the right to use. See Commercial Licensing for the consent requirements that apply to cloned-voice audio.

Explore

Need help scoping a voice-cloning integration? Reach out on Discord.