-
Notifications
You must be signed in to change notification settings - Fork 0
/
xenon.py
244 lines (188 loc) · 7.84 KB
/
xenon.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
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
from tkinter import *
from PIL import Image, ImageTk
import time
import subprocess
root = Tk()
root.title("XENON")
# root.wm_iconbitmap("xenon_icon.ico")
img = ImageTk.PhotoImage(Image.open('xenon_icon.ico'))
root.tk.call('wm', 'iconphoto', root._w, img)
gui_width = 600
gui_height = 400
root.geometry(f"{gui_width}x{gui_height}")
root.minsize(gui_width, gui_height)
root.maxsize(gui_width, gui_height)
heading = Label(root, text="XENON", font="Forte 40", fg="white", bg="#181818")
heading.place(x=200, y=10)
sub_heading = Label(root, text="The most advanced virtual assistant", font="lucida 15 bold", fg="white", bg="#181818")
sub_heading.place(x=125, y=70)
def start():
global output_screen
import pyttsx3
import speech_recognition as sr
import datetime
import wikipedia
import webbrowser
import os
import random
import pywhatkit as kit
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[0].id)
def speak(audio):
global output_screen
engine.say(audio)
engine.runAndWait()
def wishMe():
global output_screen
hour = int(datetime.datetime.now().hour)
if 0 <= hour < 12:
speak("Good Morning!")
elif 12 <= hour < 17:
speak("Good afternoon")
else:
speak("Good evening")
speak("I am Xenon! Please tell how may i help you")
def takeCommand():
global output_screen
r = sr.Recognizer()
with sr.Microphone() as source:
output_screen.insert(END, 'Listening...\n')
output_screen.update()
r.pause_threshold = 1
r.energy_threshold = 5000
audio = r.listen(source)
try:
output_screen.delete(1.0, END)
output_screen.insert(1.0, 'Recognizing...\n')
output_screen.update()
query = r.recognize_google(audio, language='en-in')
output_screen.insert(2.0, f"You said: {query}\n")
output_screen.update()
except Exception as e:
output_screen.insert(3.0, 'Say that again please...\n')
output_screen.update()
return "None"
return query
if __name__ == "__main__":
wishMe()
while True:
query = takeCommand().lower()
if 'wikipedia' in query:
speak("Searching Wikipedia...")
output_screen.delete(1.0, END)
output_screen.insert(4.0, 'Searching Wikipedia...\n')
output_screen.update()
query = query.replace("wikipedia", "")
results = wikipedia.summary(query, sentences=2)
speak("According to wikipedia")
output_screen.insert(5.0, f'According to Wikipedia: {results}\n')
output_screen.update()
speak(results)
elif 'open google' in query:
speak("Opening Google...")
webbrowser.open("google.com")
elif 'google' in query:
speak("Searching on Google...")
query = query.replace("google", "")
kit.search(query)
elif 'open youtube' in query:
speak("Opening Youtube...")
webbrowser.open("youtube.com")
elif 'play' in query:
speak("Playing on YouTube...")
query = query.replace("play", "")
kit.playonyt(query)
elif 'open twitter' in query:
speak("Opening Twitter...")
webbrowser.open("twitter.com")
elif 'open instagram' in query:
speak("Opening Instagram...")
webbrowser.open("instagram.com")
elif 'open facebook' in query:
speak("Opening Facebook...")
webbrowser.open("facebook.com")
elif 'open gmail' in query:
speak("Opening gmail...")
webbrowser.open("gmail.com")
elif 'open stack overflow' in query:
speak("Opening Stack Overflow...")
webbrowser.open("stackoverflow.com")
elif 'open omegle' in query:
speak("Opening omegle.com...")
webbrowser.open("omegle.com")
elif 'open quora' in query:
speak("Opening Quora.com...")
webbrowser.open("quora.com")
elif 'the time' in query:
strTime = datetime.datetime.now().strftime("%H:%M:%S")
speak(f"The time is {strTime}")
elif 'open notepad' in query:
speak("Opening notepad")
subprocess.call('notepad.exe')
elif 'open calculator' in query:
speak("Opening calculator")
subprocess.call('calc.exe')
elif 'open powerpoint' in query:
speak("Opening powerpoint")
powerpointPath = "C:\\Program Files\\Microsoft Office\\root\\Office16\\POWERPNT.EXE"
os.startfile(powerpointPath)
elif 'open excel' in query:
speak("Opening excel")
excelPath = "C:\\Program Files\\Microsoft Office\\root\\Office16\\EXCEL.EXE"
os.startfile(excelPath)
elif 'open word' in query:
speak("Opening Microsoft Word")
wordPath = "C:\Program Files\Microsoft Office\root\Office16\WINWORD.EXE"
os.startfile(wordPath)
elif 'how are you' in query:
speak("Thanks for asking, i am fine!")
elif 'you do' in query:
speak(
"I can open web for you or can make a wikipedia search. I can also play music or open some apps on your pc")
elif 'name' in query:
speak("I think i already mentioned it, but anyways, my name is xenon")
elif 'owner' in query:
speak("My owner is ronit. You can contact him on instagram @ronit_bhati_")
elif 'bye' in query:
speak("Thanks for using me, hope you had a good experience, bye bye!")
output_screen.delete(1.0, END)
output_screen.insert(6.0, 'Thanks for using me, hope you had a good experience, byee!\n')
output_screen.update()
time.sleep(3)
from sys import exit
exit()
elif 'exit' in query:
speak("Thanks for using me, hope you had a good experience, bye bye!")
output_screen.delete(1.0, END)
output_screen.insert(7.0, 'Thanks for using me, hope you had a good experience, byee!\n')
output_screen.update()
time.sleep(3)
from sys import exit
exit()
elif 'hello' in query:
speak("Hi, how you doin")
elif 'good' in query:
speak("Hope, you stay good always")
elif 'bustard' in query:
speak("Dont be so rude please")
elif 'hell' in query:
speak("Dont be so rude please")
elif 'kill' in query:
speak("Dont be so rude please")
elif 'murder' in query:
speak("Dont be so rude please")
else:
speak("")
logo_run = ImageTk.PhotoImage(Image.open("run.png"))
run = Button(root, image=logo_run, relief=RIDGE, command=start, width=100, height=50)
run.place(x=240, y=115)
def exit_it():
root.destroy()
quit_func = Button(root, text="Stop", command=exit_it, bg='#181818', fg="white")
quit_func.place(x=280, y=190)
output_screen = Text(root, height=8, font="lucida 13", fg="white", selectborderwidth=0)
output_screen.pack(side="bottom", fill=X, padx=20, pady=10)
output_screen.configure(bg='#181818')
root.configure(bg='#181818')
root.mainloop()