lukaszliniewicz / Pandrator

Pandrator aspires to be a user-friendly app with a graphical interface and a one-click installer that creates high-quality speech from text in multiple languages (audiobooks, speech synchronised with subtitles and more) using local models (XTTS, Silero or VoiceCraft), plus voice cloning, LLM pre-processing, RVC enhancement, and automatic evaluation
GNU Affero General Public License v3.0
292 stars 22 forks source link
audiobook audiobook-creator audiobook-maker audiobooks customtkinterprojects dubbing llm nisqa pdf-to-audio rvc silero subtitle-to-speech subtitle-to-voice text-processing text-to-speech tkinter-gui voice-cloning voicecraft xtts xttsv2

Icon

Pandrator, a GUI audiobook and dubbing generator with voice cloning and AI text optimisation

[!TIP] TL;DR: Pandrator is not an AI model itself, but a GUI framework for Text-to-Speech projects. It can generate audiobooks and dubbing by leveraging several AI tools and purpose-made workflows and algorithms. It works on Windows out of the box. It does work on Linux, but you have to perform a manual installation at the moment. The easiest way to use it is to download one of the precompiled archives - when you unzip them, use the launcher. They come in three versions, one with just XTTS (the recommended TTS model), one with XTTS, RVC and WhisperX (WhisperX is needed for dubbing), and one with Silero (the smallest model that works even on older CPUs). You can also use the launcher to install additional tools. For other installation options, look below. XTTS works best on an Nvidia GPU (with as little as 4GB of VRAM), though it is usable on a CPU.

Pandrator aspires to be easy to use and install - it has a one-click installer and a graphical user interface. It is a tool designed to perform two tasks:

It leverages the XTTS, Silero and VoiceCraft model(s) for text-to-speech conversion and voice cloning, enhanced by RVC_CLI for quality improvement and better voice cloning results, and NISQA for audio quality evaluation. Additionally, it incorporates Text Generation Webui's API for local LLM-based text pre-processing, enabling a wide range of text manipulations before audio generation.

[!NOTE] Please note that Pandrator is still in an alpha stage and I'm not an experienced developer (I'm a noob, in fact), so the code is far from perfect in terms of optimisation, features and reliability. Please keep this in mind and contribute, if you want to help me make it better.

UI Demonstration Image

Samples

The samples were generated using the minimal settings - no LLM text processing, RVC or TTS evaluation, and no sentences were regenerated. Both XTTS and Silero generations were faster than playback speed.

https://github.com/user-attachments/assets/1c763c94-c66b-4c22-a698-6c4bcf3e875d

https://github.com/lukaszliniewicz/Pandrator/assets/75737665/bbb10512-79ed-43ea-bee3-e271b605580e

https://github.com/lukaszliniewicz/Pandrator/assets/75737665/118f5b9c-641b-4edd-8ef6-178dd924a883

Dubbing sample, including translation (video source):

https://github.com/user-attachments/assets/1ba8068d-986e-4dec-a162-3b7cc49052f4

Requirements

Hardware

XTTS

It's likely that you will need at least 16GB of RAM, a reasonably modern CPU for CPU-only generation (which you can choose in the launcher), and ideally an NVIDIA GPU with 4 GB+ of VRAM for really good performance.

Silero

Silero runs on the CPU. It should perform well on almost all reasonably modern systems.

VoiceCraft

You can run VoiceCraft on a cpu, but generation will be very slow. To achieve meaningful acceleration with a GPU (Nvidia), you need one with at least 8GB of VRAM. If you have only 4GB, disable kv cache in advanced settings.

Dependencies

This project relies on several APIs and services (running locally) and libraries, notably:

Required

Optional

Installation

GUI Installer and Launcher (Windows)

Run pandrator_installer_launcher.exe with administrator priviliges. You will find it under Releases. The executable was created using pyinstaller from pandrator_installer_launcher.py in the repository.

The file may be flagged as a threat by antivirus software, so you may have to add it as an exception.

You can choose which TTS engines to install and whether to install the software that enabled RVC voice cloning (RVC_CLI). You may install new components later. The installer creates the Pandrator folder, installs winget, git, ffmpeg, C++ Build Tools and/or Calibre if not installed already and Miniconda, clones the XTTS Api Server respository, the Silero Api Server repository or the VoiceCraft API repository and the Pandrator repository, creates conda environments, installs dependencies and launches Pandrator and the server you chose. You may use the the Installer/Launcher to launch Pandrator and all the tools later.

If you want to perform the setup again, remove the Pandrator folder it created. Please allow at least a couple of minutes for the initial setup process to download models and install dependencies. Depending on the options you've chosen, it may take up to 25 minutes.

