- Created PIPER_TTS_INTEGRATION.md with complete integration summary - Added test_engine_selection.py for testing engine switching - Documented engine comparison, usage examples, and pitch guidelines - Listed all modified/created files and git commits - Included next steps for optional enhancements Task 26 completed: Piper TTS integration with engine selection UI
59 lines
1.7 KiB
Python
59 lines
1.7 KiB
Python
"""
|
|
Test script for TTS engine selection functionality.
|
|
"""
|
|
import asyncio
|
|
import sys
|
|
from services.unified_tts_service import UnifiedTTSService
|
|
|
|
|
|
async def test_engine_selection():
|
|
"""Test switching between TTS engines."""
|
|
print("Testing TTS Engine Selection\n" + "="*50)
|
|
|
|
# Initialize service
|
|
print("\n1. Initializing UnifiedTTSService...")
|
|
tts = UnifiedTTSService()
|
|
print(f" Default engine: {tts.engine_name}")
|
|
|
|
# Get available engines
|
|
print("\n2. Getting available engines...")
|
|
engines = tts.get_available_engines()
|
|
print(f" Available: {engines}")
|
|
|
|
# Get available voices
|
|
print("\n3. Getting available voices...")
|
|
voices = tts.get_available_voices()
|
|
for engine, voice_list in voices.items():
|
|
print(f" {engine}: {len(voice_list)} voices")
|
|
if voice_list:
|
|
print(f" Examples: {voice_list[:3]}")
|
|
|
|
# Test switching to Piper
|
|
print("\n4. Switching to Piper engine...")
|
|
try:
|
|
tts.set_engine('piper')
|
|
print(f" Current engine: {tts.engine_name}")
|
|
except Exception as e:
|
|
print(f" ⚠️ Error: {e}")
|
|
print(" Note: Piper may not be installed. Run ./install_piper.sh")
|
|
|
|
# Switch back to Kokoro
|
|
print("\n5. Switching back to Kokoro engine...")
|
|
tts.set_engine('kokoro')
|
|
print(f" Current engine: {tts.engine_name}")
|
|
|
|
# Test invalid engine
|
|
print("\n6. Testing invalid engine...")
|
|
try:
|
|
tts.set_engine('invalid')
|
|
print(" ❌ Should have raised error!")
|
|
except ValueError as e:
|
|
print(f" ✓ Correctly rejected: {e}")
|
|
|
|
print("\n" + "="*50)
|
|
print("✓ Engine selection tests completed!")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(test_engine_selection())
|