Developed by: Muzammal Ikhlaq
Real-Time Voice Cloning is an advanced deep learning framework implementing SV2TTS (Transfer Learning from Speaker Verification to Multispeaker Text-To-Speech Synthesis). This state-of-the-art system generates a high-fidelity digital clone of any target speaker's voice using only 5 to 10 seconds of reference audio, allowing real-time text-to-speech synthesis in that cloned voice.
- Key Features
- SV2TTS Architecture & Workflow
- Deep Learning Components
- Repository Structure
- Quick Start Guide
- Usage Modes
- REST API Documentation
- Performance & Inference Speed
- Developer Information & License
- โก 5-Second Voice Cloning: Zero-shot voice cloning capability from just a 5-10 second audio clip.
- ๐ง 3-Stage SV2TTS Neural Pipeline:
- Speaker Encoder: Extract a 256-dimensional fixed-size embedding vector from input audio.
- Tacotron Synthesizer: Convert text + speaker embedding into sequence mel-spectrograms.
- Wave-RNN Vocoder: Convert mel-spectrograms into high-fidelity 16kHz audio waveforms.
- ๐ฅ๏ธ Interactive PyQt5 GUI: Full graphical dashboard for recording audio, visualizing speaker embedding space (UMAP), and synthesizing audio interactively.
- โก Command-Line Interface (CLI): Streamlined CLI for fast batch or terminal voice cloning.
- ๐ RESTful API Server: Flask-based backend endpoint (
/clone) for web, mobile, and third-party app integration. - ๐ฆ Pre-Trained Weights Included: Pre-loaded PyTorch model checkpoints (
encoder.pt,synthesizer.pt,vocoder.pt).
Note
SV2TTS decouples speaker identity verification from speech synthesis, enabling real-time zero-shot voice cloning without requiring any model retraining for new speakers.
flowchart LR
subgraph Input ["Input Layer"]
A["Reference Audio Sample (.wav, .mp3)"]
B["Target Text Prompt"]
end
subgraph Pipeline ["SV2TTS Neural Pipeline"]
A --> C["1. Speaker Encoder<br/>(ResNet/LSTM Model)"]
C --> D["256d Speaker Embedding"]
B --> E["2. Tacotron Synthesizer<br/>(Attention-based TTS)"]
D --> E
E --> F["Mel-Spectrogram"]
F --> G["3. Wave-RNN Vocoder<br/>(Neural Audio Synthesis)"]
end
subgraph Output ["Output Layer"]
G --> H["Cloned Speech Waveform (.wav)"]
end
| Component | Model Type | Checkpoint Size | Function | Output |
|---|---|---|---|---|
| Speaker Encoder | 3-Layer LSTM / ResNet | ~16.3 MB (encoder.pt) |
Extracts fixed 256d speaker identity vector from short audio | 256d Vector |
| Synthesizer | Tacotron2 Architecture | ~353.4 MB (synthesizer.pt) |
Synthesizes mel-spectrogram from text conditioned on speaker vector | 80-band Mel-Spectrogram |
| Vocoder | Wave-RNN / Autoregressive | ~51.4 MB (vocoder.pt) |
Reconstructs 16kHz time-domain audio waveform from mel-spectrogram | 16kHz PCM Waveform |
Real Time Voice Cloning Master/
โ
โโโ saved_models/ # Pre-trained Neural Network Weights
โ โโโ default/
โ โโโ encoder.pt # Speaker Encoder PyTorch Checkpoint (~16 MB)
โ โโโ synthesizer.pt # Tacotron Synthesizer PyTorch Checkpoint (~353 MB)
โ โโโ vocoder.pt # Wave-RNN Vocoder PyTorch Checkpoint (~51 MB)
โ
โโโ api_server.py # Flask REST API Server for HTTP Audio Requests
โโโ demo_cli.py # Command-Line Interface for Terminal Inference
โโโ demo_toolbox.py # PyQt5 Graphical Interface Toolbox
โ
โโโ encoder/ # Speaker Encoder Module (Embedding generation)
โโโ synthesizer/ # Tacotron Synthesizer Module (Text-to-Spectrogram)
โโโ vocoder/ # Wave-RNN Vocoder Module (Spectrogram-to-Audio)
โโโ toolbox/ # GUI Frontend Components & Visualizers (PyQt5)
โโโ utils/ # Audio Signal Processing & Helper Utilities
โ
โโโ requirements.txt # Python Package Dependencies
โโโ README.md # Primary Repository Documentation
โโโ DEPLOYMENT_GUIDE.md # Production Hosting & Deployment Manual
- OS: Windows 10/11, Linux (Ubuntu/Debian), macOS
- Python: Version 3.8 to 3.13
- FFmpeg: Required for decoding non-WAV formats (
.mp3,.m4a,.flac)
# Clone Repository
git clone https://github.com/Muzammal-Ikhlaq/VoiceClone-AI-Studio.git
cd VoiceClone-AI-Studio
# Create Python Virtual Environment
python -m venv voice_env
# Activate Environment
# Windows (PowerShell):
.\voice_env\Scripts\Activate.ps1
# Linux / macOS:
source voice_env/bin/activate
# Install Dependencies
pip install -r requirements.txtLaunch the interactive graphical user interface:
python demo_toolbox.pyTip
Use the GUI toolbox to record reference audio directly from your microphone, browse preset voices, visualize speaker embedding clusters, and listen to synthesized audio in real time.
Run inference interactively from your terminal:
python demo_cli.pyAvailable Flags:
--cpu: Force CPU inference even if GPU/CUDA is available.--no_sound: Disable audio playback during test run.
Start the HTTP REST API backend server:
python api_server.pyAPI Server listens by default on http://0.0.0.0:5000.
Accepts a reference audio file (.wav, .mp3, .m4a) and target text string, returning synthesized cloned audio .wav.
| Field | Type | Required | Description |
|---|---|---|---|
audio |
File | Yes | Speaker reference audio file (5-10 sec recommended) |
text |
String | Yes | Sentence/text to be synthesized in target voice |
curl -X POST http://localhost:5000/clone \
-F "audio=@speaker_sample.wav" \
-F "text=Hello! This is a real-time voice cloning API demonstration." \
--output cloned_output.wavimport requests
url = "http://localhost:5000/clone"
files = {"audio": open("speaker_sample.wav", "rb")}
data = {"text": "Hello world! Real-Time Voice Cloning is fully working."}
response = requests.post(url, files=files, data=data)
if response.status_code == 200:
with open("cloned_output.wav", "wb") as f:
f.write(response.content)
print("Cloned audio saved to cloned_output.wav")
else:
print("Error:", response.json())const fs = require('fs');
const axios = require('axios');
const FormData = require('form-data');
async function generateVoice() {
const form = new FormData();
form.append('audio', fs.createReadStream('speaker_sample.wav'));
form.append('text', 'Hello from Node.js backend integration!');
const res = await axios.post('http://localhost:5000/clone', form, {
headers: form.getHeaders(),
responseType: 'arraybuffer'
});
fs.writeFileSync('cloned_output.wav', res.data);
console.log('Audio saved successfully!');
}
generateVoice();| Environment | Encoder Speed | Synthesizer Speed | Vocoder Speed | Total Real-Time Factor (RTF) |
|---|---|---|---|---|
| NVIDIA GPU (CUDA) | < 0.05 sec |
~ 0.3 sec |
~ 0.5 sec |
~ 0.8x (Faster than real-time) |
| Multi-Core CPU | < 0.1 sec |
~ 1.2 sec |
~ 10-20 sec |
~ 2.5x |
Developed by: Muzammal Ikhlaq
For detailed production hosting instructions (Linux VPS, Nginx, Gunicorn, Systemd service, Docker containerization, and SSL setup), refer to DEPLOYMENT_GUIDE.md.
This project is licensed under the MIT License.