Python Project
Python Project
import datetime
import speech_recognition as sr
import webbrowser
import os
import wikipedia
import time
from datetime import date
import pyjokes
import requests
from GoogleNews import GoogleNews
import subprocess
from pywinauto.application import Application
import pyautogui
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
i=0
j=0
i1=0
sex=''
dic = {"hello": "hello sir ,How are you", "hy": "hello sir ,How are you", "hayy":
"Im fine sir "}
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
# print(voices) this is used to see the voices that how much voices do your pc have
# print(voices[1].id)
engine.setProperty('voice', voices[0].id) # thisis used to use the voices of the
computer
def my():
with open("ss","r") as e:
s=e.readlines()
spacek(s)
e.close()
def spacek(audio):
engine.say(audio)
engine.runAndWait()
def me():
s = "hello sir Im jarvise 2. point o " \
"Created by akhilesh goswami "
spacek(s)
def wishme(s):
hour = int(datetime.datetime.now().hour)
def opendetiles():
spacek("you want to only see the user deties or i should speack")
s=takecommend()
if(s=="see"):
with open("data of user.text","r" ) as e:
e.readlines()
print(e)
e.close()
else:
with open("data of user.text","r") as e:
s = e.readlines()
print(s)
spacek(s)
e.close()
def username(s1):
try:
spacek(f"what i should to call you{s1}")
s=takecommend()
s=s.replace("call me",'')
spacek(f"helle{s1} ")
spacek(s)
with open("data of user.text","a") as e:
st = datetime.datetime.now()
st1=date.today()
e.write(f"{s} use me on {st1}at{st} \n ")
e.close()
spacek(f"how can i help you {s1}")
except Exception as e:
spacek(f"{s1} i dont understant sir what did you say ")
username(s1)
def takecommend():
"""this takes maicorphone input from the user and returns string output"""
r = sr.Recognizer()
with sr.Microphone() as source:
print("Listing......")
r.pause_threshold = 1
audio = r.listen(source)# to see everything about this please press control
and click on the line
try:
print("Recozinagition..........")
query = r.recognize_google(audio, language='en-in')
print("You said", query)
except Exception as e:
print(e)
print("said it again please")
def news(str):
global i
if i == 0:
spacek(f"ofcures {str} which news you want to listen")
else:
spacek(f"which news you want to listen{str}")
try:
s = takecommend().lower()
s=s.replace('about',"")
spacek("which page you want ot listen")
s2 = int(takecommend())
googlenews = GoogleNews()
googlenews = GoogleNews('en', "2")
# here you can use d which is denoted for how much linw you want to lesiten
googlenews.search(s)
googlenews.getpage(s2)
googlenews.result()
spacek(f" {str} here is news about ")
spacek(s)
print(googlenews.gettext())
spacek(googlenews.gettext())
except Exception as s:
spacek(f"could not understand {str} what did you say say it again")
i=1
news(str)
def me1():
with open("gg", "r") as e:
s = e.readlines()
spacek(s)
e.close()
def jarvis():
global j
if j==0:
spacek("")
else:
spacek("jarvis in a sleep mode sir")
try:
s=takecommend().lower()
print(s)
if 'sleep' in s:
spacek("ok sir")
jarvis()
j+=1
elif'woke up'in s:
spacek("ok sir it will take some time to get connection to network")
main()
else:
jarvis()
except Exception as e1:
jarvis()
def into():
global i1
global sex
while (1):
if i1>0:
spacek("who are you sir")
try:
s1 = takecommend().lower()
s1=s1.replace('im','')
if 'akhilesh' in s1:
sex = 'sir'
else:
spacek("plesae identifai your self Are you a male of female !")
spacek("or girl or boy")
s1 = takecommend().lower()
if 'male' in s1 or 'boy' in s1:
sex = 'sir'
elif 'female' in s1 or 'girl' in s1:
sex = 'meam'
else:
into()
i1=+1
def main():
into()
while (1):
clear = lambda: os.system('cls')
clear()
try:
queuery = takecommend().lower()
if 'wikipedia' in queuery:
spacek("seraching .......")
queuery = queuery.replace("wikipedia", "")
result = wikipedia.summary(queuery, sentences=2)
spacek("Accroding to wikipedia")
spacek(result)
spacek(s)
spacek(
f"you opened anthore programe{sex} would like to stop me from
listing if yes please said stop listening or dont listen")
spacek("maximizeing windows")
pyautogui.hotkey('Win', 'd')
spacek("ok sir please say what you want to write or search sir")
s=takecommend()
pyautogui.write(s)
time.sleep(3)
pyautogui.press('enter')
def dd():
while True:
try:
spacek("what you want to write in a note")
s = takecommend().lower()
app = Application().start("notepad.exe")
app.UntitledNotepad.menu_select("Help->About Notepad")
app.aboutNotepad.OK.click()
app.UntitledNotepad.Edit.type_keys(s, with_spaces=True)
spacek("would you like to write more or want to save the file")
s2=takecommend().lower()
if 'yes'in s2:
s3=takecommend()
app.UntitledNotepad.Edit.type_keys(s3,pyautogui.hotkey('enter') ,with_spaces=True)
spacek("would you like to save this")
se=takecommend().lower()
if 'yes'in se:
app.UntitledNotepad.menu_select("File->save->save")
spacek("please give a name to file")
time.sleep(5)
pyautogui.hotkey('ctrl', 's')
spacek("file has been saved")
break
elif 'save' in s2:
app.UntitledNotepad.menu_select("File->save->save")
spacek("please give a name to file")
time.sleep(5)
pyautogui.hotkey('ctrl', 's')
spacek("file has been saved")
break
spacek("would you like to close the windows")
s1 = takecommend().lowwer()
if 'yes' in s1:
spacek("ok sir")
app.UntitledNotepad.menu_select("File->Exit")
app.Exit.OK.click()
pyautogui.hotkey('alt','f4')
elif 'no'in s1:
break
except Exception as e:
spacek("i could not understand sir plesase speack again")
if __name__ == "__main__":
# jarvis()
main()