Enhance model building process and update README for Windows setup

- Added functionality to download additional required files, including config.json, during model initialization in models.py.
- Improved module import process for better clarity and organization.
- Included a test for the phonemizer to ensure functionality.
- Updated README to provide specific instructions for enabling Developer Mode or running Python as Administrator on Windows for optimal performance and symlink support.
This commit is contained in:
Pierre Bruno
2025-01-16 16:32:05 +01:00
parent 3b842a2d93
commit 65090f811a
2 changed files with 22 additions and 0 deletions

View File

@@ -44,6 +44,23 @@ The project has been updated with:
- Linux: `sudo apt-get install ffmpeg`
- macOS: `brew install ffmpeg`
### Windows-Specific Requirements
For optimal performance on Windows, you should either:
1. Enable Developer Mode:
- Open Windows Settings
- Navigate to System > Developer settings
- Turn on Developer Mode
OR
2. Run Python as Administrator:
- Right-click your terminal (PowerShell/Command Prompt)
- Select "Run as administrator"
- Run the commands from there
This is needed for proper symlink support in the Hugging Face cache system.
If you skip this, the system will still work but may use more disk space.
## Dependencies
```txt

View File

@@ -127,12 +127,15 @@ def build_model(model_file, device='cpu'):
setup_espeak()
repo_id = "hexgrad/Kokoro-82M"
# Download all required files
model_path = hf_hub_download(repo_id=repo_id, filename="kokoro-v0_19.pth")
kokoro_py = hf_hub_download(repo_id=repo_id, filename="kokoro.py")
models_py = hf_hub_download(repo_id=repo_id, filename="models.py")
istftnet_py = hf_hub_download(repo_id=repo_id, filename="istftnet.py")
plbert_py = hf_hub_download(repo_id=repo_id, filename="plbert.py")
config_json = hf_hub_download(repo_id=repo_id, filename="config.json")
# Import required modules
print("Importing plbert module...")
plbert_module = import_module_from_path("plbert", plbert_py)
print("Importing istftnet module...")
@@ -142,10 +145,12 @@ def build_model(model_file, device='cpu'):
print("Importing kokoro module...")
kokoro_module = import_module_from_path("kokoro", kokoro_py)
# Test phonemizer
from phonemizer import phonemize
test_phonemes = phonemize("Hello")
print(f"Phonemizer test successful: 'Hello' -> {test_phonemes}")
# Build model
print("Building model...")
model = models_module.build_model(model_path, device)
print(f"Model loaded successfully on {device}")