Skip to main content
Voice cloning takes two requests. First you upload a short recording of the voice and get back a speaker embedding. Then you send text with that embedding and get audio in the cloned voice. The example does both in one run. You need a recording of 5 to 30 seconds of one person speaking clearly, with little background noise. The examples call it reference.wav.
Only clone a voice when the speaker has agreed to it. A speaker embedding represents a real person’s voice: store it as securely as you would the recording, and do not share it.
1

Create an API key

Sign in to the Gnani API dashboard and generate an API key.
2

Set your key

The examples read your key from the GNANI_API_KEY environment variable, so it never appears in your code. Set it in the terminal you will run the examples from:
If you use a .env file, load it with a library such as python-dotenv or dotenv, and keep the file out of version control.
3

Install

If jq is missing, install it from jqlang.org.
4

Run

Run the Python example with python quickstart.py and the Node.js example with node quickstart.mjs.
There is no Python SDK tab: the Python SDK can use a speaker embedding but cannot create one. See Voice cloning in the Python SDK.
5

Check the output

The first request returns 200 and a speaker embedding in data.voice_clone_embedding:
The second request returns 200 with WAV audio, saved as cloned.wav. Play it: you should hear “नमस्ते, आप कैसे हैं?” (“Hello, how are you?”) in the voice from your recording.The cURL example saves it as speaker_embedding.json. Keep the embedding and reuse it for later requests. You only need to create it once per voice.

If it didn’t work

Voice Cloning errors return a JSON body with a message that says what is wrong, instead of an embedding or audio. Every error is listed in the Error Reference.

Next

Voice Clone Embeddings

What makes a good reference recording.

Streaming

Receive cloned audio as it is generated.

Realtime

Lowest latency over a WebSocket.
Last modified on December 2, 2026