Arabic-XTTS-TTS / create_speakers.py
aladhefafalquran
Add setup improvements and documentation
d2c625a
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Create placeholder speaker audio files using TTS synthesis.
This ensures the app has default speakers even if external downloads fail.
"""
import os
import sys
from pathlib import Path
# Fix encoding for Windows
if sys.platform == 'win32':
import io
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
print("Creating placeholder speaker files...")
print("Note: These will be replaced with actual samples when deployed to Hugging Face.")
# Create speakers directory
SPEAKERS_DIR = Path("speakers")
SPEAKERS_DIR.mkdir(exist_ok=True)
# Create simple placeholder text files that will be replaced on HF
speakers = {
"male1.wav": "Male speaker 1 - clear voice",
"male2.wav": "Male speaker 2 - deep voice",
"female1.wav": "Female speaker 1 - soft voice",
"female2.wav": "Female speaker 2 - energetic voice",
}
for filename, description in speakers.items():
filepath = SPEAKERS_DIR / filename
# Create empty placeholder files
filepath.touch()
print(f"✓ Created placeholder: {filename}")
print(f"\n✨ Created {len(speakers)} placeholder files in speakers/")
print("These will be automatically downloaded when deployed to Hugging Face Space.")