Training high-quality TTS models requires significant GPU resources and compute time. If you find this model useful, please consider supporting the development:
VieNeu-TTS supports long-form text synthesis (multiple sentences, paragraphs, or entire articles).
For efficient sentence splitting, text normalization, and streaming playback, please refer to the example script in the repository:
1git clone https://github.com/pnnbao97/VieNeu-TTS.git
2cd VieNeu-TTS
3uv sync
1from vieneu_tts import VieNeuTTS
2import soundfile as sf
3import torch
4import os
5
6device = "cuda" if torch.cuda.is_available() else "cpu"
7
8input_texts = [
9 "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. Giáo viên sử dụng video, bài tập tương tác và thảo luận trực tuyến để nâng cao hiệu quả học tập.",
10
11 "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 và chế độ dinh dưỡng lành mạnh, giúp giảm tốc độ suy giảm trí nhớ ở người cao tuổi.",
12
13 "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, kết hợp yếu tố tâm lý sâu sắc khiến người đọc luôn hồi hộp theo dõi diễn biến câu chuyện.",
14
15 "Các nhà khoa học nghiên cứu gen người phát hiện những đột biến mới liên quan đến bệnh di truyền. Điều này giúp nâng cao khả năng chẩn đoán và điều trị.",
16]
17
18output_dir = "./output_audio"
19os.makedirs(output_dir, exist_ok=True)
20
21def main(backbone="pnnbao-ump/VieNeu-TTS", codec="neuphonic/neucodec"):
22 """
23 In the sample directory, there are wav files and txt files with matching names.
24 These are pre-prepared reference files for testing with Vietnamese names:
25 - Bình (nam miền Bắc) - Male, North accent
26 - Tuyên (nam miền Bắc) - Male, North accent
27 - Nguyên (nam miền Nam) - Male, South accent
28 - Sơn (nam miền Nam) - Male, South accent
29 - Vĩnh (nam miền Nam) - Male, South accent
30 - Hương (nữ miền Bắc) - Female, North accent
31 - Ly (nữ miền Bắc) - Female, North accent
32 - Ngọc (nữ miền Bắc) - Female, North accent
33 - Đoan (nữ miền Nam) - Female, South accent
34 - Dung (nữ miền Nam) - Female, South accent
35
36 Note: The model can clone any voice you provide (with corresponding text).
37 However, quality may not match the sample files. For best results, finetune
38 the model on your target voice. See finetune guide at:
39 https://github.com/pnnbao-ump/VieNeuTTS/blob/main/finetune.ipynb
40 """
41 # Male voice (South accent)
42 ref_audio_path = "./sample/Vĩnh (nam miền Nam).wav"
43 ref_text_path = "./sample/Vĩnh (nam miền Nam).txt"
44
45 # Female voice (South accent) - uncomment to use
46 # ref_audio_path = "./sample/Đoan (nữ miền Nam).wav"
47 # ref_text_path = "./sample/Đoan (nữ miền Nam).txt"
48
49 ref_text_raw = open(ref_text_path, "r", encoding="utf-8").read()
50
51 if not ref_audio_path or not ref_text_raw:
52 print("No reference audio or text provided.")
53 return None
54
55 # Initialize VieNeuTTS-1000h
56 tts = VieNeuTTS(
57 backbone_repo=backbone,
58 backbone_device=device,
59 codec_repo=codec,
60 codec_device=device
61 )
62
63 print("Encoding reference audio...")
64 ref_codes = tts.encode_reference(ref_audio_path)
65
66 # Generate speech for all input texts
67 for i, text in enumerate(input_texts, 1):
68 print(f"Generating audio {i}/{len(input_texts)}: {text[:50]}...")
69 wav = tts.infer(text, ref_codes, ref_text_raw)
70 output_path = os.path.join(output_dir, f"output_{i}.wav")
71 sf.write(output_path, wav, 24000)
72 print(f"✓ Saved to {output_path}")
73
74if __name__ == "__main__":
75 main()
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}