Views
No views yet
1git clone https://github.com/pnnbao97/VieNeu-TTS.git
2cd VieNeu-TTS1# Mac OS
2brew install espeak
3
4# Ubuntu/Debian
5sudo apt install espeak
6
7# Arch Linux
8paru -S aur/espeak
9
10# Windows
11# Tải và cài đặt từ: https://github.com/espeak-ng/espeak-ng/releases
12# Mặc định cài vào: C:\Program Files\eSpeak NG\
13# Code sẽ tự động nhận diện đường dẫn nàyecho 'test' | espeak-ng -x -q --ipa -v en-us1# Cài đặt từ requirements.txt
2pip install -r requirements.txt
3
4# Hoặc sử dụng uv (nếu có pyproject.toml)
5uv pip install -r requirements.txt
6
7# Hoặc cài đặt từ pyproject.toml
8pip install -e .1# Xem hướng dẫn tại: https://pytorch.org/get-started/locally/
2pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 # CUDA 11.8VieNeuTTS/
├── vieneutts.py # Module chính chứa class VieNeuTTS
├── main.py # Script ví dụ sử dụng cơ bản
├── gradio_app.py # Ứng dụng Gradio để chạy web demo (local)
├── requirements.txt # Python dependencies
├── pyproject.toml # Project configuration (nếu dùng uv)
├── README.md # File này
├── sample/ # Thư mục chứa các file audio và text mẫu
│ ├── id_0001.wav/txt # Nam 1 - miền Nam
│ ├── id_0002.wav/txt # Nữ 1 - miền Nam
│ ├── id_0003.wav/txt # Nam 2 - miền Nam
│ ├── id_0004.wav/txt # Nữ 2 - miền Nam
│ ├── id_0005.wav/txt # Nam 3 - miền Nam
│ └── id_0007.wav/txt # Nam 4 - miền Nam
├── VieNeuTTS/ # Thư mục con (cho Hugging Face Spaces)
│ ├── app.py # Gradio app cho Spaces
│ └── vieneutts.py # Module VieNeuTTS (bản sao)
└── output_audio/ # Thư mục chứa kết quả (tự tạo khi chạy)1from vieneutts import VieNeuTTS
2import soundfile as sf
3import os
4
5# Văn bản cần tổng hợp
6input_texts = [
7 "Các khóa học trực tuyến đang giúp học sinh tiếp cận kiến thức mọi lúc mọi nơi.",
8 "Các nghiên cứu về bệnh Alzheimer cho thấy tác dụng tích cực của các bài tập trí não.",
9 "Một tiểu thuyết trinh thám hiện đại dẫn dắt độc giả qua những tình tiết phức tạp, bí ẩn.",
10]
11
12output_dir = "./output_audio"
13os.makedirs(output_dir, exist_ok=True)
14
15# Đường dẫn file tham chiếu
16# Nam miền Nam
17ref_audio_path = "./sample/id_0001.wav"
18ref_text_path = "./sample/id_0001.txt"
19# Nữ miền Nam
20# ref_audio_path = "./sample/id_0002.wav"
21# ref_text_path = "./sample/id_0002.txt"
22
23ref_text = open(ref_text_path, "r", encoding="utf-8").read()
24
25# Khởi tạo model
26tts = VieNeuTTS(
27 backbone_repo="pnnbao-ump/VieNeu-TTS",
28 backbone_device="cuda", # hoặc "cpu" nếu không có GPU
29 codec_repo="neuphonic/neucodec",
30 codec_device="cuda" # hoặc "cpu" nếu không có GPU
31)
32
33print("Encoding reference audio")
34ref_codes = tts.encode_reference(ref_audio_path)
35
36# Tổng hợp giọng nói cho nhiều văn bản
37for i, text in enumerate(input_texts, 1):
38 print(f"Generating audio for example {i}: {text}")
39 wav = tts.infer(text, ref_codes, ref_text)
40 output_path = os.path.join(output_dir, f"output_{i}.wav")
41 sf.write(output_path, wav, 24000)
42 print(f"Saved to {output_path}")python gradio_app.pyhttp://127.0.0.1:7860main.py cung cấp ví dụ tổng hợp nhiều văn bản cùng lúc:python main.pyoutput_audio/.main.py:sample/, có 6 giọng mẫu sẵn có:| File | Giới tính | Miền | Mô tả |
|---|---|---|---|
id_0001 | Nam | Miền Nam | Giọng nam 1 |
id_0002 | Nữ | Miền Nam | Giọng nữ 1 |
id_0003 | Nam | Miền Nam | Giọng nam 2 |
id_0004 | Nữ | Miền Nam | Giọng nữ 2 |
id_0005 | Nam | Miền Nam | Giọng nam 3 |
id_0007 | Nam | Miền Nam | Giọng nam 4 |
C:\Program Files\eSpeak NG\sudo apt install espeak hoặc sudo apt install espeak-ngbrew install espeak hoặc brew install espeak-ngbackbone_device="cpu" và codec_device="cpu"1@misc{vieneutts2025,
2 title={VieNeu-TTS: Vietnamese Text-to-Speech with Instant Voice Cloning},
3 author={Pham Nguyen Ngoc Bao},
4 year={2025},
5 publisher={Hugging Face},
6 howpublished={\url{https://huggingface.co/pnnbao-ump/VieNeu-TTS}}
7}1@misc{neuttsair2025,
2 title={NeuTTS Air: On-Device Speech Language Model with Instant Voice Cloning},
3 author={Neuphonic},
4 year={2025},
5 publisher={Hugging Face},
6 howpublished={\url{https://huggingface.co/neuphonic/neutts-air}}
7}git checkout -b feature/AmazingFeature)git commit -m 'Add some AmazingFeature')git push origin feature/AmazingFeature)