Build a Voice Cloning Demo App
Description and use
This article walks through a complete end-to-end voice cloning demo using the ElevenLabs API: upload a short WAV sample, create a cloned voice, and synthesize text on demand via a Python script and optionally a Flask web service
Problem
How to create a complete, end-to-end voice cloning demo that lets users upload a short sample, generate a cloned voice, and synthesize any text on demand using the ElevenLabs API.
Outcome
A complete end-to-end voice cloning demo: upload a ~30-second WAV sample, create a cloned voice via ElevenLabs API, then synthesize arbitrary text on demand using a Python script and optionally a Flask web service.
Workflow
- Get an ElevenLabs API key from https://try.elevenlabs.io/kr07zfuqn1bp and store it as ELEVENLABS_API_KEY environment variable
- Upload a short voice sample (≈30 seconds, WAV 16-bit 44.1 kHz) via multipart/form-data POST to /v1/voices/add with name=MyDemoVoice
- Save the returned voice_id for later use
- Run a Python script (synth_demo.py) that POSTs to /text-to-speech/{voice_id} with text, model_id=eleven_monolingual_v1, stability=0.75, similarity_boost=0.85, and writes the streamed WAV bytes to output.wav
- Optionally wrap the synthesis logic in a Flask app exposing a /speak POST endpoint that accepts JSON text and returns synthesized audio or JSON response
Evidence
Modern text-to-speech (TTS) platforms can take a few minutes of recorded audio and generate a synthetic voice that sounds almost indistinguishable from the real thing.
In this post we’ll walk through a complete, end-to-end demo that lets you upload a short sample, generate a cloned voice, and then synthesize any text on demand. We’ll use the ElevenLabs API, which is currently one of the most developer-friendly services for high-quality voice cloning.
The ElevenLabs free tier gives you 10 k characters per month—perfect for experimenting.
The file must be a WAV (16-bit, 44.1 kHz) for best results.
curl -X POST "https://api.elevenlabs.io/v1/voices/add" -H "xi-api-key: $ELEVENLABS_API_KEY" -F "name=MyDemoVoice" -F "files[]=@/path/to/voice_sample.wav"
POST /text-to-speech/{voice_id} with your text. Passes optional voice_settings to tweak stability (smoothness) and similarity boost (how close it stays to the original sample). Streams the returned WAV data directly to output.wav.
If you want to expose the demo as a simple API endpoint, Flask makes it a breeze:
- Record date: 2026-10-20T18:41:04.440Z