139_spanish-voice-trainer/test-scripts/test_voices.py

29 lines
1,000 B
Python
Raw Permalink Normal View History

# test_voices.py
import soundfile as sf
from kokoro_onnx import Kokoro
kokoro = Kokoro("kokoro-v1.0.onnx", "voices-v1.0.bin")
# Test phrases
#english_text = "Welcome to the Spanish voice trainer. Let's practice key phrases together."
#spanish_text = "Bienvenido al entrenador de voz en español. Practiquemos frases clave juntos."
english_text = "surname"
spanish_text = "apellido"
# Voices to test (English and Spanish presets)
voices_to_test = [
("af_bella", "en-us", english_text),
("af_nicole", "en-us", english_text),
("af_sky", "en-us", english_text),
("ef_dora", "es", spanish_text),
("em_alex", "es", spanish_text),
]
for voice, lang, text in voices_to_test:
print(f"Generating sample for {voice} ({lang})...")
samples, sample_rate = kokoro.create(text, voice=voice, speed=1.0, lang=lang)
filename = f"sample_{voice}.wav"
sf.write(filename, samples, sample_rate)
print("Done! You can play sample_af_bella.wav, sample_ef_dora.wav, etc. using afplay.")