Professional Documents
Culture Documents
Import Subprocess
Import Subprocess
import wolframalpha
import pyttsx3
import tkinter
import json
import random
import operator
import speech_recognition as sr
import datetime
import wikipedia
import webbrowser
import os
import winshell
import pyjokes
import feedparser
import smtplib
import ctypes
import time
import requests
import shutil
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)
def speak(audio):
engine.say(audio)
engine.runAndWait()
def wishMe():
hour = int(datetime.datetime.now().hour)
else:
speak(assname)
def username():
uname = takeCommand()
speak("Welcome Mister")
speak(uname)
columns = shutil.get_terminal_size().columns
print("#####################".center(columns))
print("#####################".center(columns))
def takeCommand():
r = sr.Recognizer()
print("Listening...")
r.pause_threshold = 1
audio = r.listen(source)
try:
print("Recognizing...")
print(e)
return "None"
return query
server.ehlo()
server.starttls()
server.close()
if __name__ == '__main__':
clear()
wishMe()
username()
while True:
query = takeCommand().lower()
if 'wikipedia' in query:
speak('Searching Wikipedia...')
speak("According to Wikipedia")
print(results)
speak(results)
webbrowser.open("google.com")
webbrowser.open("stackoverflow.com")
# music_dir = "G:\\Song"
music_dir = "C:\\Users\\GAURAV\\Music"
songs = os.listdir(music_dir)
print(songs)
codePath = r"C:\\Users\\GAURAV\\AppData\\Local\\Programs\\Opera\\launcher.exe"
os.startfile(codePath)
try:
content = takeCommand()
sendEmail(to, content)
except Exception as e:
print(e)
try:
speak("What should I say?")
content = takeCommand()
to = input()
sendEmail(to, content)
except Exception as e:
print(e)
assname = query
assname = takeCommand()
speak(assname)
exit()
speak(pyjokes.get_joke())
client = wolframalpha.Client(app_id)
indx = query.lower().split().index('calculate')
answer = next(res.results).text
webbrowser.open(query)
os.startfile(power)
ctypes.windll.user32.SystemParametersInfoW(20,
0,
"Location of wallpaper",
0)
appli = r"C:\\ProgramData\\BlueStacks\\Client\\Bluestacks.exe"
os.startfile(appli)
try:
data = json.load(jsonObj)
i=1
print(item['description'] + '\n')
i += 1
except Exception as e:
print(str(e))
ctypes.windll.user32.LockWorkStation()
subprocess.call('shutdown / p /f')
speak("for how much time you want to stop jarvis from listening commands")
a = int(takeCommand())
time.sleep(a)
print(a)
location = query
speak(location)
subprocess.call(["shutdown", "/r"])
speak("Hibernating")
subprocess.call("shutdown / h")
time.sleep(5)
subprocess.call(["shutdown", "/l"])
note = takeCommand()
snfm = takeCommand()
file.write(strTime)
file.write(" :- ")
file.write(note)
else:
file.write(note)
speak("Showing Notes")
print(file.read())
speak(file.read(6))
speak("After downloading file please replace this file with the downloaded one")
total_length = int(r.headers.get('content-length'))
if ch:
Pypdf.write(ch)
wishMe()
speak(assname)
city_name = takeCommand()
response = requests.get(complete_url)
x = response.json()
if x["code"] != "404":
y = x["main"]
current_temperature = y["temp"]
current_pressure = y["pressure"]
current_humidiy = y["humidity"]
z = x["weather"]
weather_description = z[0]["description"]
print(" Temperature (in kelvin unit) = " +str(current_temperature)+"\n atmospheric pressure (in hPa unit)
="+str(current_pressure) +"\n humidity (in percentage) = " +str(current_humidiy) +"\n description = " +str(weather_description))
else:
message = client.messages \
.create(
body = takeCommand(),
from_='Sender No',
to ='Receiver No'
print(message.sid)
elif "wikipedia" in query:
webbrowser.open("wikipedia.com")
speak(assname)
speak("I'm not sure about, may be you should give me some time")
client = wolframalpha.Client("API_ID")
res = client.query(query)
try:
print (next(res.results).text)
speak (next(res.results).text)
except StopIteration: