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