MY JARVIS CODE USING PYTHON
import pyttsx3
import datetime
import speech_recognition as sr
import wikipedia
import webbrowser
import os
import webbrowser as wb
import smtplib
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
import subprocess
import winsound
def talktome(audio):
print(audio)
tts=gTTs(text=audio,language='en')
tts.save('audio.mp3')
os.system('mpg123 audio.mp3')
engine=pyttsx3.init('sapi5')
voices=engine.getProperty('voices')
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 sir!")
speak("the weather is nice today!")
elif hour>=12 and hour<18:
speak("Good Afternoon sir!")
speak( "Have a beautiful day!")
else:
speak("good evening sir!")
speak(" i am mini ,1 point o , ,please tell me master how may i help you")
def takecommand():
#it takes microphone input and gives output
r=sr.Recognizer()
with sr.Microphone() as source:
print("listening......")
r.pause_threshold= 1
r.adjust_for_ambient_noise(source,duration=1)
audio=r.listen(source)
try:
print("recognizing....")
query= r.recognize_google(audio,language='en-in')
print(f"master said: {query}\n")
except Exception as e:
#print(e)
print("say that again please.....")
return"none"
return query
if __name__=="__main__":
wishMe()
while True:
query = takecommand().lower()
if "who are you" in query or "define yourself" in query:
speak('''hello,I am person.your personal assistant.
I am here to make your life easier.
you can command me to perform various tasks such as accepting your commands''')
if "who made you" in query or"who created you" in query or "who is your creator" in query:
speak('''I have been created by shaik. Faizuddin.''')
if "when you are created" in query or "when is your birthday" in query:
speak('''i was created on eleventh. october. 2020''')
if "exit" in query or "bye" in query:
speak("ok bye master")
break
if "thank you" in query:
speak("Its my pleasure to be your assistant master")
if "our family" in query:
speak('''our grand father is johny.
our grand mother is noorjahan.
our father is Rasheed.
our mother is Nazima.
our sister is neha.
and my friend was faizu.''')
speak("this is our family sir!")
if "wake up" in query:
speak("I am on work master")
continue
if "wikipedia" in query:
speak('searching wikipedia....')
query=query.replace("wikipedia", "")
results=wikipedia.summary(query, sentences=2)
speak("According to wikipedia")
speak(results)
print(results)
if "who am i" in query:
speak("If you talk then definetely you are human")
if "why you came to world" in query:
speak("thanks to faizu. further is a secret")
if "reason for you" in query:
speak("I was created as a minor project by mister faizu")
if "how are you" in query:
speak("i am fine,thank you master")
speak("how are you , master")
if "fine" in query or "good" in query:
speak("It's good to know that you are fine")
if "change your name" in query:
speak("what would you like to call me,master")
assistant_name=takecommand()
speak("thanks for naming me")
if "what is your name" in query:
speak("i am mini,1 ,point o , master")
if "joke" in query:
speak(pyjokes.get_joke())
if "lock the screen" in query:
speak("locking your device master")
ctypes.windll.user32.lockworkstation()
if "shutdown system" in query:
speak("hold a sec ! your system is on its way ")
subprocess.call('shutdown /s /t 15')
speak("shutting down your laptop master")
if "stop listening" in query or "sleep" in query:
speak("ok master")
time.sleep(60)
if "restart" in query:
subprocess.call(["shutdown","/r"])
if "write a note" in query:
speak("what should i write sir")
note=takecommand()
file=open('jarvis.txt','w')
speak("should i include date and time master")
snfm=takecommand()
if 'yes' in snfm or 'sure' in snfm:
strtime=datetime.datetime.now().strftime("%H:%M:")
file.write(strtime)
file.write(" :- ")
file.write(note)
else:
file.write(note)
if "show note" in query:
speak("showing notes master")
file=open('jarvis.txt',"r")
print(file.read())
speak(file.read(6))
if 'open youtube' in query:
webbrowser.open("https://www.youtube.com/")
speak("opening youtube sir!")
if 'open google' in query:
webbrower.open("google.com")
if 'play music' in query:
music_dir='D:\\old songs'
songs=os.listdir(music_dir)
print(songs)
os.startfile(os.path.join(music_dir,songs[0]))
speak("playing music master")
if 'the time' in query:
strtime =datetime.datetime.now().strftime("%H:%M:%S")
speak(f"sir ,the time is {strtime}")
if 'open classes' in query:
webbrowser.open("https://city.codetantra.com/login.jsp")
speak("opening your classes master")
if 'open gmail' in query:
webbrowser.open("gmail.com")
speak("opening gmail master")
if 'open whatsapp' in query:
webbrowser.open("whatsappweb.com")
speak("opening whatsapp master")
if 'open facebook' in query:
webbrowser.open("facebook.com")
speak("opening your facebook account master")
if 'open my insta' in query:
webbrowser.open("https://www.instagram.com/shaikfaizuddin786/?hl=en")
speak("opening your instagram account master")
if "sbi online" in query:
webbrowser.open('retail.onlinesbi.com/retail/login.htm')
speak("opening s b i master")
if "open paytm" in query:
webbrowser.open('paytm.com/')
speak("opening paytm master")
if "open hotstar" in query :
webbrowser.open('hotstar.com/in')
speak("opening hotstar master")
def open_application ():
if 'chrome' in query:
speak("opening chrome master")
os.startfile('C:\Program Files\Google\Chrome\Application\chrome')
if 'word' in query :
speak("opening word master")
os.startfile('C:\Program Files\Microsoft Office\Office12\word.exe')
if "excel" in query or "XL" in query:
speak("opening excel master")
os.startfile('C:\Program Files\Microsoft Office\Office12\excel.exe')
if "power point" in query or "ppt" in query:
speak("opening power point master")
os.startfile('C:\Program Files\Microsoft Office\Office12\powerpnt.exe')
if "study pdf" in query:
os.startfile('F:\study pdf')
if "movies" in query:
os.startfile('E:\movies')
if "downloads" in query:
os.startfile('Downloads')
Comments
Post a Comment