Create your own AI(Artificial intelligence) assistant using python
Hey
guys once again welcome to the Decoders blog, I hope you all are doing
well and today I'm present with a AI assistant (using python).
Here is an overview of how your AI is going to work like!!!!
import webbrowser
import pyttsx3
import datetime
import os
import subprocess
import wikipedia
engine=pyttsx3.init()
voices=engine.getProperty('voices')
engine.setProperty('voices',voices[2].id)
def speak(audio):
engine.say(audio)
engine.runAndWait()
speak("Hello, I am your assistant how can I help you")
while(True):
user=input("Ask something....:")
euser=user.lower()
if 'open google' in euser:
speak("opening google")
webbrowser.open("google.com")
elif 'open youtube' in euser:
speak("opening youtube")
webbrowser.open("youtube.com")
elif 'time' in euser:
n1=datetime.datetime.now().strftime("%H:%M:%S")
print("The current time",n1)
speak(f"the current time is {n1}")
elif 'whatsapp' in euser:
speak("opening whatsapp")
webbrowser.open("web.whatsapp.com")
elif 'you' in euser:
print("I am your assistant, my name is alex")
speak("I am your assistant, my name is alex")
elif 'live' in euser:
print("I am always with you as an invisible energy :)")
speak("I am always with you as an invisible energy")
elif 'blog' in euser:
speak("opening blog")
webbrowser.open("blogger.com")
elif 'twitter' in euser:
speak("opening twitter")
webbrowser.open("twitter.com")
elif 'movieverse' in euser:
speak("opening movieverse")
webbrowser.open("movieverse.co")
elif 'wikipedia' in euser:
euser=euser.replace("wikipedia","")
results=wikipedia.summary(euser,sentences=5)
print(results)
speak(results)
elif 'exit' in euser:
speak("Closing the function......")
break
else:
print("Nothing found")
speak("noothing found")
Comments
Post a Comment