JARVIS IN PYTHON
Python installing steps
1. Download visual studio code
2. Install python.org
3. Verify python was installed on window
Python startup steps
1. One visual studio code
2. Welcome window
3. Open folder
4. New folder
5. Select folder
6. Create new file
7. Python 3.7 A 32 bit
8. Right click
9. Window power shell
10.Write python
11.Write exit()
12.Install pip pandas
13.Print(“Hello world \n”)
14.Go to extention
15.Search code runner
16.Install it
Opening steps to create Jarvis :
1. Desktop
2. New folder
3. Name : Jarvis
4. Click shift
5. Open power shell windows here
6. Type – code
7. Open editors
8. Jarvis
9. Name : jarvis.py
What is voice
assistant ?
What we are building ?
Build Jarvis using python it's a voice assistant. It's a artificial intelligence techniques language processing speech recognition written in python. For assistants like Jarvis to be able to control the systems in phone or your pc. Voice and speech recognition we think that text will be more important for the communication. But still we realise voice also play a very important role too. The useful aspect of voice is that it's very fast. No need to take phone, open any type of app or start typing; you just speak.
* Coding for Jarvis in python :
import pyttsx3
import speech_recognition as Sr
import datetime
import wikipedia
import os
import smtplib
engine = pyttsx3.init('sapi 5')
voice = engine.getProperty('voices')
print(voices[0].id)
engine.SetProperty('voice',voices[0]id)
def speak(audio)
engine.say(audio)
engine.runAndwait
def wishMe():
hour = int(datetime.datetime.now().hour)
if hour>= 0 and hour<12:
Speak("Good Morning!")
elif hour>= 12 and hour<18:
Speak("Good Afternoon!")
else:
Speak("Good Evening!")
Speak ("I am Jarvis Sir. Please tell me How may I
Help you")
def takeCommand():
#take microphone input from the user and returns string output.
r = Sr.Recognizer()
with Sr.Microphone() as source:
print("Listening....")
r.pause_threshold = 1
audio = r.listen(source)
try:
print("Recognising...")
query = r.recognizer_google(audio, Language =
'en-in')
print(if"user said : {query}\n")
except Exception as e :
print(e)
print("Say that again please....")
return "None"
return query
def sendEmail(to,content) :
server = smtplib.SMTP('smtp.gmail.com',587)
server.ehlo()
server.startis()
server.login('email id','password')
server.sendmail('email id',to,content)
server.close()
if_name_=="_main_":
wishMe()
While True :
query = takeCommand(). lower()
#logic for executing tasks based on query
if 'wikipedia' in query :
speak('Searching Wikipedia....')
query = query.replace("Wikipedia"," ")
results = wikipedia.summary(query, sentence = 2)
speak ("According to Wikipedia")
print (result)
speak(result)
elif 'open youtube' in query:
webbrowser.open("youtube.com")
elif 'open google' in query:
webbrowser.open("google.com")
elif 'playmusic' in query:
music_dir = "D:\\Non Critical\\Songs\\Favorite
Songs 2"
song = is.list dir(music_dir)
print(songs)
os.startfile(os.path.join(music_dir,songs[0]))
elif 'the time' in query:
StrTime = datetime.datetime.now().StrTime("%H:
%M: %S")
speak(If "Sir, the time is {StrTime}")
elif 'email to Aleena' in query:
try:
speak("What should I Say?")
content = takeCommand()
to = "Aleenayouremail@gmail.com"
sendEmail(to, content)
speack("Email has been send!")
except Exception as e:
print(e)
speak("Sorry my friend Aleena. Iam not able
to send this email")
Comments
Post a Comment
If you have any doubts. Please let me know.