-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtempCodeRunnerFile.py
More file actions
66 lines (54 loc) · 2.57 KB
/
tempCodeRunnerFile.py
File metadata and controls
66 lines (54 loc) · 2.57 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
from voice.speech_handler import VoiceEngine
from ai.gemini_handler import GeminiAI
from utils.config import WAKE_WORD
from utils.real_time import get_real_time
from utils.timer import Timer # NEW: Timer functionality
from utils.todo import ToDoList # NEW: To-Do list functionality
class Assistant:
def __init__(self):
self.voice = VoiceEngine()
self.ai = GeminiAI()
self.timer = Timer() # NEW: Initialize timer
self.todo = ToDoList() # NEW: Initialize to-do list
def run(self):
active_session = False
while True:
user_input = self.voice.listen().strip().lower() # Convert to lowercase
if not active_session:
if WAKE_WORD in user_input:
active_session = True
self.voice.speak("Hello boss!, How can I help you?")
continue
else:
if "exit" in user_input:
self.voice.speak("Goodbye!")
active_session = False
continue
# NEW: Timer functionality
if "set a timer" in user_input or "timer" in user_input:
self.voice.speak("For how many minutes?")
duration = self.voice.listen().strip()
self.timer.start_timer(duration)
# NEW: To-Do list functionality
elif "add to my to-do list" in user_input:
self.voice.speak("What task should I add?")
task = self.voice.listen().strip()
response = self.todo.add_task(task)
self.voice.speak(response)
elif "view my to-do list" in user_input:
response = self.todo.view_tasks()
self.voice.speak(response)
elif "clear my to-do list" in user_input:
response = self.todo.clear_tasks()
self.voice.speak(response)
# Existing functionality: Time/date queries
real_time_response = get_real_time(user_input)
if real_time_response:
self.voice.speak(real_time_response)
# Existing functionality: Default to Gemini
else:
response = self.ai.generate_response(user_input)
self.voice.speak(response)
if __name__ == "__main__":
assistant = Assistant()
assistant.run()