A Flask-based API for voice cloning and text-to-speech generation using the OuteTTS library.
IMPORTANT: This application requires a GPU (NVIDIA L4 or greater recommended) for optimal performance. Voice cloning is computationally intensive and will be significantly slower without adequate GPU resources.
This project enables you to:
- Generate voice maps from audio samples
- List available voice maps
- Generate speech using cloned voices with custom text
The system uses Google Cloud Storage for storing voice maps and generated audio files, making them accessible via signed URLs.
└── hrushik-reddy-voice-clone/
├── README.md
├── api.py
├── postman.json
└── requirements.txt
- Voice Map Generation: Create voice fingerprints from audio samples
- Voice Cloning: Generate speech with cloned voices using custom text
- Cloud Storage: Store and retrieve voice maps and generated audio using Google Cloud Storage
- API Interface: Easy-to-use REST API endpoints
- Python 3.8+
- NVIDIA GPU (L4 or greater recommended)
- CUDA and cuDNN properly installed
- Google Cloud credentials
- OuteTTS library
- Flask and additional dependencies (see
requirements.txt)
- Clone the repository:
git clone https://github.com/hrushik-reddy/voice-clone.git
cd hrushik-reddy-voice-clone- Install dependencies:
pip install -r requirements.txt- Set up Google Cloud credentials:
export GOOGLE_APPLICATION_CREDENTIALS="path/to/your/service-account-file.json"Alternatively, place your credentials file at var/secrets/google/proposals-creds.json
- Create necessary directories:
mkdir -p voice_mapspython api.pyThe server will start on http://0.0.0.0:5000
Create a voice map from an audio sample:
POST /generate_voicemap
Request Body:
{
"signed_url": "https://storage.googleapis.com/your-audio-file.mp3",
"speaker_name": "custom_speaker_name"
}Response:
{
"status": "success",
"speaker_name": "custom_speaker_name",
"voice_map_path": "voice_maps/custom_speaker_name_voice_map.json",
"voice_map_url": "https://storage.googleapis.com/...",
"time_taken": "2.45 s"
}Get a list of all available voice maps:
GET /list_voice_maps
Response:
{
"status": "success",
"voice_maps": [
{
"speaker_name": "custom_speaker_name",
"file_path": "voice_maps/custom_speaker_name_voice_map.json"
}
]
}Generate speech using a cloned voice:
POST /generate_voice
Request Body:
{
"speaker_name": "custom_speaker_name",
"text": "Hello, this is a test of voice generation."
}Response:
{
"status": "success",
"speaker_name": "custom_speaker_name",
"audio_url": "https://storage.googleapis.com/...",
"time_taken": "1.23 s"
}A Postman collection is included in the repository (postman.json) to help you test the API endpoints. Import this collection into Postman to get started quickly.
- Audio Processing: Uses PyDub to process and normalize audio files
- Voice Cloning: Leverages OuteTTS for voice cloning and speech generation
- Storage: Uses Google Cloud Storage for cloud-based file storage
- API Framework: Built with Flask for lightweight API endpoints
- Audio samples are trimmed to 20 seconds for voice map generation
- Requires proper Google Cloud credentials with access to the specified bucket
Hrushik Reddy