Jarvis
Now we are going to create some functions. With the help of this functions we are going to make our
- Play music
- Open websites
- Search on Google
Ok Lets Start our Code.
music()
# To play music
def music():
music_dir = "D:\\Music"
songs = os.listdir(music_dir)
rd = random.choice(songs)
os.startfile(os.path.join(music_dir, rd))
YouTube()
import webbrowser
# To find IP address of the system
def YouTube():
speak("Opening Youtube")
webbrowser.open("www.youtube.com")
google()
def google():
speak("What should I search on google, sir")
qn = takecommand().lower()
webbrowser.open(f"https://www.google.com/search?q={qn}")
Place the above code in between the Previous code and call the function in the main block of the code
which means,
if __name__ == "__main__":
wish()
query = takecommand().lower()
if "open notepad" in query:
notepad()
elif "open cmd" in query:
cmd()
elif "close notepad" in query:
close_notepad()
elif "ip address" in query:
ip_address()
elif "play music" in query:
music()
elif "open youtube" in query:
YouTube()
elif "open facebook" in query:
FaceBook()
elif "open google" in query:
google()
No comments:
Post a Comment