For additional functionality not yet included in the installer:

Please refer to the repositories linked under Dependencies for detailed installation instructions. Remember that the APIs must be running to make use of the functionalities they offer.

Manual Installation:

  1. Make sure that Python 3, git, calibre and ffmpeg are installed and in PATH.
  2. Install and run at least XTTS API Server, Silero API Server or VoiceCraft API Server.
  3. Clone this repository (git clone https://github.com/lukaszliniewicz/Pandrator.git).
  4. cd to the repository directory.
  5. Install requirements using pip install -r requirements.txt.
  6. Run python pandrator.py.

Features

Quick Start Guide

Basic Usage

If you don't want to use the additional functionalities, you have everything you need in the Session tab.

  1. Either create a new session or load an existing one (select a folder in Outputs to do that).
  2. Choose your .txt, .srt, .pdf or epub file. If you choose a PDF or EPUB file, a preview window will open with the extracted text. You may edit it (OCRed books often have poorly recognized text from the title page, for example). Files that contain a lot of text, regardless of format, can take a long time to finish preprocessing before generation begins. The GUI will freeze, but as long as there is processor activity, it's simply working. For whole books, expect 10m+ for preprocessing.
  3. Select the TTS server you want to use - XTTS, Silero or VoiceCraft - and the language from the dropdown (VoiceCraft currently supports only English).
  4. Choose the voice you want to use.
    1. XTTS, voices are short, 6-12s .wav files (22050hz sample rate, mono) stored in the tts_voices directory. The XTTS model uses the audio to clone the voice. It doesn't matter what language the sample is in, you will be able to generate speech in all supported languages, but the quality will be best if you provide a sample in your target language. You may use the sample one in the repository or upload your own. Please make sure that the audio is between 6 and 12s, mono, and the sample rate is 22050hz. You may use a tool like Audacity to prepare the files. The less noise, the better. You may use a tool like Resemble AI for denoising and/or enhancement of your samples on Hugging Face.
    2. Silero offers a number of voices for each language it supports. It doesn't support voice cloning. Simply select a voice from the dropdown after choosing the language.
    3. VoiceCraft works similarly to XTTS in that it clones the voice from a .wav sample. However, it needs both a properly formatted .wav file (mono, 16000hz) and a .txt file with the transcription of what is said in the sample. The files must have the same name (apart from the extension, of course). You need to upload them to tts_voices/VoiceCraft and you will be able to select them in the GUI. Currently only English is supported. If you generate with a new voice for the first time, the server will perform the alignment procedure, so the first sentence will be generated with a delay. This won't happen when you use that voice again.
  5. If you want, you can either slow down or speed up the generated audio (type in or choose a ratio, e.g. 1.1, which is 10% faster than generated; it may be especially useful for dubbing).
  6. If you chose an .srt file, you will be given the option to select a video file and one of its audio tracks to mix with the synchronized output, as well as weather you want to lower the volume of the original audio when subtitle audio is playing.
  7. Start the generation. You may stop and resume it later, or close the programme and load the session later.
  8. You can play back the generated sentences, also as a playlist, edit them (the text for regeneration), regenerate or remove individual ones.
  9. "Save Output" concatenates the sentences generated so far an encodes them as one file (default is .opus at 64k bitrate; you may change it in the Audio tab to .wav or .mp3).

General Audio Settings

  1. You can change the lenght of silence appended to the end of sentences and paragraphs.
  2. You can enable a fade-in and -out effect and set the duration.
  3. You can choose the output format and bitrate.

General Text Pre-Processing Settings

  1. You can disable/enable splitting long sentences and set the max lenght a text fragment sent for TTS generation may have (enabled by default; it tries to split sentences whose lenght exceeds the max lenght value; it looks for punctuation marks (, ; : -) and chooses the one closest to the midpoint of the sentence; if there are no punctuation marks, it looks for conjunctions like "and"); it performs this operation twice as some sentence fragments may still be too long after just one split.
  2. You can disable/enable appending short sentences (to preceding or following sentences; disabled by default, may perhaps improve the flow as the lenght of text fragments sent to the model is more uniform).
  3. Remove diacritics (useful when generating a text that contains many foreign words or transliterations from foreign alphabets, e.g. Japanese). Do not enable this if you generate in a language that needs diacritics, like German or Polish! The pronounciation will be wrong then.

LLM Pre-processing

RVC Quality Enhancement and Voice Cloning

NISQA TTS Evaluation

Contributing

Contributions, suggestions for improvements, and bug reports are most welcome!

Tips

To-do