-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
90 lines (71 loc) · 2.75 KB
/
main.py
File metadata and controls
90 lines (71 loc) · 2.75 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
import fridayfunctions as FF
from fridayfunctions import playmusic
import speakandrecognizefunctions as SRF
import datetime
WAKE_WORD = "friday"
USER = "sumesh"
def success():
print("Command executed succesfully :)")
# GREETINGS ON THE START
SRF.speak("Hello !! I am FRIDAY !!")
FF.wishme()
SRF.speak("if u need me to do anything just ask !")
while True:
# Constantly hearing in the background
text = SRF.takecommandbackground()
# Wakes up when it hears the word FRIDAY in the text
if text.count(WAKE_WORD) > 0:
SRF.speak("How may i help you ?")
print("\nListening....")
# takes the command to do stuff
text = SRF.takecommand()
# This is if u greet friday
WISH_STR = ["hello", "hey", "hai", "hi", "hola"]
for phrase in WISH_STR:
if phrase in text:
SRF.speak("Hello" + USER)
success()
# This is for taking notes
NOTE_STRS = ["take note", "take a note", "make a note",
"write this down", "remember this"]
for phrase in NOTE_STRS:
if phrase in text:
SRF.speak("what would you like me write down")
note_text = SRF.takecommand()
FF.note(note_text)
SRF.speak("Ok i Have taken the note")
success()
# this is for wikipedia search, command - " search wikipedia for [name] ", "wikipedia search [name]","search on wikipedia for []"
if 'wikipedia' in text:
FF.wikipediasearch(text)
success()
# to open files on this computer
if 'open' in text:
FF.open_programs_websites(text)
success()
# this is for telling the current time
TIME_STRS = ["whats the time", "tell the time", "the time"]
for phrase in TIME_STRS:
if phrase in text:
hour = datetime.datetime.now().strftime("%I")
minute = datetime.datetime.now().strftime("%M%p")
SRF.speak(f"It's {hour} {minute} ")
success()
GOOGLE_STRS = ["search on google",
"google search", "search google for"]
for phrase in GOOGLE_STRS:
if phrase in text:
query = text.replace(phrase, "")
FF.googlesearch(query)
success()
MUSIC_STRS = ["play music", "start music"]
for phrase in MUSIC_STRS:
if phrase in text:
playmusic()
success()
# This is if u want to exit the program
EXIT_STRS = ["exit", "go away", "bye bye"]
for phrase in EXIT_STRS:
if phrase in text:
SRF.speak("Bye Bye " + USER + "see you later")
exit()