-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathco_brain.py
More file actions
148 lines (125 loc) · 5.9 KB
/
Copy pathco_brain.py
File metadata and controls
148 lines (125 loc) · 5.9 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
from Automation.Automation_Brain import Auto_main_brain,clear_file
#from NetHyTechSTT.listen import listen
from Speech_Recognition.speech import listen
from TextToSpeech.Fast_DF_TTS import speak
import threading
from Data.DLG_Data import online_dlg,offline_dlg
import random
from Automation.Battery import battery_Alert
from Time_Operations.brain import input_manage,input_manage_Alam
from Brain.brain import Main_Brain
from Features.create_file import create_file
from Vision.Vbrain import *
#from Vision.MVbrain import *
from Weather_Check.check_weather import get_weather_by_address
from Whatsapp_automation.wa import send_msg_wa
from TextToImage.gen_image import generate_image
from Features.mike_health import mike_health
from Features.speaker_health import speaker_health_test
from Features.br_persentage import check_br_persentage
from Features.set_br import set_brightness_windows
from Features.set_get_volume import *
from Features.check_running_app import *
from Features.find_my_ip import find_my_ip
numbers = ["1:","2:","3:","4:","5:","6:","7:","8:","9:"]
spl_numbers = ["11:","12:"]
ran_online_dlg = random.choice(online_dlg)
ran_offline_dlg = random.choice(offline_dlg)
def check_inputs():
output_text = ""
while True:
with open("input.txt","r") as file:
input_text = file.read().lower()
if input_text != output_text:
output_text = input_text
if output_text.startswith("tell me"):
output_text = output_text.replace(" p.m.","PM")
output_text = output_text.replace(" a.m.","AM")
if "11:" in output_text or "12:" in output_text:
input_manage(output_text)
clear_file()
else:
for number in numbers:
if number in output_text:
output_text = output_text.replace(number,f"0{number}")
input_manage(output_text)
clear_file()
elif output_text.startswith("set alarm"):
output_text = output_text.replace(" p.m.","PM")
output_text = output_text.replace(" a.m.","AM")
if "11:" in output_text or "12:" in output_text:
input_manage_Alam(output_text)
clear_file()
else:
for number in numbers:
if number in output_text:
output_text = output_text.replace(number,f"0{number}")
input_manage_Alam(output_text)
clear_file()
elif "jarvis" in output_text:
f = open('log.txt','a')
f.write('\n'+'You : '+ output_text)
response = Main_Brain(output_text)
f.write('\n'+'jarvis : '+ response)
speak(response)
elif output_text.startswith("create"):
if "file" in output_text:
create_file(output_text)
elif "what is this" in output_text or "what can you see" in output_text:
image_path = "captured_image.png"
if capture_image_and_save(image_path):
encoded_image = encode_image_to_base64(image_path)
answer = vision_brain(encoded_image)
speak(answer)
elif "what is in front of mobile camera" in output_text or "what can you see use mobile camera" in output_text:
image_path = "captured_image.png"
if capture_image_and_save(image_path):
encoded_image = encode_image_to_base64(image_path)
answer = vision_brain(encoded_image)
speak(answer)
elif "check weather" in output_text:
text = output_text.replace("check weather in","")
ans = get_weather_by_address(text)
speak(ans)
elif "send message on whatsapp" in output_text:
send_msg_wa()
elif "generate image" in output_text:
text = output_text.replace("generate image","")
text = text.strip()
generate_image(text)
speak("image generated successfully")
elif "find my ip" in output_text:
ip_address = find_my_ip()
speak(f"Your IP address is {ip_address}")
elif "check mike" in output_text or "check mike health" in output_text or "check microphone" in output_text:
mike_health()
elif "check speaker health" in output_text or "check speaker" in output_text:
speaker_health_test()
elif "check brightness percentage" in output_text:
check_br_persentage()
elif "set brightness percentage" in output_text:
try:
set = output_text.replace("set brightness percentage to", "").strip()
set_brightness_windows(int(set))
except ValueError:
speak("Please provide a valid brightness percentage.")
elif "check volume level" in output_text:
get_volume_windows()
elif "set volume level " in output_text:
set = output_text.replace("set volume level","")
set = set.replace("%","")
set_volume_windows(int(set))
elif "check running application" in output_text:
check_running_app()
else:
Auto_main_brain(output_text)
def Jarvis():
clear_file()
t1 = threading.Thread(target=listen)
t2 = threading.Thread(target=check_inputs)
t1.start()
t2.start()
t1.join()
t2.join()
if __name__ == "__main__":
Jarvis()