SoniTranslate

repository·main·Indexed 23 days ago

https://github.com/r3gm/sonitranslate

A web-based application for translating videos with synchronized audio using a Gradio-based UI. It supports transcription and translation across a wide array of languages, featuring a pipeline that includes speaker diarization, vocal refinement, and Text-to-Speech (TTS) engines like Piper and Coqui XTTS. The tool provides a comprehensive API for multilingual media and document conversion, supporting various output formats including subtitled MP4s, WAV/MP3 audio, and videobooks.

Tokens
8.7K
Snippets
19
Records
37
Agent score
79%

What's inside SoniTranslate

  1. Overview of SoniTranslate

    main
    SoniTranslate is a web application designed for video translation with synchronized audio. It provides a user-friendly interface built on the Gradio library, allowing users to translate videos into various supported languages while maintaining audio synchronization.
  2. Run SoniTranslate via Colab Runtime

    main

    You can run SoniTranslate using a Google Colab notebook, which provides a managed runtime environment. This is useful for users who do not want to set up a local environment.

    https://colab.research.google.com/github/R3gm/SoniTranslate/blob/main/SoniTranslate_Colab.ipynb
  3. Run SoniTranslate

    main

    To launch the SoniTranslate web interface:

    1. Activate the environment:
      conda activate sonitr
    2. Run the application script:
      python app_rvc.py
    3. Open your browser and navigate to the local URL displayed in the terminal (typically http://127.0.0.1:7860).
    conda activate sonitr
    python app_rvc.py
  4. Prerequisites for SoniTranslate installation

    main

    Before installing SoniTranslate, ensure the following requirements are met:

    1. NVIDIA Drivers: Install drivers for CUDA 11.8.0.
    2. Pyannote License: Create a Hugging Face account and accept the license agreements for:
      • https://huggingface.co/pyannote/speaker-diarization
      • https://huggingface.co/pyannote/segmentation
    3. Hugging Face Token: Create an Access Token on Hugging Face. Ensure you check "Read access to contents of all public gated repos you can access".
    4. Anaconda/Miniconda: Install for Python environment management.
    5. Git: Install Git (can be done via conda install -c anaconda git -y).
    6. FFmpeg: Required for multimedia processing. Install via conda install -y ffmpeg and verify with ffmpeg -h.
  5. Install optional TTS engines (Piper and Coqui XTTS)

    main

    You can extend SoniTranslate with additional Text-to-Speech capabilities:

    Piper TTS (Fast, local neural TTS):

    pip install -q piper-tts==1.2.0

    Coqui XTTS (Realistic voice cloning):

    pip install -q -r requirements_xtts.txt
    pip install -q TTS==0.21.1  --no-deps
    pip install -q piper-tts==1.2.0
    
    pip install -q -r requirements_xtts.txt
    pip install -q TTS==0.21.1  --no-deps
  6. Stop and Reset SoniTranslate

    main

    To stop the application, press Ctrl+C in the terminal. To deactivate the environment, run conda deactivate.

    If you need to perform a clean reinstall, delete the SoniTranslate folder and remove the Conda environment:

    conda deactivate
    conda env remove -n sonitr
  7. Install SoniTranslate locally

    main

    Follow these steps to set up the SoniTranslate environment (tested on Linux):

    1. Create and activate Conda environment:

      conda create -n sonitr python=3.10 -y
      conda activate sonitr
      python -m pip install pip==23.1.2 Setuptools==80.6.0
      conda install pytorch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 pytorch-cuda=11.8 -c pytorch -c nvidia
    2. Clone the repository:

      git clone https://github.com/r3gm/SoniTranslate.git
      cd SoniTranslate
    3. Install dependencies:

      pip install -r requirements_base.txt -v
      pip install -r requirements_extra.txt -v
      pip install onnxruntime-gpu
    conda create -n sonitr python=3.10 -y
    conda activate sonitr
    python -m pip install pip==23.1.2 Setuptools==80.6.0
    conda install pytorch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 pytorch-cuda=11.8 -c pytorch -c nvidia
    
    git clone https://github.com/r3gm/SoniTranslate.git
    cd SoniTranslate
    
    pip install -r requirements_base.txt -v
    pip install -r requirements_extra.txt -v
    pip install onnxruntime-gpu
  8. Install Optional TTS Engines (Coqui XTTS and Piper)

    main

    You can extend SoniTranslate with additional Text-to-Speech capabilities:

    Coqui XTTS (Voice cloning and realistic multilingual TTS):

    pip install -q -r requirements_xtts.txt
    pip install -q TTS==0.21.1  --no-deps

    Piper TTS (Fast, local neural TTS): Note: Windows support is experimental.

    pip install https://github.com/R3gm/piper-phonemize/releases/download/1.2.0/piper_phonemize-1.2.0-cp310-cp310-win_amd64.whl
    pip install sherpa-onnx==1.9.12
    pip install piper-tts==1.2.0 --no-deps
    # Coqui XTTS
    pip install -q -r requirements_xtts.txt
    pip install -q TTS==0.21.1  --no-deps
    
    # Piper TTS (Experimental on Windows)
    pip install https://github.com/R3gm/piper-phonemize/releases/download/1.2.0/piper_phonemize-1.2.0-cp310-cp310-win_amd64.whl
    pip install sherpa-onnx==1.9.12
    pip install piper-tts==1.2.0 --no-deps
  9. Run SoniTranslate via Web UI

    main

    To launch the Gradio-based web interface:

    1. Activate the environment:
      conda activate sonitr
    2. Set your Hugging Face token as an environment variable:
      export YOUR_HF_TOKEN="YOUR_HUGGING_FACE_TOKEN"
    3. Run the application:
      python app_rvc.py
    4. Open the provided local URL (typically http://127.0.0.1:7860) in your browser.
    conda activate sonitr
    export YOUR_HF_TOKEN="YOUR_HUGGING_FACE_TOKEN"
    python app_rvc.py
  10. Configure environment variables for Hugging Face and OpenAI

    main

    Instead of exporting variables every session, you can set them permanently within the Conda environment.

    Set Hugging Face Token:

    conda activate sonitr
    conda env config vars set YOUR_HF_TOKEN="YOUR_HUGGING_FACE_TOKEN_HERE"
    conda deactivate

    Set OpenAI API Key (for translation, TTS, or transcription):

    conda activate sonitr
    conda env config vars set OPENAI_API_KEY="your-api-key-here"
    conda deactivate
    conda activate sonitr
    conda env config vars set YOUR_HF_TOKEN="YOUR_HUGGING_FACE_TOKEN_HERE"
    conda deactivate
    
    conda activate sonitr
    conda env config vars set OPENAI_API_KEY="your-api-key-here"
    conda deactivate
  11. Prerequisites for Windows Installation

    main

    Before installing SoniTranslate on Windows, ensure the following requirements are met:

    1. Microsoft Visual C++ Build Tools: Install via the Visual Studio Installer. Select the "C++ build tools" workload and ensure "MSVCv142 - VS 2019 C++ x64/x86 build tools" and "Windows 10 SDK" (or Windows 11 SDK) are selected.
    2. NVIDIA Driver & CUDA: Verify your CUDA version by running nvidia-smi in Command Prompt. The CUDA Version must be at least 11.8. If it is lower, update your drivers via the NVIDIA website.
    3. Hugging Face Access:
    4. Software: Install Anaconda or Miniconda and Git.
  12. Install SoniTranslate on Windows

    main

    Follow these steps to set up the SoniTranslate environment using Conda:

    1. Create and prepare the environment:
      conda create -n sonitr python=3.10 -y
      conda activate sonitr
      python -m pip install pip==23.1.2 Setuptools==80.6.0
    2. Clone the repository:
      git clone https://github.com/r3gm/SoniTranslate.git
      cd SoniTranslate
    3. Install CUDA Toolkit 11.8.0:
      conda install -c "nvidia/label/cuda-11.8.0" cuda-toolkit -y
    4. Install PyTorch:
      conda install pytorch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 pytorch-cuda=11.8 -c pytorch -c nvidia -y
    5. Install core dependencies:
      pip install -r requirements_base.txt -v
      pip install -r requirements_extra.txt -v
      pip install onnxruntime-gpu
    6. Install FFmpeg:
      conda install -y ffmpeg
      Verify installation with ffmpeg -h.
    conda create -n sonitr python=3.10 -y
    conda activate sonitr
    python -m pip install pip==23.1.2 Setuptools==80.6.0
    
    git clone https://github.com/r3gm/SoniTranslate.git
    cd SoniTranslate
    
    conda install -c "nvidia/label/cuda-11.8.0" cuda-toolkit -y
    
    conda install pytorch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 pytorch-cuda=11.8 -c pytorch -c nvidia -y
    
    pip install -r requirements_base.txt -v
    pip install -r requirements_extra.txt -v
    pip install onnxruntime-gpu
    
    conda install -y ffmpeg