-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.py
More file actions
71 lines (60 loc) · 1.93 KB
/
Copy pathmain.py
File metadata and controls
71 lines (60 loc) · 1.93 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
#!/usr/bin/env python3
"""
Empathic Voice Companion - Main Application
Streamlined version using the new Streaming Architecture.
"""
import sys
import logging
import signal
import time
from pathlib import Path
# Add src to path
sys.path.insert(0, str(Path(__file__).parent / "src"))
from src.utils.config import config
from src.core.orchestrator import StreamOrchestrator
from src.core.async_orchestrator import AsyncStreamOrchestrator
# Configure logging
logging.basicConfig(
level=getattr(logging, config.get('logging.level', 'INFO')),
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[
logging.StreamHandler(),
logging.FileHandler(config.get('logging.file', 'logs/empathic_voice.log'))
]
)
logger = logging.getLogger(__name__)
def main():
"""Main entry point."""
print("\n🚀 Starting TUNDA (Streaming Mode)...")
print("🎤 Listening for voice input...")
print("🛑 Press Ctrl+C to stop\n")
mode = config.get("orchestrator.mode", "threaded")
orchestrator = AsyncStreamOrchestrator() if mode == "async" else StreamOrchestrator()
def signal_handler(signum, frame):
print("\n👋 Stopping...")
if mode == "async":
orchestrator.stop_sync()
else:
orchestrator.stop()
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
try:
if mode == "async":
import asyncio
async def runner():
await orchestrator.start()
while True:
await asyncio.sleep(1.0)
asyncio.run(runner())
else:
orchestrator.start()
# Keep main thread alive
while True:
time.sleep(1.0)
except Exception as e:
logger.error(f"Application error: {e}")
print(f"❌ Error: {e}")
orchestrator.stop()
sys.exit(1)
if __name__ == "__main__":
main()