Skip to content

apekshyasharma/Voice_Cloning_System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

VoiceCloner

A web-based voice cloning application built with Flask and Coqui TTS (YourTTS). Record your voice, clone it, and generate text-to-speech with your cloned voice in multiple languages and emotions.

Features

  • Voice Recording: Record audio directly from your browser's microphone
  • Voice Cloning: Clone your voice using state-of-the-art YourTTS model
  • Text-to-Speech: Generate speech from text using your cloned voice
  • Multi-language Support: English, French, and Portuguese (Brazilian)
  • Emotion Control: Add emotional cues (happy, sad, calm, angry)
  • Task-specific Styles: Different speaking styles (assistant, storytelling, narration, translator)
  • Web Interface: Clean, responsive UI with tabbed interface
  • Audio Conversion: Automatic conversion of various audio formats to WAV
  • CORS Enabled: Supports cross-origin requests

πŸ“Έ User Interface Screenshots

Below are the key UI screens from the VoiceCloner web application:

πŸŽ™οΈ Speech-to-Speech (Record & Clone)

Speech to Speech UI


πŸ“ Text-to-Speech (Enter Text & Generate)

Text to Speech UI


πŸ› οΈ Text-to-Speech (Advanced Options)

Text to Speech UI 2

Installation

Prerequisites

  • Python 3.8+
  • FFmpeg (for audio processing)
  • Conda (recommended for managing dependencies)

Setup

  1. Clone the repository:

    git clone <repository-url>
    cd VoiceCloner
  2. Create a Conda environment:

    conda create -n voicecloner python=3.9
    conda activate voicecloner
  3. Install FFmpeg:

    conda install -c conda-forge ffmpeg
  4. Install Python dependencies:

    pip install -r requirements.txt
  5. Run the application:

    python app.py
  6. Open your browser and navigate to:

    http://localhost:5000
    

Usage

Web Interface

  1. Record Voice Tab:

    • Click "Start Recording" to record your voice
    • Click "Stop" to end recording
    • Select emotion and task style (optional)
    • Choose language
    • Click "Clone Voice" to generate cloned speech
  2. Type Text Tab:

    • Enter text to synthesize
    • Select emotion, task, and language
    • Click "Generate Voice" to create speech using your previously recorded voice

API Endpoints

POST /upload_audio

Upload and clone voice from recorded audio.

Parameters:

  • audio (file): Audio file (webm/ogg/wav)
  • text (string, optional): Text to synthesize (default: "Hello! This is your cloned voice.")
  • emotion (string, optional): Emotion cue (happy, sad, calm, angry)
  • task (string, optional): Task style (default, assistant, storytelling, narration, translator)
  • language (string, optional): Language code (en, fr-fr, pt-br)

Response:

{
  "ok": true,
  "audioUrl": "/outputs/cloned_abc123.wav"
}

POST /generate_text

Generate speech from text using the latest recorded reference voice.

Parameters:

  • text (string, required): Text to synthesize
  • emotion (string, optional): Emotion cue
  • task (string, optional): Task style
  • language (string, optional): Language code

Response:

{
  "ok": true,
  "audioUrl": "/outputs/tts_def456.wav"
}

GET /outputs/<filename>

Serve generated audio files.

Project Structure

VoiceCloner/
β”œβ”€β”€ app.py                 # Main Flask application
β”œβ”€β”€ requirements.txt       # Python dependencies
β”œβ”€β”€ voice_cloner/          # Main package
β”‚   β”œβ”€β”€ __init__.py       # Flask app factory
β”‚   β”œβ”€β”€ routes.py         # API routes and handlers
β”‚   β”œβ”€β”€ tts_model.py      # TTS model wrapper
β”‚   └── utils.py          # Audio processing utilities
β”œβ”€β”€ templates/             # Jinja2 templates
β”‚   └── index.html        # Main web interface
β”œβ”€β”€ static/               # Static assets (CSS, JS, images)
β”œβ”€β”€ uploads/              # Uploaded audio files
└── outputs/              # Generated audio files

Technical Details

TTS Model

  • Model: Coqui TTS YourTTS (tts_models/multilingual/multi-dataset/your_tts)
  • GPU Support: Disabled by default (set gpu=True in tts_model.py for GPU acceleration)
  • Supported Languages: English (en), French (fr-fr), Portuguese (pt-br)

Audio Processing

  • Input Formats: WebM, OGG, WAV, MP3, and other formats supported by FFmpeg
  • Output Format: WAV (16-bit, variable sample rate)
  • Conversion: Uses soundfile library with pydub fallback for unsupported formats

Dependencies

  • Flask: Web framework
  • Coqui TTS: Text-to-speech engine
  • Librosa: Audio processing
  • Soundfile: Audio I/O
  • PyDub: Audio format conversion
  • NumPy: Numerical computing
  • SciPy: Scientific computing
  • Transformers: Machine learning models

Browser Compatibility

  • Modern browsers with MediaRecorder API support
  • Chrome 47+, Firefox 25+, Safari 14+, Edge 79+

Configuration

Environment Variables

  • CONDA_PREFIX: Used to locate FFmpeg binaries in Conda environments

Model Configuration

Modify voice_cloner/tts_model.py to:

  • Change the TTS model
  • Enable GPU acceleration
  • Add support for more languages

Troubleshooting

Common Issues

  1. FFmpeg not found:

    conda install -c conda-forge ffmpeg
  2. Microphone permission denied:

    • Ensure HTTPS in production or localhost
    • Check browser permissions
  3. Model download fails:

    • Check internet connection
    • Ensure sufficient disk space (models are ~1GB)
  4. Audio conversion errors:

    • Install FFmpeg
    • Check audio file formats

Performance Tips

  • Use GPU acceleration for faster synthesis
  • Keep reference audio short (5-10 seconds recommended)
  • Use supported languages for best results

License

This project uses Coqui TTS, which is licensed under the Apache 2.0 License. See individual component licenses for details.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

Acknowledgments

About

A Flask-based web application for voice cloning and text-to-speech synthesis using Coqui TTS YourTTS. Record your voice directly from the browser, clone it with AI, and generate speech in multiple languages (English, French, Portuguese) with customizable emotions.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors