Create AI Assistant For Beginners without Machine Learning Part — 2
Iron Man Jarvis Like AI
In the previous article, you will learn how you can make one AI Assistant using python. If you don’t read like is here to check first then read this Create AI Assistant For Beginners without Machine Learning Part — 1

Topics
- Text to Speech
- Different Voice Options and speak rate
- Datetime Function
- Greeting Function
- Speech Recognition
- Main Function
- Wikipedia search
- Send Email
- Chrome Search
- Logout, Shutdown, Restart Function’
- Play Songs
- Remember Function
- ScreenShot
- CPU & Battery Update
- Jokes Function
In the previous topic, we cover the Wikipedia search topic after that in this article I start by sending Emails.
Today worlds Almost all company using the chatbot for providing good customer service this is not like that but this is beginning or basic of AI bots. If you want to create an advanced level AI bot using the RASA framework Then you can read this article on how to build a bot using RASA.
Send Email
import smtplib # already install in pythondef sendmail(to,content):
server = smtplib.SMTP("smtp.gmail.com",587) #port no 587
server.ehlo() server.starttls() #pre define function server.login("example@gmail.com","123@123admin") server.sendmail("client@gmail.com",to,content) server.close()#now go to main function and add it there in ielif
# I was discuss how to create main function and add themelif "send email" in query:
try:
speak("what should I say")
content = takecommand()
to = "xyz@gmail.comm"
#send email(to, content)
speak(content) except Exception as e:
speak(e)
speak("Unable to send email")
Then run your main file and provide you real email address to check it works or not, I will provide only demo emails for privacy.
Chrome Search
First, you have installed Google chrome and you find the path of your chrome extension file for use in code with a good internet connection. you can open the terminal and execute the file with a voice command.
import webbrowser as wb#this condition add in main functionelif "search in chrome" in query:
speak("what you search")
chromepath="find you chrome path and paste here"
search = takecommand().lower()
wb.get(chromepath).open_new_tab(search +".com")
Logout, Shutdown, Restart Function
Using the system command you need to OS library to simply import in python file. you can add these conditions in the main function and give the voice command to use AI assistant.
import oselif "logout" in query:
os.system("shutdown - l")elif "shutdown" in query:
os.system("shutdown /s /t 1")elif "restart"in query:
os.system("shutdown /r /t 1")
Play Songs
this is the fun part of coding you simply add the music app path and choose any one song from you music library and it’s automatically play
elif "play songs" in query:
song_dir= "path of music player"
songs = os.listdir(song_dir)
os.startfile(os.path.join(song_dir,songs[0]))
remember function
this function adds for something important work reminder of that day and you want your system to remember your important task.
elif "remember" in query:
speak("waht should i remember .")
data = takecommand()
speak("you said me to rembember"+ data) remember = open('data.txt',"w")
remember.write(data)
remember.close()elif "do you know anything" in query:
remember = open("data.txt","r")
speak("you said me to remember that"+ remember.read())
remember.close()
screenshot
you use this function to capture your laptop/pc screen. then you simply call this command by voice and it’s capture automatically.
import pyautogui #pip install pyauto guidef screenshot():
img = pyautogui.screenshot()
img.save("ss.png")#add elif condition in main functionelif "screenshot" in query:
screenshot()
speak("screenshot capture")
CPU &battery update
you can see or hear your CPU and battery update by simply using psutil library of python.
import psutil #pip install psutildef cpu():
usage = str(psutil.cpu_times_percent())
speak("cpu is at "+ usage)
battery= psutil.sensors_battery
speak("battery at ")
speak(battery.percent)elif "cpu" in query:
cpu()
jokes
for fun, you add this jokes library and run it. 1st you install pyjokes library by using pip.
import pyjokes #pip install pyjokesdef jokes():
speak(pyjokes.get_joke())
I hope you all enjoy this python beginner's project. if you have to face any kind of Problem you message me on Instagram @learnwithlearners.
the project code uploaded in GitHub you can check here