-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
39 lines (29 loc) · 1022 Bytes
/
app.py
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
# Main app
# import Libs
import os
import sys
import asyncio
from dotenv import load_dotenv
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "src")))
# Import components
from components.voice_handler import VoiceHandler
from components.chat_bot import Chatbot
from components.command_processor import CommandProcessor
async def main():
# Load environment variables
load_dotenv()
api_key = os.getenv("GEMINI_API_KEY")
# Init Components
voice_handler = VoiceHandler()
chatbot = Chatbot(api_key=api_key)
command_processor = CommandProcessor(voice_handler, chatbot)
# Chào người dùng
voice_handler.speak("What can I help with?")
while True:
command = await voice_handler.listen()
if command != "none":
should_continue = await command_processor.process_command(command)
if not should_continue:
break
if __name__ == "__main__":
asyncio.run(main())