-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAutomation_Brain.py
More file actions
103 lines (93 loc) · 3.7 KB
/
Copy pathAutomation_Brain.py
File metadata and controls
103 lines (93 loc) · 3.7 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
from Automation.open_App import open_App
from Automation.Web_Open import openweb
import pyautogui as gui
from Automation.Play_Music_YT import play_music_on_youtube
from TextToSpeech import Fast_DF_TTS
from Automation.playmusic_Sfy import play_music_on_spotify
from Automation.Battery import check_percentage
from os import getcwd
import time
from Automation.tab_automation import perform_browser_action
from Automation.Youtube_play_back import perform_media_action
import pywhatkit
from Automation.scrool_system import perform_scroll_action
import threading
from TextToSpeech.Fast_DF_TTS import speak
def play():
gui.press("space")
def search_google(text):
pywhatkit.search(text)
def close():
gui.hotkey('alt','f4')
def clear_file():
with open(f"{getcwd()}\\input.txt","w") as file:
file.truncate(0)
def Open_Brain(text):
if "website" in text:
text = text.replace("open","").replace("website","").strip()
t1 = threading.Thread(target=speak,args=(f"Navigating {text} website",))
t2 = threading.Thread(target=openweb,args=(text,))
else:
text = text.replace("open","").replace("app","").strip()
t1 = threading.Thread(target=speak,args=(f"Navigating {text} application",))
t2 = threading.Thread(target=open_App,args=(text,))
t1.start()
t2.start()
t1.join()
t2.join()
def Auto_main_brain(text):
try:
if text.startswith("open"):
Open_Brain(text)
elif "close" in text:
close()
elif "play music" in text or "play music on youtube" in text:
Fast_DF_TTS.speak("Which song do you want to play, sir?")
clear_file()
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.endswith("song"):
play_music_on_youtube(output_text)
break
elif "play some music" in text or "play music on spotify" in text:
Fast_DF_TTS.speak("Which song do you want to play, sir?")
clear_file()
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.endswith("song"):
play_music_on_spotify(output_text)
break
elif "check battery percentage" in text or "check battery level" in text:
check_percentage()
elif text.startswith("search"):
search_text = text.replace("search", "").strip()
t1 = threading.Thread(target=speak, args=(f"Doing research about {search_text}",))
t2 = threading.Thread(target=search_google, args=(search_text,))
t1.start()
t2.start()
t1.join()
t2.join()
time.sleep(0.5)
gui.press("enter")
elif "search in google" in text:
search_text = text.replace("search in google", "").strip()
t1 = threading.Thread(target=speak, args=(f"Performing research about {search_text} in Google search engine",))
t2 = threading.Thread(target=search_google, args=(search_text,))
t1.start()
t2.start()
t1.join()
t2.join()
else:
perform_browser_action(text)
perform_media_action(text)
perform_scroll_action(text)
except Exception as e:
print("Error: " + str(e))