TTS application with voice cloning capabilities from Darkest Dungeon game audio samples. Uses Coqui TTS (XTTS v2) to generate deep, narrator-style voice that matches the game's atmosphere.
- ✅ Voice Cloning from Darkest Dungeon audio samples
- ✅ Deep Voice Processing - Automatically deepens voice with pitch shifting and formant adjustment
- ✅ Web interface with Gradio (easy to use)
- ✅ CPU support (no GPU required)
- ✅ Automatic text splitting for long texts
- ✅ Automatic selection of best voice samples
- ✅ 100+ Darkest Dungeon-themed example texts shuffled on each app start
- ✅ Beautiful English UI focused on Darkest Dungeon atmosphere
- Python 3.10 hoặc cao hơn
- Hệ điều hành: Windows, Linux, hoặc macOS
- RAM: Tối thiểu 4GB (khuyến nghị 8GB+)
- Ổ cứng: ~5GB để lưu models và dependencies
cd Project_Sound_DDWindows:
.\venv\Scripts\Activate.ps1Linux/Mac:
source venv/bin/activateCách 1: Sử dụng script tự động (Khuyến nghị)
Windows PowerShell:
.\install_dependencies.ps1Method 2: Manual installation
pip install -e .
pip install bnnumerizer gruutLưu ý quan trọng:
- Một số packages (
gruut,jieba) cần được cài từ source để tránh lỗi missing files - Script
install_dependencies.ps1sẽ tự động xử lý điều này - Package
bnnumerizercó thể gặp vấn đề cài đặt. Nếu gặp lỗi, tạo file stub:- Tạo file
venv\Lib\site-packages\bnnumerizer.pyvới nội dung:def numerize(text): return text
- Tạo file
- Lần đầu tiên chạy sẽ tự động tải TTS model (~2GB), có thể mất vài phút.
Xử lý lỗi dependencies:
- Nếu gặp lỗi
ModuleNotFoundErrorvớigruuthoặcjieba, cài lại từ source:.\venv\Scripts\pip.exe install --force-reinstall --no-cache-dir gruut==2.2.3 .\venv\Scripts\pip.exe install --force-reinstall --no-cache-dir jieba
- Nếu gặp lỗi
cannot import name 'BeamSearchScorer' from 'transformers', downgrade transformers:.\venv\Scripts\pip.exe install "transformers>=4.33.0,<4.40.0"
- Nếu gặp lỗi
Weights only load failedhoặcweights_onlyvới PyTorch, downgrade PyTorch:.\venv\Scripts\pip.exe install "torch>=2.0.0,<2.6.0" "torchaudio>=2.0.0,<2.6.0"
python app.pyThen open your browser and navigate to: http://localhost:7860
English TTS (with voice cloning):
from src.voice_cloner import VoiceCloner
# Initialize voice cloner
cloner = VoiceCloner(sound_dir="Sound")
cloner.initialize()
# Generate audio from English text
audio = cloner.synthesize_simple(
text="Hello, this is a text-to-speech application with voice cloning.",
output_path="output.wav"
)The application automatically applies deep voice processing to make the narrator voice deeper and more atmospheric:
- Pitch Shifting: Lowers pitch by 4 semitones for a deeper sound
- Formant Shifting: Adjusts vocal tract characteristics for a deeper timbre
- Uses librosa for high-quality audio processing
Project_Sound_DD/
├── Sound/ # Thư mục chứa các file .wav mẫu (481 files)
├── src/
│ ├── __init__.py
│ ├── audio_processor.py # Xử lý và chuẩn hóa file âm thanh
│ ├── tts_engine.py # TTS engine với Coqui TTS
│ ├── text_processor.py # Xử lý văn bản tiếng Anh
│ └── voice_cloner.py # Module voice cloning chính
├── tests/ # Unit tests
├── app.py # Ứng dụng Gradio
├── pyproject.toml # Dependencies và cấu hình
└── README.md
- Model được tối ưu để chạy trên CPU
- Sử dụng threading giới hạn để tránh quá tải
- Tự động chia nhỏ văn bản dài
- Caching models để tái sử dụng
- Đảm bảo thư mục
Soundcó chứa các file.wav - Kiểm tra quyền truy cập file
- Kiểm tra kết nối internet (lần đầu cần tải model)
- Đảm bảo đã cài đặt đầy đủ dependencies
- Bình thường khi chạy trên CPU, mỗi câu có thể mất 10-30 giây
- Có thể giảm độ dài văn bản để tăng tốc
pytest tests/pip install -e ".[dev]"MIT License
Dự án phát triển cho Vietnamese TTS với voice cloning.
- Voice Cloning: Uses XTTS v2 model with voice cloning from Darkest Dungeon audio samples in the
Sounddirectory. - Deep Voice Processing: Automatically applies pitch shifting (-4 semitones) and formant adjustment to create a deep, narrator-style voice.
- Voice quality depends on the quality of sample files in the
Sounddirectory. - First-time use requires time to download and initialize the XTTS v2 model (~2GB).
- Examples are shuffled on each app start for variety.
- All examples are themed around Darkest Dungeon for an immersive experience.
The deep voice processing includes:
- Pitch Shifting: Lowers pitch using librosa's pitch_shift function
- Formant Shifting: Adjusts frequency spectrum for deeper vocal characteristics
- Automatic normalization to prevent clipping
- Maintains audio quality and naturalness
Adjust parameters in src/voice_cloner.py to customize the depth of voice:
pitch_shift_semitones: How much to lower pitch (default: -4.0)formant_shift: Formant adjustment factor (default: 0.88)