Update Jarvis2.py
This commit is contained in:
parent
2f2077a868
commit
935415f8f7
12
Jarvis2.py
12
Jarvis2.py
@ -12,6 +12,8 @@ import pyttsx3
|
|||||||
import speech_recognition as sr
|
import speech_recognition as sr
|
||||||
import wikipedia
|
import wikipedia
|
||||||
|
|
||||||
|
import gui
|
||||||
|
|
||||||
print("Initializing Jarvis....")
|
print("Initializing Jarvis....")
|
||||||
MASTER = getpass.getuser()
|
MASTER = getpass.getuser()
|
||||||
|
|
||||||
@ -46,6 +48,7 @@ def search(search_query, search_engine):
|
|||||||
|
|
||||||
|
|
||||||
def speak(text):
|
def speak(text):
|
||||||
|
gui.speak(text)
|
||||||
engine.say(text)
|
engine.say(text)
|
||||||
engine.runAndWait()
|
engine.runAndWait()
|
||||||
|
|
||||||
@ -95,10 +98,13 @@ def take_command():
|
|||||||
|
|
||||||
speak("Initializing Jarvis....")
|
speak("Initializing Jarvis....")
|
||||||
wish_me()
|
wish_me()
|
||||||
|
|
||||||
|
|
||||||
|
def execute_the_command_said_by_user():
|
||||||
query = take_command().lower()
|
query = take_command().lower()
|
||||||
|
|
||||||
# logic for executing basic tasks
|
# logic for executing basic tasks
|
||||||
if "wikipedia" in query.lower():
|
if "wikipedia" in query:
|
||||||
speak("Searching wikipedia....")
|
speak("Searching wikipedia....")
|
||||||
query = query.replace("wikipedia", "")
|
query = query.replace("wikipedia", "")
|
||||||
print_and_speak(wikipedia.summary(query, sentences=2))
|
print_and_speak(wikipedia.summary(query, sentences=2))
|
||||||
@ -171,3 +177,7 @@ elif "play music" in query:
|
|||||||
speak("Playing your request")
|
speak("Playing your request")
|
||||||
|
|
||||||
speak("Next Command! Sir!")
|
speak("Next Command! Sir!")
|
||||||
|
|
||||||
|
|
||||||
|
gui.set_speak_command(execute_the_command_said_by_user)
|
||||||
|
gui.mainloop()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user