Skip to content

Commit

Permalink
fixed the notes function, removed the emojies
Browse files Browse the repository at this point in the history
  • Loading branch information
HarshitRuwali committed Mar 27, 2021
1 parent f7b5bc6 commit c4b4a2f
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 52 deletions.
2 changes: 1 addition & 1 deletion cli/utils/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@


def calendar():
bot.bot("Opening Calendar 📅")
bot.bot("Opening Calendar")
url = "https://calendar.google.com/calendar/"
webbrowser.open(url)
2 changes: 1 addition & 1 deletion cli/utils/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


def map():
bot.bot("opening maps!🗺️")
bot.bot("opening maps!")
q = sr.Recognizer()
t = 0
with sr.Microphone() as source:
Expand Down
49 changes: 49 additions & 0 deletions cli/utils/notes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from cli.utils import user, bot, write_note

def write(a):
file = open("user_" + a + "txt", "w")
note = write_note.write_note()
file.write(note)
print("A new note is created!")

def main():
bot.bot("Searching for Notes")
try:
if user.user == 0:
file = open("general.txt", "r")
bot.bot(file.read())
elif user.user == 1:
file = open("user_1.txt", "r")
elif user.user == 2:
file = open("user_2.txt", "r")
elif user.user == 3:
file = open("user_3.txt", "r")

except FileNotFoundError:
bot.bot("No notes are available.")
bot.bot("Want to created one now?")
q = sr.Recognizer()
t = 0
with sr.Microphone() as source:
while t == 0:
audio = q.listen(source, phrase_time_limit=5)
try:
res = q.recognize_google(audio)
t = 1
if "yes" in res:
bot.bot("What should I write?")
elif user.user == 0:
cli.utils.notes.write("0")
elif user.user == 1:
cli.utils.notes.write("1")
elif user.user == 2:
cli.utils.notes.write("2")
elif user.user == 3:
cli.utils.notes.write("3")
else:
bot.bot("Okay, exiting the note section")
except:
print('Not understandable')
print('Try again')
t = 0
bot.bot("A new note is created!")
2 changes: 1 addition & 1 deletion cli/utils/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


def search():
bot.bot('What to search? 🔍')
bot.bot('What to search?')
# listen()
w = sr.Recognizer()
t = 0
Expand Down
2 changes: 1 addition & 1 deletion cli/utils/shop.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def shop():
query = q.recognize_google(audio)
print('you said :{}'.format(query))
bot.bot('Here you go')
bot.bot('Happy shopping! 🛍️')
bot.bot('Happy shopping!')
t = 1
except:
print('Not understandable')
Expand Down
1 change: 1 addition & 0 deletions cli/utils/user.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# it is the config file for the current user
# 0 is for the default user
# 1 for the 1st and so on...
# the ids are being updated from the predict.py
# we assign a id and then update the functions
# only which needs a user specific response
# like the bot's response voice
Expand Down
22 changes: 11 additions & 11 deletions cli/utils/whoami.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

def main():
if user.user == 0:
bot.bot("I am the general user. I am not giving the presonalised voice assistant.")
bot.bot("To activate the presonalised voice assistant say RECOGNISE")
bot.bot("I am the general user. I am not giving the presonalised voice assistant.")
bot.bot("To activate the presonalised voice assistant say RECOGNISE")

elif user.user == 1:
bot.bot("You the registered User 0!")
bot.bot("Welcome back!")
elif user.user == 1:
bot.bot("You the registered User 0!")
bot.bot("Welcome back!")

elif user.user == 2:
bot.bot("You the registered User 1!")
bot.bot("Welcome back!")
elif user.user == 2:
bot.bot("You the registered User 1!")
bot.bot("Welcome back!")

elif user.user == 3:
bot.bot("You the registered User 2!")
bot.bot("Welcome back!")
elif user.user == 3:
bot.bot("You the registered User 2!")
bot.bot("Welcome back!")
16 changes: 16 additions & 0 deletions cli/utils/write_note.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import speech_recognition as sr

def write_note():
mic = sr.Microphone()
r = sr.Recognizer()
with mic as source:
print("What to write in the note!")
note = r.listen(source)
try:
note = r.recognize_google(note).lower()
print("The note will be written as: " + note)
except sr.UnknownValueError:
print("Sorry I didn't get you. Kindly say again.")
note = write_note()

return note
39 changes: 2 additions & 37 deletions cli/voice_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ def func(command):
bot.bot(pyjokes.get_joke())

elif "google" in command:
webbrowser.open("https://www.google.com")
bot.bot("Check your default web browser!")
search.search()

elif 'time' in command:
now = datetime.datetime.now()
Expand All @@ -83,41 +82,8 @@ def func(command):
elif "prime video" in command:
amazon_prime.amazon_prime()

elif "write note" in command:
bot.bot("What should I write?")
note = write_note.write_note()
file = open('general.txt', 'w')
file.write(note)

elif "show notes" in command:
bot.bot("Searching for Notes")
try:
file = open("general.txt", "r")
bot.bot(file.read())
except FileNotFoundError:
bot.bot("No notes are available.")
bot.bot("Want to create one now?")
q = sr.Recognizer()
t = 0
with sr.Microphone() as source:
while t == 0:
audio = q.listen(source, phrase_time_limit=5)
try:
res = q.recognize_google(audio)
t = 1
if "yes" in res:
bot.bot("What should I write?")
file = open('general.txt', 'w')
note = write_note.write_note()
file.write(note)
print("A new note is created!")
else:
bot.bot("Okay, exiting the note section")
except:
print('Not understandable')
print('Try again')
t = 0
bot.bot("A new note is created!")
notes.main()

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

# google search
elif 'search' in command:
search.search()

Expand Down

1 comment on commit c4b4a2f

@HarshitRuwali
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the emojis were spelled out, like magnifying glass and so on...

Please sign in to comment.