-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_tts.py
More file actions
executable file
·74 lines (57 loc) · 1.77 KB
/
Copy pathtest_tts.py
File metadata and controls
executable file
·74 lines (57 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python3
"""
Quick test script for TTS abstraction layer
Tests both pyttsx3 and piperSpeak engines
"""
import sys
from pathlib import Path
# Add parent directory to path for imports
sys.path.insert(0, str(Path(__file__).parent.parent))
from config import get_config
from tts_manager import create_tts_engine
def test_tts():
"""Test TTS engine initialization and speech"""
print("=" * 60)
print("TTS Abstraction Layer Test")
print("=" * 60)
# Load config
config = get_config()
print(f"\nConfiguration loaded")
print(f" TTS_ENGINE: {getattr(config, 'TTS_ENGINE', 'not set')}")
# Create TTS engine
print(f"\nCreating TTS engine...")
tts = create_tts_engine(config)
print(f" Engine type: {type(tts).__name__}")
# Initialize
print(f"\nInitializing TTS engine...")
success = tts.initialize()
if not success:
print("❌ TTS initialization failed!")
return False
print("✅ TTS engine initialized successfully")
# Test speech
print(f"\nTesting speech output...")
test_text = "Hello, this is a test of the text to speech abstraction layer."
print(f" Speaking: '{test_text}'")
success = tts.speak(test_text)
if not success:
print("❌ Speech failed!")
return False
print("✅ Speech completed successfully")
# Cleanup
print(f"\nCleaning up...")
tts.cleanup()
print("✅ Cleanup complete")
print("\n" + "=" * 60)
print("All tests passed! ✅")
print("=" * 60)
return True
if __name__ == "__main__":
try:
success = test_tts()
sys.exit(0 if success else 1)
except Exception as e:
print(f"\n❌ Test failed with error: {e}")
import traceback
traceback.print_exc()
sys.exit(1)