AI4Bharat Indic-TTS

repository·master·Indexed 18 days ago

https://github.com/ai4bharat/indic-tts

A text-to-speech system providing state-of-the-art models for 15 major Indian languages, including Assamese, Bengali, Hindi, Tamil, and Telugu. It utilizes a unified architecture based on FastPitch acoustic models and HiFi-GAN V1 vocoders. The repository includes tools for local inference, hosting a REST API server via uvicorn, deploying to Azure Machine Learning using Triton server, and training models from datasets formatted in LJSpeech style.

Tokens
11.2K
Snippets
40
Records
49
Agent score
64%

What's inside Indic-TTS

  1. Organize language checkpoints for deployment

    master

    To optimize GPU RAM usage, models are grouped by language families. Place your language-specific checkpoint folders in the corresponding directory structure before deployment:

    • North-Indian (Indo-Aryan) languages (as, bn, gu, hi, mr, or, pa, raj): Place in inference/checkpoints/indo-aryan/checkpoints
    • South-Indian (Dravidian) languages (kn, ml, ta, te): Place in inference/checkpoints/dravidian/checkpoints
    • Miscellaneous languages (en, brx, mni): Place in inference/checkpoints/misc/checkpoints
  2. Set up the Azure Machine Learning (AML) environment

    master

    Before deploying, navigate to the Triton server directory and set the required environment variables for your Azure resource group, workspace, and Docker registry. You must also ensure that any relevant .yml configuration files are updated to match these values.

    cd inference/triton_server
    
    export RESOURCE_GROUP=Dhruva-prod
    export WORKSPACE_NAME=dhruva--central-india
    export DOCKER_REGISTRY=dhruvaprod
  3. Run the Triton server container

    master

    Start the Triton server using the tts_triton image. Ensure you provide sufficient shared memory (--shm-size=256m), enable GPU access (--gpus=1), and mount your local checkpoints/ directory to /models/checkpoints inside the container so the server can access the models. The server exposes port 8000.

    docker run --shm-size=256m --gpus=1 --rm -v ${PWD}/checkpoints/:/models/checkpoints -p 8000:8000 -t tts_triton
  4. Push the Triton Docker image to Azure Container Registry

    master

    To make the Triton server image available for deployment, tag the local tts_triton image with your registry's URI and push it to the Azure Container Registry (ACR).

    az acr login --name $DOCKER_REGISTRY
    docker tag tts_triton $DOCKER_REGISTRY.azurecr.io/tts/triton-tts-coqui:latest
    docker push $DOCKER_REGISTRY.azurecr.io/tts/triton-tts-coqui:latest
  5. Test online inference with client.py

    master

    To verify the deployment:

    1. Retrieve the endpoint domain (exclude https:// and trailing /) and the authentication key from the 'Consume' tab in Azure ML Studio.
    2. Configure client.py with the following settings:
      • Set ENABLE_SSL = True
      • Set ENDPOINT_URL to your domain.
      • Set the Authorization value inside HTTP_HEADERS using your key.
    3. Execute the client script.
    # client.py configuration steps
    ENABLE_SSL = True
    ENDPOINT_URL = "your-endpoint-domain"
    HTTP_HEADERS = {"Authorization": "your-auth-key"}
    
    # Run via terminal:
    # python3 client.py
  6. Set up AI4Bharat-TTS Inference environment

    master

    To use the AI4Bharat-TTS inference models, ensure you have Python 3.9+ installed. Follow these steps to prepare your environment:

    1. Install System Dependencies (Linux only): Navigate to the inference directory and install the required system libraries using apt-get.

    2. Install Python Dependencies: Install the necessary machine learning and utility packages using pip.

    3. Download and Prepare Models: Download the model checkpoints from the official releases. Create a directory named checkpoints in your project root and unzip the downloaded files there.

    # 1. System dependencies (Linux)
    cd inference
    sudo apt-get install libsndfile1-dev ffmpeg enchant
    
    # 2. Python dependencies
    pip install -r requirements-ml.txt requirements-utils.txt
    
    # 3. Model setup
    mkdir checkpoints
    # [Download and unzip models into the checkpoints/ folder]
  7. Install Indic-TTS via Environment Setup

    master

    To set up the Indic-TTS environment, follow these steps to install system dependencies, create a Conda environment, and install the required Python packages (PyTorch, Trainer, and TTS).

    1. System Dependencies

    Install the necessary system libraries using apt-get:

    sudo apt-get install libsndfile1-dev ffmpeg enchant

    2. Conda Environment

    Create and activate a new Conda environment named tts-env:

    conda create -n tts-env
    conda activate tts-env

    3. Install PyTorch

    Install PyTorch with CUDA 11.3 support:

    pip3 install -U torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113

    4. Install Trainer

    Clone the Trainer repository and install it in editable mode with all dependencies:

    git clone https://github.com/gokulkarthik/Trainer 
    cd Trainer
    pip3 install -e .[all]
    cd ..

    Note: If you are manually copying files instead of cloning, ensure you apply the specific fixes mentioned in the repository documentation for wandb_logger.py, trainer.py, and distribute.py.

    5. Install TTS

    Clone the TTS repository and install it in editable mode with all dependencies:

    git clone https://github.com/gokulkarthik/TTS 
    cd TTS
    pip3 install -e .[all]
    cd ..

    6. Final Requirements

    Install any remaining requirements from the project's requirements file:

    pip3 install -r requirements.txt
    # 1. Create environment
    sudo apt-get install libsndfile1-dev ffmpeg enchant
    conda create -n tts-env
    conda activate tts-env
    
    # 2. Setup PyTorch
    pip3 install -U torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113
    
    # 3. Setup Trainer
    git clone https://github.com/gokulkarthik/Trainer 
    cd Trainer
    pip3 install -e .[all]
    cd ..
    
    # 4. Setup TTS
    git clone https://github.com/gokulkarthik/TTS 
    cd TTS
    pip3 install -e .[all]
    cd ..
    
    # 5. Install other requirements
    pip3 install -r requirements.txt
  8. Prepare IndicTTS data for training

    master

    Before training, you must prepare your dataset using the provided preprocessing notebooks:

    1. Format Dataset: Convert the IndicTTS dataset into the LJSpeech format using preprocessing/FormatDatasets.ipynb.
    2. Analyze Dataset: Verify the suitability of the dataset for TTS using preprocessing/AnalyzeDataset.ipynb.