Aratako/T5Gemma-TTS

Multilingual TTS model with voice cloning and duration control, based on T5Gemma encoder-decoder LLM

What is T5Gemma-TTS?

T5Gemma-TTS is a text-to-speech (TTS) system — software that converts written text into spoken audio. It's built on a type of AI model called an Encoder-Decoder LLM (a large language model that first reads the input, then generates output step by step). The project provides both the code to train the model and the code to run it (inference).

What can it do?

  • Speaks three languages: English, Chinese, and Japanese.
  • Voice cloning: Given a short reference audio clip (and optionally its transcript), it can mimic that voice without any extra training — this is called zero-shot cloning.
  • Duration control: You can tell it how long the audio should be (in seconds). If you don't, it estimates a reasonable length based on the number of phonemes and language-specific pacing rules.
  • Batch generation: From the same input text, it can generate multiple different audio variations in parallel (via the web interface), so you can pick the best one.
  • Flexible training: You can train from scratch, fine-tune an existing model, or use LoRA (a lightweight fine-tuning method that updates only a small set of parameters).

How do you use it?

There are three ways to run inference:

  1. Command line — using a HuggingFace-hosted model:
    python inference_commandline_hf.py --model_dir Aratako/T5Gemma-TTS-2b-2b --target_text "Hello, this is a test."
    
  2. Command line — using a local .pth checkpoint (the project's own format).
  3. Gradio web UI — a browser interface with sliders for parameters like number of samples, and options for low-memory mode.

For voice cloning, you add --reference_speech path/to/audio.wav and optionally --reference_text (if you don't provide the transcript, the system auto-transcribes it using a Whisper model).

Installation and environment

The project is installed via git clone and pip install -r requirements.txt. For GPU use, you need to install PyTorch with CUDA first.

Tested environments (per the developer):

  • Linux + CUDA — works
  • Windows + CUDA via Docker — works
  • Apple Silicon (MPS) — works (tested on M4 Max MacBook Pro)

Known issue: On native Windows (not Docker), inference can be unstable — generation times may be inconsistent or it may hang. The cause is still under investigation. The README suggests using WSL2 or Docker as a workaround.

Memory options

  • Quantized models: Pre-quantized versions reduce GPU memory usage. The full model uses ~10.6 GB VRAM; an 8-bit quantized encoder version uses ~8.6 GB; a 4-bit version uses ~7.6 GB. Only the encoder is quantized — the decoder stays full precision to preserve audio quality. These require bitsandbytes and a CUDA GPU.
  • Low-VRAM flags: --cpu_codec moves the XCodec2 tokenizer to CPU (saves ~3.5 GB), --cpu_whisper moves Whisper to CPU (saves ~5 GB), and --low_vram enables both. These trade memory for slower first-run latency but don't change output quality.

Training

The README gives a general workflow:

  1. Data preprocessing — scripts convert raw audio datasets into text transcripts, audio tokens (via XCodec2), and train/validation manifests. An example is provided for the Emilia-YODAS English dataset.
  2. Training — shell scripts handle three scenarios: training from scratch (8 GPUs), full fine-tuning (8 GPUs), and LoRA fine-tuning (1 GPU).
  3. Model conversion — scripts convert .pth checkpoints to HuggingFace format, including merging LoRA adapters.

Key training parameters include the base model (google/t5gemma-2b-2b-ul2), learning rate, gradient accumulation steps, and LoRA rank.

Architecture and dependencies

The model builds on several existing pieces:

  • T5Gemma (Google) — the base language model
  • XCodec2 — an audio codec that converts audio into discrete tokens the model can work with (plus an anime-tuned variant used by default for better Japanese voice support)
  • VoiceStar — the architectural inspiration and base code

The project structure includes modules for the model itself (models/t5gemma.py with something called PM-RoPE), data loading, training infrastructure (distributed trainer, ScaledAdam optimizer), and HuggingFace export wrappers.

Limitations (stated in the README)

  • Not real-time: Autoregressive generation of audio tokens is slow, so it's unsuitable for low-latency applications.
  • Duration control is imperfect: Generated audio may not match the requested duration exactly, and even when it matches, pacing or naturalness may be off.
  • Audio quality varies: Performance depends on training data; voices, accents, or speaking styles underrepresented in the data may work less well.

License

  • Code: MIT License
  • Model weights: See the model card on HuggingFace for separate licensing details.

Quick facts

Aspect Detail
Languages English, Chinese, Japanese
Voice cloning Zero-shot from reference audio
Interfaces CLI, HuggingFace format, Gradio web UI
Training modes From scratch, full fine-tune, LoRA
VRAM range ~7.6 GB (4-bit) to ~10.6 GB (full)
Known issue Native Windows instability
Paper arXiv:2604.01760

All information above is drawn directly from the project's README. No features or facts were added beyond what the README states.

Related

  • Project
  • Project
  • Project
  • Project