# VieNeu-TTS

> On-device Vietnamese text-to-speech with instant voice cloning, 48 kHz audio and real-time CPU inference

- Category: Multimodal Generation / Audio, Music & Voice
- Language: Python
- Licence: Apache-2.0
- Repository: https://github.com/pnnbao97/VieNeu-TTS
- Website: https://www.vieneu.io
- Canonical page: https://ai-tldr.dev/tools/vieneu-tts/

## In short

VieNeu-TTS is an open-source text-to-speech toolkit built for Vietnamese, with English code-switching. It sits in the Audio, Music & Voice category of the Multimodal Generation tools and is open-source, written in Python and licensed Apache-2.0. To get started: install the SDK.

## Overview

VieNeu-TTS is an open-source text-to-speech toolkit built for Vietnamese, with English code-switching. It ships as a Python SDK (`pip install vieneu`), a Gradio web UI, and an OpenAI-compatible streaming server, so you can turn Vietnamese text into speech on your own machine instead of calling a cloud service. The default v3 Turbo engine outputs 48 kHz audio and includes 25 preset voices spanning Northern, Central and Southern accents.

The minimal install is torch-free: on a CPU the whole pipeline runs on ONNX Runtime, and on a CUDA machine the same API switches to a PyTorch engine that batches requests automatically. Beyond plain synthesis it clones a voice from a 3–8 second reference clip (with automatic denoising), accepts inline emotion cues such as `[cười]` (chuckle) and `[thở dài]` (sigh), streams audio frame by frame, and supports LoRA fine-tuning of a single voice on one consumer GPU. A smaller v3 Nano model trades quality for speed on weak CPUs and edge boards.

The repository holds the open-source engine and a simplified demo; the maintainer notes that the separate VieNeu-TTS v4 model and app features such as dubbing and audiobooks are proprietary and offered through vieneu.io rather than this repo.

## What it does

- Python SDK with `infer`, `infer_batch` and `infer_stream`, running torch-free on CPU via ONNX Runtime or batched on a CUDA GPU with the same API
- Instant voice cloning from a 3–8 second clip, with automatic denoising and `add_voice` to save a cloned voice for reuse by name
- 25 built-in preset voices across Northern, Central and Southern Vietnamese accents, plus experimental inline emotion cues
- OpenAI-compatible `POST /v1/audio/speech` streaming server, runnable from the repo or via Docker CPU/GPU profiles, usable from the OpenAI SDK, Pipecat or LiveKit
- Gradio web UI (`vieneu-web`) for trying voices and cloning without writing code
- LoRA fine-tuning scripts to train one custom voice or reading style from about 10–30 minutes of clean audio

## Getting started

Install the SDK from PyPI for scripting, or clone the repo with uv to get the web UI and the streaming API server. The commands below are taken from the project README.

1. Install the SDK

   The default install is torch-free and runs on CPU through ONNX Runtime. On Linux with an NVIDIA GPU, `pip install "vieneu[cuda]"` adds the PyTorch engine.

```bash
pip install vieneu
```

2. Generate speech with a preset voice

   Create a `Vieneu` instance (v3 Turbo by default), synthesize text with a built-in voice and save a WAV file.

```python
from vieneu import Vieneu

vieneu = Vieneu()
audio = vieneu.infer("Xin chào các bạn!", voice="Mai Anh")
vieneu.save(audio, "output.wav")
```

3. Clone a voice from a short clip

   Pass a 3–8 second reference recording; it is cleaned up automatically before cloning.

```python
audio = vieneu.infer(
    "Đây là giọng được nhân bản tức thì.",
    ref_audio="my_voice.wav",   # a 3–8s reference clip
    denoise=True,
)
vieneu.save(audio, "cloned.wav")
```

4. Run the web UI

   Clone the repository, install dependencies with uv (add `--extra cuda` for GPU), then open http://127.0.0.1:7860.

```bash
git clone https://github.com/pnnbao97/VieNeu-TTS.git
cd VieNeu-TTS
uv sync
uv run vieneu-web
```

5. Serve an OpenAI-compatible speech API

   Start the streaming server from the repo or with Docker; it listens on http://localhost:8000/v1/audio/speech and works with the OpenAI SDK by changing `base_url`.

```bash
uv run python -m apps.openai_speech
# or, with Docker:
docker compose -f docker/docker-compose.yml --profile api-cpu up
```

## When to use it

- Add Vietnamese speech to an app or product that must run offline or on a CPU-only machine
- Power a Vietnamese voice agent through an OpenAI-compatible streaming endpoint with Pipecat or LiveKit
- Narrate articles, lessons or audiobooks in a cloned or preset Vietnamese voice
- Fine-tune a dedicated voice with LoRA when cloning alone does not match a speaker closely enough
