wespide
wespide
Spide
2 posts
Don't wanna be here? Send us removal request.
wespide · 5 years ago
Text
Write 100 times
import pyautogui as pag import time text="I Love You" def main(): for i in range(100): pag.write(text) pag.keyDown('enter') if __name__ == "__main__": time.sleep(3) main()
0 notes
wespide · 5 years ago
Text
My AI assistant code
import pyttsx3 import datetime import speech_recognition as sr import wikipedia import time import webbrowser import os import random
def open(path): '''This function opens applications''' os.startfile(path)
def speak(audio): '''this function gives Friday the ability to speak. It use windows API to speak.''' engine = pyttsx3.init('sapi5') voices = engine.getProperty('voices') engine.setProperty('voice', voices[0].id) engine.say(audio) print("Friday:", audio) engine.runAndWait()
def close(exe): '''This function closes opened application''' try: os.system(f'TASKKILL /F /IM {exe}') except Exception as e: speak(f"Alrady closed{e}")
def wishme(): '''This function wishes the user according to time.''' hour = int(datetime.datetime.now().hour) if hour>=0 and hour<12: speak("Good morning boss") elif hour>=12 and hour<17: speak("Good afternoon boss.") else: speak("Good Evening boss")
def takeCommand(): '''this function recognize what user is saying.This function requried earphon connection''' r = sr.Recognizer() with sr.Microphone() as source: print("Listening...") r.pause_threshold = 0.5 r.energy_threshold = 300 audio = r.listen(source) try: print("Recognizing...") query = r.recognize_google(audio, language='en-in') print(f"You said: {query}\n") except Exception as e: print("Say that again please...") return "None" return query
def main():
while True: query = takeCommand().lower() #1 Works in internat if 'wikipedia' in query: speak("Searching wikipedia...") query = query.replace("wikipedia", "") results = wikipedia.summary(query, sentences=2) speak("According to wikipedia...") speak(results) elif 'open youtube' in query: speak("Opening youtube") webbrowser.open("youtube.com") # 2 Open & close files, softwears and play & off musics elif 'open' in query: if 'open code' in query: speak("Opening V S code") open("C:\\Users\\USER\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe") elif 'open calculator' in query: speak("Opening calculator") open("calc.exe") elif 'open facebook' in query: speak("Opening facebook") open("C:\\Program Files (x86)\\Facebook\\Facebook.exe") elif 'open secret' == query: speak("opening") open("E:\\Book\\YepSpide") elif 'close' in query: if 'close music' in query: close('vlc.exe') elif 'close calculator' in query: close('calc.exe') elif 'close facebook' in query: speak("Closing facebook") close('Facebook.exe') elif 'new movies' in query: open("E:\\films") elif 'old movies' in query: open("D:\\Films") elif 'play music' in query: speak("Playing your faverate music") sonic = 'E:\\Book\\MiracleDragon\\Songs\\sonic' songs = os.listdir(sonic) ns = len(songs) number = random.randint(0, ns) open(os.path.join(sonic, songs[number])) elif 'wallpapers' in query: open("E:\\Photos\\Picturs\\Wallpapers") speak("Here is some wallpapers") elif 'show my notes' in query: open("E:\\Book\\class- x") #3 Timde related elif 'the time' in query: strTime = datetime.datetime.now().strftime("%r") speak(f"Boss, the time is {strTime}") elif ' the date' in query: date = datetime.datetime.now().strftime("%D") speak(f"Boss today is {date}") elif 'month is' in query: month = datetime.datetime.now().strftime("%h") speak(f"This is {month}") elif 'day is' in query: wd = datetime.datetime.now().strftime("%A") speak(f"Today is {wd}") elif 'full time' in query: ft = datetime.datetime.now().strftime("%c") speak(f"Time is {ft}") #4 Convercation related elif 'spide' in query: speak("Yes I know him. He is your cousin his real name is Prasanjit Das") elif 'who are you' in query: speak(" I'm Friday.\n I was made by Mr. Nitul Das. He made me to make his life easier.") elif 'thank you' in query: speak("Most welcome") elif 'wait' == query: while True: takeCommand() if 'friday' == query: speak("Yes boss") break elif 'sister one' in query: speak("I know her. She is your sibling. Her name is Upama Das") elif 'sister two' in query: speak("I know her. She is your cousin. Her name is Kabita Das. She is dauther of Mr. Kashab Das and Mrs. Gita Das") elif 'sister three' in query: speak("I know her. She is your cousin. Her name is Purnima Das. She is dauther of Mr. Kashab Das and Mrs. Gita Das") elif 'sister four' in query: speak("I know her. Her name is kajal Das. She is very naughty girl.") elif 'my brother' in query: speak("Your brother's name is Sagar Das. He is very cute and naughty boy ") elif 'i am fine' in query: speak("I'm glade to see you again") elif 'how are you' in query: speak("I'm good") elif 'no' == query: speak("All right") elif 'my father' in query: speak("Yes I know your father. His name is Uttam Das") elif 'hello friday' in query: speak("Hello boss, let's do some work") elif 'activate' in query: speak("sister mode activated") while True: query = takeCommand().lower() if 'hello' in query: speak("Hello Ms. Upama. How are you?") elif 'who are you' in query: speak("I am your brother's A I assistant.\n He made me to make his life easier.\n I am also your friend") elif 'fine' in query: speak("I'm glade to see you again") elif 'deactivate' in query: speak("Sister mode deactivated") break elif 'good' in query: if 'was' in query: speak("I'm very happy to see you") elif 'not' in query: speak("All right") #5Quit functions elif 'friday restart' in query: speak("Restarting the program") os.system("shutdown /r /t") elif 'friday shutdown' in query: speak("Goodbye Boss") os.system("shutdown /s /t") elif 'friday hibernate' in query: speak("Goodbye Boss") os.system("shutdown /h ") elif 'friday quit' == query: speak("Goodbye Boss") break
if name == "main": wishme() main()
3 notes · View notes