fixed everything again
This commit is contained in:
parent
295e6fa322
commit
3350726592
@ -3,7 +3,7 @@ import os
|
|||||||
|
|
||||||
import speech_recognition as sr
|
import speech_recognition as sr
|
||||||
|
|
||||||
from actions import search_engine_selector, speak, wishMe
|
from actions import search_engine_selector, speak, wish_me
|
||||||
from commands import (
|
from commands import (
|
||||||
command_bye,
|
command_bye,
|
||||||
command_hello,
|
command_hello,
|
||||||
@ -24,13 +24,13 @@ popular_websites = {
|
|||||||
"youtube": "https://www.youtube.com",
|
"youtube": "https://www.youtube.com",
|
||||||
"wikipedia": "https://www.wikipedia.org",
|
"wikipedia": "https://www.wikipedia.org",
|
||||||
"amazon": "https://www.amazon.com",
|
"amazon": "https://www.amazon.com",
|
||||||
"GitHub": "https://www.github.com",
|
"github": "https://www.github.com",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def main(search_engine, takeCommand, debug):
|
def main(search_engine, take_command, debug):
|
||||||
while True:
|
while True:
|
||||||
query = takeCommand().lower()
|
query = take_command().lower()
|
||||||
|
|
||||||
# logic for executing commands without arguments
|
# logic for executing commands without arguments
|
||||||
phrases = {
|
phrases = {
|
||||||
@ -59,14 +59,14 @@ def main(search_engine, takeCommand, debug):
|
|||||||
popular_websites,
|
popular_websites,
|
||||||
debug,
|
debug,
|
||||||
search_engine,
|
search_engine,
|
||||||
takeCommand
|
take_command
|
||||||
)
|
)
|
||||||
|
|
||||||
elif "search" in query.lower():
|
elif "search" in query.lower():
|
||||||
command_search(query, search_engine)
|
command_search(query, search_engine)
|
||||||
|
|
||||||
elif "mail" in query:
|
elif "mail" in query:
|
||||||
command_mail(takeCommand)
|
command_mail(take_command)
|
||||||
|
|
||||||
speak("Next Command! Sir!")
|
speak("Next Command! Sir!")
|
||||||
|
|
||||||
@ -79,11 +79,10 @@ def run():
|
|||||||
debug = config['DEFAULT']['debug']
|
debug = config['DEFAULT']['debug']
|
||||||
|
|
||||||
if debug == "True":
|
if debug == "True":
|
||||||
def takeCommand():
|
def take_command():
|
||||||
query = input("Command |--> ")
|
return input("Command |--> ")
|
||||||
return query
|
|
||||||
else:
|
else:
|
||||||
def takeCommand():
|
def take_command():
|
||||||
r = sr.Recognizer()
|
r = sr.Recognizer()
|
||||||
with sr.Microphone() as source:
|
with sr.Microphone() as source:
|
||||||
print("Listening....")
|
print("Listening....")
|
||||||
@ -109,13 +108,12 @@ def run():
|
|||||||
print("Say That Again Please")
|
print("Say That Again Please")
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
query = None
|
|
||||||
|
|
||||||
return query
|
return None
|
||||||
|
|
||||||
speak(text="Initializing Jarvis....")
|
speak(text="Initializing Jarvis....")
|
||||||
wishMe(master)
|
wish_me(master)
|
||||||
main(search_engine, takeCommand, debug)
|
main(search_engine, take_command, debug)
|
||||||
|
|
||||||
|
|
||||||
if os.path.isfile('./config.ini'): # Checks if config.ini exists.
|
if os.path.isfile('./config.ini'): # Checks if config.ini exists.
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@ -50,7 +50,7 @@ def speak(text):
|
|||||||
engine.runAndWait()
|
engine.runAndWait()
|
||||||
|
|
||||||
|
|
||||||
def wishMe(master):
|
def wish_me(master):
|
||||||
hour = datetime.datetime.now().hour
|
hour = datetime.datetime.now().hour
|
||||||
# print(hour)
|
# print(hour)
|
||||||
if hour >= 0 and hour < 12:
|
if hour >= 0 and hour < 12:
|
||||||
|
|||||||
14
commands.py
14
commands.py
@ -24,16 +24,16 @@ def command_wikipedia(debug, query):
|
|||||||
|
|
||||||
|
|
||||||
def command_whatsup():
|
def command_whatsup():
|
||||||
stMsgs = [
|
st_msgs = [
|
||||||
"Just doing my thing!",
|
"Just doing my thing!",
|
||||||
"I am fine!",
|
"I am fine!",
|
||||||
"Nice!",
|
"Nice!",
|
||||||
"I am nice and full of energy",
|
"I am nice and full of energy",
|
||||||
]
|
]
|
||||||
speak(random.choice(stMsgs))
|
speak(random.choice(st_msgs))
|
||||||
|
|
||||||
|
|
||||||
def command_open(query, popular_websites, debug, search_engine, takeCommand):
|
def command_open(query, popular_websites, debug, search_engine, take_command):
|
||||||
website = query.replace("open", "").strip().lower()
|
website = query.replace("open", "").strip().lower()
|
||||||
try:
|
try:
|
||||||
open_url(popular_websites[website])
|
open_url(popular_websites[website])
|
||||||
@ -44,7 +44,7 @@ def command_open(query, popular_websites, debug, search_engine, takeCommand):
|
|||||||
pass
|
pass
|
||||||
speak(f"Sorry, i don't know the website {website}")
|
speak(f"Sorry, i don't know the website {website}")
|
||||||
speak(f"¿Do you want me to search {website} in the web?")
|
speak(f"¿Do you want me to search {website} in the web?")
|
||||||
if takeCommand() == "yes":
|
if take_command() == "yes":
|
||||||
search(website, search_engine)
|
search(website, search_engine)
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
@ -55,13 +55,13 @@ def command_search(query, search_engine):
|
|||||||
search(search_query, search_engine)
|
search(search_query, search_engine)
|
||||||
|
|
||||||
|
|
||||||
def command_mail(takeCommand):
|
def command_mail(take_command):
|
||||||
speak("Who is the recipient? ")
|
speak("Who is the recipient? ")
|
||||||
recipient = takeCommand()
|
recipient = take_command()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
speak("What should I say? ")
|
speak("What should I say? ")
|
||||||
content = takeCommand()
|
content = take_command()
|
||||||
|
|
||||||
email = config['EMAIL']
|
email = config['EMAIL']
|
||||||
server = smtplib.SMTP(email['server'], email['port'])
|
server = smtplib.SMTP(email['server'], email['port'])
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
master = YourName
|
master = YourName
|
||||||
search_engine = Google
|
search_engine = Google
|
||||||
#Google/Bing/DuckDuckGo/Youtube
|
#Google/Bing/DuckDuckGo/Youtube
|
||||||
debug = False
|
debug = True
|
||||||
#True/False
|
#True/False
|
||||||
musicPath =
|
musicPath =
|
||||||
[EMAIL]
|
[EMAIL]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user