-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsource.py
More file actions
331 lines (274 loc) · 12 KB
/
source.py
File metadata and controls
331 lines (274 loc) · 12 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
import sys
import time # Keep this import
from PyQt6.QtWidgets import QApplication
# Remove duplicate "import time" statements
from password_auth_ui import password_auth # ✅ Import password authentication function
from ui import JarvisUI
from speech import listen, speak
from ocr import perform_ocr
from schedule_manager import add_schedule, view_schedule
from face_auth import capture_face, verify_face
from voice_auth import verify_voice
from system_control import *
from text_generator import generate_text
import ollama
from automation import send_email_voice, read_unread_emails_voice, send_whatsapp_voice, send_telegram_voice
from translator import translate_text, speak_translated_text
from task_manager import add_task, view_tasks
import speech_recognition as sr
def get_ollama_response(command):
"""Generate response using Ollama AI"""
if not isinstance(command, str):
command = str(command)
response = ollama.chat(model="mistral:latest", messages=[{"role": "user", "content": command}])
return response
def listen_for_jarvis():
"""Continuously listen for 'Jarvis' wake word."""
recognizer = sr.Recognizer()
with sr.Microphone() as source:
print("Waiting for wake word 'Jarvis'...")
while True:
try:
audio = recognizer.listen(source)
text = recognizer.recognize_google(audio).lower()
if "jarvis" in text:
print("✅ Wake word detected! Listening for command...")
speak("Yes, how can I assist?")
return listen()
except sr.UnknownValueError:
continue
except sr.RequestError:
print("Speech recognition service error.")
def main():
print("\U0001F680 Running Main Function...")
speak("Initializing system...")
# 🔹 Run Password Authentication Before Anything
if not password_auth():
print("❌ Access Denied! Exiting...")
sys.exit(1) # ✅ Corrected indentation
print("✅ Password Verified! Proceeding...")
app = QApplication(sys.argv)
jarvis_ui = JarvisUI()
jarvis_ui.show()
# Loading Animation Before Face Authentication
jarvis_ui.start_waveform_animation()
time.sleep(3) # Simulate loading time
jarvis_ui.stop_waveform_animation() # Fixed typo (was `stot_waveform_animation()`)
if not capture_face() or not verify_face():
speak("Face verification failed! Exiting.")
jarvis_ui.update_status("❌ Access Denied!")
return
jarvis_ui.stop_face_scan_effect()
jarvis_ui.update_status("✅ Face Verified!")
speak("Face verification successful!")
jarvis_ui.start_face_scan_effect()
jarvis_ui.update_status("\U0001F4F7 Scanning Face...")
# Face Authentication with UI Effects
# Voice Authentication with Animated Waveform
jarvis_ui.start_waveform_animation()
jarvis_ui.update_status("\U0001F3A4 Say your password...")
if not verify_voice():
speak("Voice verification failed! Access denied.")
jarvis_ui.update_status("❌ Access Denied!")
return
jarvis_ui.stop_waveform_animation()
jarvis_ui.update_status("✅ Authentication successful!")
speak("Authentication successful! Welcome, Shiva Mani.")
# System Control Dashboard (Live CPU, RAM Updates)
jarvis_ui.enable_system_dashboard()
while True:
command = listen_for_jarvis()
if command:
jarvis_ui.update_status(f"🗣️ {command}")
if "exit" in command:
speak("Goodbye! Shutting down.")
break
elif "shutdown" in command:
shutdown()
elif "restart" in command:
restart()
elif "sleep" in command:
sleep()
elif "lock" in command:
lock()
elif "volume up" in command:
adjust_volume('up')
elif "volume down" in command:
adjust_volume('down')
elif "mute" in command:
mute()
elif "take screenshot" in command:
take_screenshot()
elif "empty recycle bin" in command:
empty_recycle_bin()
elif "create folder" in command:
create_folder("NewFolder", "C:\\")
elif "delete folder" in command:
delete_folder("C:\\NewFolder")
elif "open folder" in command:
open_folder("C:\\")
elif "search file" in command:
print(search_file("test.txt", "C:\\"))
elif "copy file" in command:
copy_file("source.txt", "destination.txt")
elif "extract zip" in command:
extract_zip("archive.zip", "C:\\extracted")
elif "wifi on" in command:
wifi_on_off(True)
elif "wifi off" in command:
wifi_on_off(False)
elif "check speed" in command:
print(check_speed())
elif "get ip" in command:
print(get_ip())
elif "flush dns" in command:
flush_dns()
elif "battery status" in command:
print(battery_status())
elif "task manager" in command:
print(task_manager())
elif "system uptime" in command:
print(system_uptime())
elif "cpu usage" in command:
print(get_cpu_ram_usage())
elif "list processes" in command:
print(list_running_processes())
elif "kill process" in command:
print(kill_process("notepad.exe"))
elif "play media" in command:
play_pause_media()
elif "next track" in command:
next_track()
elif "previous track" in command:
previous_track()
elif "set wallpaper" in command:
set_wallpaper("C:\\wallpaper.jpg")
elif "open website" in command:
open_website("https://google.com")
elif "google search" in command:
google_search("Python tutorials")
elif "send email" in command:
send_email("test@example.com", "Subject", "Body")
elif "open whatsapp" in command:
open_whatsapp()
elif "ocr" in command:
image_path = input("Enter image path: ")
text = perform_ocr(image_path)
print("Extracted Text:\n", text)
elif "add schedule" in command:
event = input("Enter event: ")
event_time = input("Enter time (e.g., 10:00 AM): ") # Fixed variable name
print(add_schedule(event, event_time))
elif "view schedule" in command:
print("Your Schedule:\n", view_schedule())
elif "generate text" in command:
speak("Please enter your prompt.")
prompt = input("Enter your prompt: ")
result = generate_text(prompt, "ollama")
print(result)
speak("Text generation complete.")
elif "send email" in command:
send_email_voice()
elif "read emails" in command:
read_unread_emails_voice()
elif "send WhatsApp message" in command:
send_whatsapp_voice()
elif "translate" in command:
speak("Please say the text you want to translate.")
text = listen()
speak("Which language should I translate to?")
target_language = listen()
translated_text = translate_text(text, target_language)
speak(f"Translation: {translated_text}")
speak_translated_text(translated_text, target_language)
elif "send Telegram message" in command:
send_telegram_voice()
else:
response = get_ollama_response(command)
speak(response)
jarvis_ui.update_status(f"🤖 {response}")
sys.exit(app.exec())
if __name__ == "__main__":
main()
# import sys
# from PyQt6.QtWidgets import QApplication
# from ui import JarvisUI
# from speech import listen, speak
# from face_auth import capture_face, verify_face
# from voice_auth import verify_voice
# from system_control import execute_command
# from password_auth_ui import password_auth
# from text_generator import generate_text
# from image_generator import generate_image
# import ollama # Importing Ollama for AI conversation
# def get_ollama_response(prompt):
# """Generate response using Ollama AI."""
# response = ollama.chat(model="llama3", messages=[{"role": "user", "content": prompt}])
# return response['message']['content']
# def image_generation():
# """Runs image generation when user commands."""
# speak("Please select an image generation method.")
# method = input("Select method (stable_diffusion / huggingface / leonardo): ").strip()
# speak("Please enter your image prompt.")
# prompt = input("Enter image prompt: ")
# result = generate_image(prompt, method)
# print(result)
# speak("Image generation complete.")
# def text_generation():
# """Runs text generation when user commands."""
# speak("Please select a text generation method.")
# method = input("Select method (ollama / huggingface): ").strip()
# speak("Please enter your prompt.")
# prompt = input("Enter your prompt: ")
# result = generate_text(prompt, method)
# print(result)
# speak("Text generation complete.")
# def main():
# print("\U0001F680 Running Main Function...")
# speak("Initializing system...")
# print("\U0001F512 Please authenticate using your password...")
# speak("Please authenticate using your password.")
# if not password_auth():
# print("❌ Access Denied! Exiting...")
# speak("Access denied! Exiting system.")
# return
# print("✅ Password Verified. Initializing system...")
# speak("Password verified. Initializing system.")
# print("\U0001F5A5️ Starting UI...")
# app = QApplication(sys.argv)
# jarvis_ui = JarvisUI()
# jarvis_ui.show()
# jarvis_ui.update_status("\U0001F4F7 Scanning Face...")
# if not capture_face() or not verify_face():
# speak("Face verification failed! Exiting.")
# jarvis_ui.update_status("❌ Access Denied!")
# return
# jarvis_ui.update_status("✅ Face Verified!")
# speak("Face verification successful!")
# jarvis_ui.update_status("\U0001F3A4 Say your password...")
# if not verify_voice():
# speak("Voice verification failed! Access denied.")
# jarvis_ui.update_status("❌ Access Denied!")
# return
# jarvis_ui.update_status("✅ Authentication successful!")
# speak("Authentication successful! Welcome, Shiva Mani.")
# while True:
# jarvis_ui.update_status("\U0001F3A4 Listening for command...")
# command = listen().lower()
# jarvis_ui.update_status(f"🗣️ {command}")
# if "exit" in command:
# speak("Goodbye! Shutting down.")
# break
# if execute_command(command):
# continue
# elif "generate image" in command:
# image_generation()
# elif "generate text" in command:
# text_generation()
# else:
# response = get_ollama_response(command)
# speak(response)
# jarvis_ui.update_status(f"🤖 {response}")
# sys.exit(app.exec())
# if __name__ == "__main__":
# main()