Skip to content

Commit c4b4a2f

Browse files
committed
fixed the notes function, removed the emojies
1 parent f7b5bc6 commit c4b4a2f

File tree

9 files changed

+83
-52
lines changed

9 files changed

+83
-52
lines changed

cli/utils/calendar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44

55
def calendar():
6-
bot.bot("Opening Calendar 📅")
6+
bot.bot("Opening Calendar")
77
url = "https://calendar.google.com/calendar/"
88
webbrowser.open(url)

cli/utils/map.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
def map():
7-
bot.bot("opening maps!🗺️")
7+
bot.bot("opening maps!")
88
q = sr.Recognizer()
99
t = 0
1010
with sr.Microphone() as source:

cli/utils/notes.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
from cli.utils import user, bot, write_note
2+
3+
def write(a):
4+
file = open("user_" + a + "txt", "w")
5+
note = write_note.write_note()
6+
file.write(note)
7+
print("A new note is created!")
8+
9+
def main():
10+
bot.bot("Searching for Notes")
11+
try:
12+
if user.user == 0:
13+
file = open("general.txt", "r")
14+
bot.bot(file.read())
15+
elif user.user == 1:
16+
file = open("user_1.txt", "r")
17+
elif user.user == 2:
18+
file = open("user_2.txt", "r")
19+
elif user.user == 3:
20+
file = open("user_3.txt", "r")
21+
22+
except FileNotFoundError:
23+
bot.bot("No notes are available.")
24+
bot.bot("Want to created one now?")
25+
q = sr.Recognizer()
26+
t = 0
27+
with sr.Microphone() as source:
28+
while t == 0:
29+
audio = q.listen(source, phrase_time_limit=5)
30+
try:
31+
res = q.recognize_google(audio)
32+
t = 1
33+
if "yes" in res:
34+
bot.bot("What should I write?")
35+
elif user.user == 0:
36+
cli.utils.notes.write("0")
37+
elif user.user == 1:
38+
cli.utils.notes.write("1")
39+
elif user.user == 2:
40+
cli.utils.notes.write("2")
41+
elif user.user == 3:
42+
cli.utils.notes.write("3")
43+
else:
44+
bot.bot("Okay, exiting the note section")
45+
except:
46+
print('Not understandable')
47+
print('Try again')
48+
t = 0
49+
bot.bot("A new note is created!")

cli/utils/search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
def search():
9-
bot.bot('What to search? 🔍')
9+
bot.bot('What to search?')
1010
# listen()
1111
w = sr.Recognizer()
1212
t = 0

cli/utils/shop.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def shop():
1515
query = q.recognize_google(audio)
1616
print('you said :{}'.format(query))
1717
bot.bot('Here you go')
18-
bot.bot('Happy shopping! 🛍️')
18+
bot.bot('Happy shopping!')
1919
t = 1
2020
except:
2121
print('Not understandable')

cli/utils/user.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# it is the config file for the current user
22
# 0 is for the default user
33
# 1 for the 1st and so on...
4+
# the ids are being updated from the predict.py
45
# we assign a id and then update the functions
56
# only which needs a user specific response
67
# like the bot's response voice

cli/utils/whoami.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
def main():
44
if user.user == 0:
5-
bot.bot("I am the general user. I am not giving the presonalised voice assistant.")
6-
bot.bot("To activate the presonalised voice assistant say RECOGNISE")
5+
bot.bot("I am the general user. I am not giving the presonalised voice assistant.")
6+
bot.bot("To activate the presonalised voice assistant say RECOGNISE")
77

8-
elif user.user == 1:
9-
bot.bot("You the registered User 0!")
10-
bot.bot("Welcome back!")
8+
elif user.user == 1:
9+
bot.bot("You the registered User 0!")
10+
bot.bot("Welcome back!")
1111

12-
elif user.user == 2:
13-
bot.bot("You the registered User 1!")
14-
bot.bot("Welcome back!")
12+
elif user.user == 2:
13+
bot.bot("You the registered User 1!")
14+
bot.bot("Welcome back!")
1515

16-
elif user.user == 3:
17-
bot.bot("You the registered User 2!")
18-
bot.bot("Welcome back!")
16+
elif user.user == 3:
17+
bot.bot("You the registered User 2!")
18+
bot.bot("Welcome back!")

cli/utils/write_note.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import speech_recognition as sr
2+
3+
def write_note():
4+
mic = sr.Microphone()
5+
r = sr.Recognizer()
6+
with mic as source:
7+
print("What to write in the note!")
8+
note = r.listen(source)
9+
try:
10+
note = r.recognize_google(note).lower()
11+
print("The note will be written as: " + note)
12+
except sr.UnknownValueError:
13+
print("Sorry I didn't get you. Kindly say again.")
14+
note = write_note()
15+
16+
return note

cli/voice_assistant.py

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ def func(command):
6767
bot.bot(pyjokes.get_joke())
6868

6969
elif "google" in command:
70-
webbrowser.open("https://www.google.com")
71-
bot.bot("Check your default web browser!")
70+
search.search()
7271

7372
elif 'time' in command:
7473
now = datetime.datetime.now()
@@ -83,41 +82,8 @@ def func(command):
8382
elif "prime video" in command:
8483
amazon_prime.amazon_prime()
8584

86-
elif "write note" in command:
87-
bot.bot("What should I write?")
88-
note = write_note.write_note()
89-
file = open('general.txt', 'w')
90-
file.write(note)
91-
9285
elif "show notes" in command:
93-
bot.bot("Searching for Notes")
94-
try:
95-
file = open("general.txt", "r")
96-
bot.bot(file.read())
97-
except FileNotFoundError:
98-
bot.bot("No notes are available.")
99-
bot.bot("Want to create one now?")
100-
q = sr.Recognizer()
101-
t = 0
102-
with sr.Microphone() as source:
103-
while t == 0:
104-
audio = q.listen(source, phrase_time_limit=5)
105-
try:
106-
res = q.recognize_google(audio)
107-
t = 1
108-
if "yes" in res:
109-
bot.bot("What should I write?")
110-
file = open('general.txt', 'w')
111-
note = write_note.write_note()
112-
file.write(note)
113-
print("A new note is created!")
114-
else:
115-
bot.bot("Okay, exiting the note section")
116-
except:
117-
print('Not understandable')
118-
print('Try again')
119-
t = 0
120-
bot.bot("A new note is created!")
86+
notes.main()
12187

12288
elif "gmail" in command:
12389
bot.bot("sure, opening gmail")
@@ -144,7 +110,6 @@ def func(command):
144110
bot.bot("You have aborted the process. Returning back to previous state")
145111
main(listen())
146112

147-
# google search
148113
elif 'search' in command:
149114
search.search()
150115

0 commit comments

Comments
 (0)