Hướng dẫn cài Coqui TTS
- Cài python
Python Releases for Windows
The official home of the Python Programming Language


Bật cmd chạy 2 lệnh sau:
python -m pip install --upgrade pip
pip install --upgrade virtualenv
- Cài TTS
GitHub - coqui-ai/TTS: 🐸💬 - a deep learning toolkit for Text-to-Speech, battle-tested in research and production
🐸💬 - a deep learning toolkit for Text-to-Speech, battle-tested in research and production - coqui-ai/TTS

Ở trang chủ khuyên dùng python >= 3.9, < 3.12 nên mình chọn 3.11
Để cho tiện bạn nên tạo một môi trường ảo.
mkdir coqui_tts
cd coqui_tts
virtualenv py311 --python=python311
.\py311\Scripts\activate

Giờ thì chạy lệnh install như ở trang chủ:
pip install TTS


Nếu gặp lỗi trên bạn vào cái link này rồi cài:


- CUDA
Nếu bạn dùng card NVDIA thì cài thêm cái này để dùng CUDA cho nhanh. Không thì bỏ qua, lúc này sẽ chạy bằng CPU chậm hơn.
Bạn cũng cần cài lại torch.
pip uninstall torch
pip install torch --index-url https://download.pytorch.org/whl/cu118

CUDA Toolkit 12.1 Downloads
Get the latest feature updates to NVIDIA’s proprietary compute stack.

- Chạy thử
Tạo folder output
mkdir output
Tạo một file test.py
import torch
from TTS.api import TTS
text = """ a deep learning toolkit for Text-to-Speech, battle-tested in research and production """
# Get device
device = "cuda" if torch.cuda.is_available() else "cpu"
print(device)
# List available 🐸TTS models
tts = TTS("tts_models/en/ljspeech/fast_pitch").to(device)
tts.tts_to_file(text, file_path="output/output.wav")
Chạy thử
python test.py


Output
0:00
/6.026304
Bạn có thể thử các model khác ở đây
tts --list_models
