Skip to content
SIVA-RAJAPublic

About

VOICE CLONING

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GenVoice

GenVoice is a web application for voice cloning and text-to-speech generation using the XTTS v2 model. It features a three-tier architecture with a simple vanilla frontend, a Django backend API for managing voice samples and tasks, and a dedicated FastAPI microservice for AI model inference.

Architecture

The system is separated into three distinct components to ensure scalability, ease of development, and clear separation of concerns.

  1. Frontend (Vanilla HTML/JS/CSS)

    • Location: frontend/
    • Role: Provides the user interface for uploading/recording voice samples and requesting text-to-speech generation.
    • Decisions: Built without modern frontend frameworks (like React/Vue) to keep it lightweight and easy to serve. Uses native web APIs (fetch, MediaRecorder) for core functionality. Communicates solely with the Django Backend via REST API.
  2. Backend (Django / Django REST Framework)

    • Location: backend/
    • Role: Acts as the main orchestrator and state manager. It exposes RESTful APIs to the frontend, manages the database for voice samples (VoiceSample) and generated speeches (GeneratedSpeech), and handles file storage (media/).
    • Decisions: Django was chosen for its robust ORM and built-in features (like admin and migrations), accelerating development. When a text-to-speech request is received, it forwards the task and audio file to the XTTS Microservice synchronously rather than running the heavy ML model itself. This ensures the web server remains responsive.
  3. XTTS Microservice (FastAPI)

    • Location: xtts_server/
    • Role: A dedicated inference service running the Coqui TTS (XTTS v2) model.
    • Decisions: Running the ML model in a separate FastAPI service prevents the Django backend from becoming bottlenecked by heavy inference tasks and allows the ML component to be scaled independently or hosted on specialized GPU instances. It exposes a single /generate endpoint that converts audio files, runs the model on the text, and returns the generated speech audio.

Setup Instructions

Prerequisites

  • Python 3.9+
  • (Optional but recommended) CUDA-compatible GPU for faster XTTS inference
  • ffmpeg or librosa/soundfile system dependencies for audio processing

1. XTTS Server (Microservice)

Navigate to the xtts_server directory and set up the environment:

cd xtts_server
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Run the FastAPI server:

uvicorn app:app --host 0.0.0.0 --port 5000

Note: On the first request, the XTTS v2 model will be downloaded automatically (this may take a few minutes).

2. Django Backend

Navigate to the backend directory and set up the environment:

cd backend
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Set up environment variables by creating a .env file based on .env.example:

cp .env.example .env

Ensure the XTTS_URL in .env points to your running XTTS server (e.g., http://localhost:8000/generate) and a database URL is provided (e.g., PostgreSQL or SQLite).

Run migrations and start the server:

python manage.py makemigrations
python manage.py migrate
python manage.py runserver 8000

3. Frontend

The frontend consists of static files. You can serve it using any simple static file server. For example, using Python's built-in HTTP server:

cd frontend
python -m http.server 5500

Note: Update GenVoice.API_BASE in frontend/js/api.js to point to your Django backend URL (e.g., http://localhost:8080/api) if it currently points to a different deployment URL (like ngrok).

Workflows

1. Voice Sample Upload: User uploads or records audio in the frontend -> Frontend POSTs to Django /api/samples/ -> Django saves the file in media/ and records metadata in the database.

2. Speech Generation: User inputs text, selects a voice, and a language in the frontend -> Frontend POSTs to Django /api/speeches/ -> Django fetches the voice sample and calls the XTTS FastAPI service with the text and audio file -> XTTS service loads the ML model, clones the voice, and returns a generated WAV file -> Django saves this output audio and returns its URL to the frontend.

About

VOICE CLONING

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages