-
Notifications
You must be signed in to change notification settings - Fork 30
/
EDITH.py
111 lines (100 loc) · 3.22 KB
/
EDITH.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
import pyttsx3
import datetime
import time
import speech_recognition as sr
import win32api, sys, os
import wikipedia
import webbrowser
engine = pyttsx3.init('sapi5')
voices = engine.getProperty("voices")
for i in voices:
print(i)
engine.setProperty('voice' , voices[2].id)
def speak(audio):
engine.say(audio)
engine.runAndWait()
def paswd():
speak("Say Edith")
query = take_commands().lower().strip()
if(query == "edit" or query=="edith"):
speak("Standby ..; Starting Biometric Scan; ")
speak("Your Name")
query = take_commands().lower().strip()
speak("hello"+query)
time.sleep(1)
c=1
return c
def wishme():
t = int(datetime.datetime.now().hour)
if(t>=0 and t<=12):
speak("Good Morning.")
elif(t>12 and t<=18):
speak("Good Afternoon. ")
else:
speak("Good Evening .")
speak("I am Edith. ")
time.sleep(2)
def take_commands():
r = sr.Recognizer()
with sr.Microphone() as source:
print("Listening......")
audio = r.listen(source)
try :
print("Recognizing......")
query = r.recognize_google(audio , language = 'en-in')
print("User Said:~ " + query)
except Exception as e :
print(e)
speak("I am Not getting you , Say That Again")
return "none"
return query
wishme()
speak("Fetching Files.... from Satellite 53;")
speak("Intializing Databases........;")
time.sleep(1)
speak(" Intializations SucessFull")
time.sleep(1)
c = paswd()
speak("Would u like to see what i can do; ")
while c :
query = take_commands().lower()
if 'yes' in query:
speak("Than Say Open Youtube")
elif (query == 'no'):
speak("Ok! ; I am Quitiing")
c=0
elif 'wikipedia' in query:
speak("Searching WEB.......")
query = query.replace('wikipedia','')
re = wikipedia.summary(query)
print(re)
speak(re)
elif 'stop talking' in query:
speak(" Quitting Sir...! Thanks for your time ")
c=0
elif 'open youtube' in query:
speak("here we go..")
webbrowser.open("youtube.com")
elif 'about you' in query:
speak("I am EDITH and EDITH stands for Even Dead, I'm The Hero, I am developed By an Iron man Fan . U can Always Find My source code at github at abhi032 to make me smarter ")
elif 'play music' in query:
speak("Do u want to provide playlist path ?")
query = take_commands().lower().strip()
if "yes" in query:
speak(" i am waiting for Path")
x=input("Path")
songs = os.listdir(x)
print(songs)
os.startfile(os.path.join(x, songs[0]))
else :
speak("Sure...!! Playing......")
os.startfile("c:\\Users\\Abhishek\\Desktop\\Virtual_Assistant\\tmk.mp3")
elif 'google it' in query:
speak("Sure!!!. opening web...")
query = query.replace("google it","").strip()
query = query.replace(" ","+")
re = webbrowser.open("google.com/search?q="+query)
else :
speak("I am Not Allowed to do this ;")
speak("Would You Like to Addd more features SO PLEASE ADD some commands")
c=0