-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple_voice_test.py
More file actions
86 lines (68 loc) · 2.61 KB
/
simple_voice_test.py
File metadata and controls
86 lines (68 loc) · 2.61 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
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env python3
"""
Simple Interactive Voice Chat Test for Autumn AI Assistant
"""
import asyncio
import sys
import os
from pathlib import Path
# Add project root to path
sys.path.append(os.getcwd())
from core.kokoro_tts import KokoroTTSEngine
async def simple_voice_chat():
"""Simple interactive voice chat test."""
print("🍂 Autumn's Voice Chat Test")
print("=" * 30)
print("🎵 Initializing voice system...")
# Initialize TTS engine
engine = KokoroTTSEngine(device="auto")
success = await engine.initialize()
if not success:
print("❌ Failed to initialize voice system")
return
print(f"✅ Voice system ready!")
print(f"🔥 Using ONNX: {engine.use_onnx}")
print(f"🎭 Device: {engine.device}")
print()
print("Type messages for Autumn to speak!")
print("Commands: 'quit' to exit, emotions: neutral, friendly, happy, calm, serious")
print()
current_emotion = "friendly"
while True:
try:
# Get user input
user_input = input(f"[{current_emotion}] Enter text: ").strip()
if user_input.lower() in ['quit', 'exit', 'bye']:
print("🍂 Goodbye!")
await engine.speak("Goodbye! Take care!", emotion="friendly")
break
# Check for emotion change
emotions = ['neutral', 'friendly', 'happy', 'calm', 'serious']
if user_input.lower() in emotions:
current_emotion = user_input.lower()
print(f"🎭 Voice emotion changed to: {current_emotion}")
await engine.speak(f"Voice emotion changed to {current_emotion}", emotion=current_emotion)
continue
if not user_input:
continue
print(f"🎵 Speaking with emotion: {current_emotion}")
# Generate and play speech
success = await engine.speak(user_input, emotion=current_emotion)
if success:
print("✅ Speech completed!")
else:
print("❌ Speech failed!")
except KeyboardInterrupt:
print("\n👋 Goodbye!")
break
except Exception as e:
print(f"❌ Error: {e}")
await engine.shutdown()
print("🔊 Voice system shut down.")
if __name__ == "__main__":
try:
asyncio.run(simple_voice_chat())
except KeyboardInterrupt:
print("\n👋 Test interrupted. Goodbye!")
except Exception as e:
print(f"❌ Test failed: {e}")