File
File
File
py
import pyttsx3
import simple_colors
import speech_recognition as rec
import datetime
import webbrowser
import smtplib
from email.message import EmailMessage
import wikipedia
import os
import matplotlib.pyplot as plot
import cartopy.crs as cart
import random
import wolframalpha
import requests
from PIL import Image
import pyautogui as pg
from os import startfile
from pyautogui import click
from keyboard import press
from keyboard import press_and_release
from keyboard import write
from time import sleep
from geopy.distance import great_circle
from pyautogui import hotkey
from playsound import playsound
bot= pyttsx3.init('sapi5')
voices= bot.getProperty('voices')
bot.setProperty('voices',voices[1].id)
bot.setProperty('rate',170)
def speak(audio):
print(" ")
print('zero : ', simple_colors.green(f'{audio}', 'bold'))
print(" ")
bot.say(audio)
bot.runAndWait()
def takecommand():
r = rec.Recognizer()
with rec.Microphone() as source:
speak("Listening ....")
r.pause_threshold = 1
audio = r.listen(source)
try:
print("Recognizing ....")
except Exception as e:
speak("say that again please !!")
return "None"
return query
def wish_me():
hour=int(datetime.datetime.now().hour)
if hour>=0 and hour<12:
speak("Good Morning Sir!")
elif hour>=12 and hour<=18:
speak("Good Afternoon Sir!")
else:
speak("Good Evening Sir!")
speak('my name is Zero . How can i Help you ?')
def Alarm(query):
Time = open("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\data.txt",'a')
Time.write(query)
Time.close()
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\FEATURES\\ALARM.PY")
def downyoutube():
from pytube import YouTube
from pyautogui import click
from pyautogui import hotkey
import pyperclip
sleep(2)
click(x=205,y=62)
hotkey('ctrl','c')
value= pyperclip.paste()
link = str(value)
def download(link):
url = YouTube(link)
vedio = url.streams.get_highest_resolution()
speak("sir the download has been started")
vedio.download('C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\Youtube')
download(link)
speak("sir i have downloaded the vedio")
speak("you can check it out")
os.startfile('C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\Youtube')
def Speedtest():
from time import sleep
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\gui program\\
SpeedTestGui.py")
sleep(60)
def teach(query):
api_key = "7RAJ2A-8YUGV5Q2WG"
request = wolframalpha.Client(api_key)
requested = request.query(query)
try:
answer = next(requested.results).text
return answer
except:
speak(" According to my database this Question is not Answerable")
def My_location():
open = 'https://www.google.co.in/maps/@28.4729472,77.0363116,613a,35y,39.13t/
data=!3m1!1e3?entry=ttu'
speak("checking....")
webbrowser.open(open)
ip_add = requests.get('https://api.ipify.org').text
url = 'https://get.geojs.io/v1/ip/geo/' + ip_add + '.json'
geo_q = requests.get(url)
geo_d = geo_q.json()
state = geo_d['city']
country = geo_d['country']
speak(f"sir you are now in {state, country}")
def calculator(query):
term =str(query)
term = term.replace("multiply","*")
term = term.replace("plus","+")
term = term.replace("multiply","*")
term = term.replace("devide by","/")
term = term.replace("minus","-")
term = term.replace("into","*")
final = str(term)
result=teach(final)
speak(f"Output is :{result}")
def temp(query):
term = str(query)
term=term.replace("zero","")
term=term.replace("in","")
term=term.replace("what is","")
term=term.replace("temperature","")
temp_query = str(term)
if 'outside' in temp_query:
var1 = "Temperature in Haryana"
answer = teach(var1)
speak(f"{var1} is {answer}")
else:
var2 = "Temperature in"+temp_query
answer = teach(var2)
speak(f"{var2} is {answer}")
def close():
click(1341,11)
def whatsapp(name,message):
click(x=503, y=744)
sleep(2)
key='whatsapp'
write(key)
sleep(2)
click(x=568, y=175)
sleep(2)
write(name)
sleep(2)
click(x=233, y=169)
sleep(2)
write(message)
press('enter')
close()
def youtube(command):
query=str(command)
if 'pause' in query:
press_and_release('k')
elif 'mute' in query:
press_and_release('m')
elif 'unmute' in query:
press_and_release('m')
elif 'seek back' in query:
press_and_release('j')
elif 'seek front' in query:
press_and_release('l')
elif 'full screen' in query:
press_and_release('f')
elif 'film' in query:
press_and_release('t')
elif 'skip' in query:
press_and_release('l')
elif 'increase' in query:
press_and_release('shift + >')
elif 'decrease' in query:
press_and_release('shift + <')
elif 'previous' in query:
press_and_release('shift + p')
elif 'next' in query:
press_and_release('shift + n')
elif 'search' in query:
click(x=550, y=98)
search=query.replace("youtube","")
search1=search.replace("search","")
write(search1)
sleep(1)
press('enter')
def date_converter(query):
date = query.replace(" and ","-")
date = query.replace(" and","-")
date = query.replace("and ","-")
date = query.replace("and","-")
date = query.replace(" ","")
return str(date)
def NasaNews(date):
api_key="XNN3qHB7sIu5egaoKKBcUhJ4aM4yGodEHLBYfHnh"
url = "http://api.nasa.gov/planetary/apod?api_key=" + str(api_key)
Para = {'date':str(date)}
r=requests.get(url,params = Para)
data = r.json()
info = data['explanation']
title =data['title']
Img_url=data['url']
image_r = requests.get(Img_url)
FileName = str(date)+'.jpg'
with open(FileName,'wb') as f:
f.write(image_r.content)
path1="C:\\Users\\abc\\Desktop\\MY AI PROJECT\\"+str(FileName)
path2="C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
img_space\\"+str(FileName)
os.rename(path1,path2)
img=Image.open(path2)
img.show()
speak(title)
speak(f"According to nasa:{info}")
def Summary(body):
value=str(random.randrange(1,16))
if '1' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\1.jpeg")
elif '2' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\2.jpeg")
elif '3' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\3.jpeg")
elif '4' in value:
os.startfile("C:C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\4.jpeg")
elif '5' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\5.jpeg")
elif '6' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\6.jpeg")
elif '7' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\7.jpeg")
elif '8' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\.jpeg")
elif '9' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\9.jpeg")
elif '10' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\10.jpeg")
elif '11' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\11.jpeg")
elif '12' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\12.jpeg")
elif '13' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\13.jpeg")
elif '14' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\14.jpg")
elif '15' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\15.jpg")
name = str(body)
url = "https://hubblesite.org/api/glossary/"+str(name)
url1=url.replace(" ","")
r=requests.get(url1)
data=r.json()
if len(data) != 0:
info = data['defination']
speak(f'according to my database : \n{info}')
else:
speak("No data available , Try Again later")
def isstracker():
url = "http://api.open-notify.org/iss-now.json"
r=requests.get(url)
data=r.json()
dt=data['timestamp']
lat = data['iss_position']['latitude']
long = data['iss_position']['longitude']
print(f"time and date:{dt}")
print(f"latitude:{lat}")
print(f"longitude:{long}")
plot.figure()
ax=plot.axes(projection = cart.PlateCarree())
ax.stock_img()
plot.scatter(float(long),float(lat),color = 'blue',marker = ".")
plot.show()
def email_alert(subject,body,to):
msg=EmailMessage()
msg.set_content(body)
msg['subject']=subject
msg['to']=to
user="[email protected]"
msg['from']=user
password="wvekznfuyqhihyot"
server=smtplib.SMTP("smtp.gmail.com",587)
server.starttls()
server.login(user,password)
server.send_message(msg)
server.quit()
speak("sir i have send the mail to",user)
if __name__ =='__main__':
wish_me()
takecommand()
while True:
query = takecommand().lower()
if 'zero' in query:
try:
speak('Exploring the data....')
query = query.replace("zero","")
results = wikipedia.summary(query,sentences=2)
speak("On Analysing my data i found that ")
speak(results)
except:
speak("i did not get any suitable result")
webbrowser.open("https://dronacharya.info/ggnresults/GetResult.aspx")
elif 'news' in query:
webbrowser.open("https://timesofindia.indiatimes.com/?from=mdr")
elif 'search' in query:
name=query.replace("search","")
Name = str(name)
string="https://www."+Name+".com"
string2=string.replace(" ","")
webbrowser.open(string2)
Name=str(name)
call(Name)
NASA.py
import requests
import os
from PIL import Image
import pyttsx3
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import datetime
import random
api_key="XNN3qHB7sIu5egaoKKBcUhJ4aM4yGodEHLBYfHnh"
def Summary(body):
value=str(random.randrange(1,16))
if '1' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\1.jpeg")
elif '2' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\2.jpeg")
elif '3' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\3.jpeg")
elif '4' in value:
os.startfile("C:C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\4.jpeg")
elif '5' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\5.jpeg")
elif '6' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\6.jpeg")
elif '7' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\7.jpeg")
elif '8' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\.jpeg")
elif '9' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\9.jpeg")
elif '10' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\10.jpeg")
elif '11' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\11.jpeg")
elif '12' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\12.jpeg")
elif '13' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\13.jpeg")
elif '14' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\14.jpg")
elif '15' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\15.jpg")
name = str(body)
url = "http://hubblesite.org/api/v3/features/"+str(name)
r=requests.get(url)
data=r.json()
if len(data) != 0:
info = data['defination']
speak(f'according to my database : {info}')
else:
speak("No data available , Try Again later")
engine= pyttsx3.init('sapi5')
voices= engine.getProperty('voices')
engine.setProperty('voices',voices[1].id)
engine.setProperty('rate',170)
def speak(audio):
print(" ")
print(f": {audio}")
print(" ")
engine.say(audio)
engine.runAndWait()
def NasaNews(date):
Img_url=data['url']
image_r = requests.get(Img_url)
FileName = str(date)+'.jpg'
with open(FileName,'wb') as f:
f.write(image_r.content)
path1="C:\\Users\\abc\\Desktop\\MY AI PROJECT\\"+str(FileName)
path2="C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
img_space\\"+str(FileName)
os.rename(path1,path2)
img=Image.open(path2)
img.show()
speak(title)
speak(f"According to nasa:{info}")
def mars():
name='curiosity'
date = '2020-12-3'
api="2WbrclsQaBuGd75awgpZhonwK5cKSKRjQkxZasJQ"
api_ = str(api)
url =f"https://api.nasa.gov/mars-photos/api/v1/rovers/{name}/photos?
earth_date{date}&api_key{api}"
print(url)
def isstracker():
url = "http://api.open-notify.org/iss-now.json"
r=requests.get(url)
data=r.json()
dt=data['timestamp']
lat = data['iss_position']['latitude']
long = data['iss_position']['longitude']
print(f"time and date:{dt}")
print(f"latitude:{lat}")
print(f"longitude:{long}")
plt.figure()
ax=plt.axes(projection = ccrs.PlateCarree())
ax.stock_img()
plt.scatter(float(long),float(lat),color = 'blue',marker = ".")
plt.show()
def Astro(start_date,end_date):
url =f"http://api.nasa.gov/neo/rest/v1/feed?
start_date={start_date}&end_date={end_date}&api_key={api_key}"
try:
r=requests.get(url)
Data=r.json()
tb=Data['element_count']
print(tb)
neo =Data['near_earth_objects']
speak(f"Total asteroid betweer {start_date} and {end_date} is :{tb}")
for body in neo[start_date]:
id = body['id']
name = body['name']
absolute =body['absolute_magnitude_h']
print(id,name,absolute)
except:
speak("Date gap is very large")
def astrobody(body):
url=f"https://api.le-systeme-solaire.net/rest/bodies/"+str(body)
rrr = requests.get(url)
data=rrr.json()
number=len(data)
mass=data['mass']['massValue']
volume = data['vol']['volValue']
density = data['density']
gravity = data['gravity']
escapev = data['escape']
speak(f"number of bodies : {number} ")
speak(f"Mass of {body} : {mass} M?")
speak(f"volume of {body} : {volume}AU ")
speak(f"density of {body} : {density}km3 ")
speak(f"gravity of {body} : {gravity} ")
speak(f"Escape Velocity of {body} : {escapev}m/s ")
astrobody("earth")\\ put name of desired body to be automated***