def run_movie(command): print('User: '******'surprise me' in command or 'you pick one' in command or 'choose' in command or 'you pick' in command or\ 'you pic' in command: assistant.speak('Playing my favorite movie.') play_movie() while like_movie is False: assistant.speak('Do you like it?') command = assistant.takeCommand() if 'no' in command or 'change movie' in command or 'pick a different movie' in command or\ 'change the movie' in command: assistant.speak('Playing a different movie.') play_movie() elif 'yes' in command or 'thank you' in command or 'thankyou' in command: like_movie = True assistant.speak('Enjoy the movie sir.') else: if 'none' in command or command is None: assistant.speak('I did not get you. Please repeat the movie name') command = assistant.takeCommand() run_movie(command) else: search_google(command + ' watch online') # if __name__ == "__main__": # get_movie()
def search_wiki(query): assistant.speak(f'Asking Wiki about {query}') try: result = wikipedia.summary(query, sentences=1) assistant.speak(result) assistant.speak('Anything else sir?') command = assistant.takeCommand() if 'no' in command: assistant.speak('Okay.') elif 'repeat' in command: assistant.speak(result) elif 'yes' in command: assistant.speak('What do you want to know about?') command = assistant.takeCommand() if 'who is' in command: query = command.replace('who is', '') search_wiki(query) elif 'what is' in command: query = command.replace('what is', '') search_wiki(query) elif 'tell me about' in command: query = command.replace('tell me about', '') search_wiki(query) else: search_wiki(command) except: assistant.speak(f'Wiki has no information on {query}') assistant.speak('Anything else sir?') command = assistant.takeCommand() if 'no' in command: assistant.speak('Okay.') elif 'yes' in command: assistant.speak('What do you want to know about?') command = assistant.takeCommand() if 'who is' in command: query = command.replace('who is', '') search_wiki(query) elif 'what is' in command: query = command.replace('what is', '') search_wiki(query) elif 'tell me about' in command: query = command.replace('tell me about', '') search_wiki(query) elif 'none' in command or command is None: pass else: assistant.speak('I did not quite get you.')
def run_assistant(self): self.counter = 0 assistant.speak('Greetings, I am Jarvis.') while True: self.permission = assistant.takeCommand() if 'terminate' in self.permission or 'i don\'t need you' in self.permission or 'i do not need you' in self.permission: sys.exit() elif 'friday' in self.permission: self.counter += 1 assistant.run_friday(self.counter) elif 'wake up' in self.permission or 'wakeup' in self.permission: hour = int(datetime.datetime.now().hour) if (hour >= 23 and hour < 24) or (hour >= 0 and hour < 9): if (hour >= 23 and hour < 24) or (hour >= 0 and hour < 4): assistant.speak('Please let me sleep sir, It\'s pretty late') elif (hour >= 4 and hour < 9): assistant.speak('Please let me sleep sir, It\'s quite early') response = assistant.takeCommand().lower() if 'ok' in response or 'sleep' in response: assistant.speak('Thank you.') elif 'no' in response or 'wake up' in response or 'wakeup' in response: assistant.speak('Okay. I\'ll be up in a few seconds') time.sleep(5) self.counter += 1 assistant.run_jarvis(self.counter) elif 'jarvis' in self.permission or 'are you up' in self.permission: self.counter += 1 # self.Runner.change_animation('S:\\Development\\Python\\jarvis_voiceai\\resources\\listening.gif') assistant.run_jarvis(self.counter)
def get_howto_result(command): assistant.speak(f'Searching database for {command}') try: max_results = 1 how_to = search_wikihow(command, max_results) assert len(how_to) == 1 how_to[0].print() assistant.speak(how_to[0].summary) assistant.speak('Anything else sir?') command = assistant.takeCommand() if 'no' in command: assistant.speak('Okay sir.') elif 'repeat' in command: assistant.speak(how_to[0].summary) elif 'how to' in command: get_howto_result(command) elif 'yes' in command: assistant.speak('What sir?') newcommand = assistant.takeCommand() get_howto_result(newcommand) except: assistant.speak(f'No information on {command}') assistant.speak('Do you wish to know about something else?') newcommand = assistant.takeCommand() if 'no' in newcommand: assistant.speak('Okay sir.') elif 'yes' in newcommand: assistant.speak('What sir?') newcommand = assistant.takeCommand() if 'i want to know about' in newcommand: newcommand = newcommand.replace('i want to know about', '') get_howto_result(newcommand) elif 'none' in newcommand or newcommand is None: pass else: assistant.speak('I did not quite get you.')
def get_specific_news(response): global content try: for i in range(len(day)): if day[i] in response: content = articles[i]['description'] assistant.speak(content) assistant.speak('Do you wish to know more about it?') resp = assistant.takeCommand().lower() if 'yes' in resp or 'yeah' in resp or 'yup' in resp: assistant.speak('Opening news on browser') webbrowser.open(articles[i]['url']) if content is None: assistant.speak('No more information on this.') except: assistant.speak('No more information on this.')
def open_module(command): if 'open youtube' in command: assistant.speak('opening youtube') webbrowser.open('www.youtube.com') elif 'open google' in command: assistant.speak('opening google') try: assistant.speak('What should I search for?') query = assistant.takeCommand() if 'none' in query or query is None: webbrowser.open('www.google.com') elif query is not None: assistant.search_google(query) except: webbrowser.open('www.google.com') elif 'open gmail' in command: assistant.speak('opening gmail') webbrowser.open('www.gmail.com') elif 'open whatsapp' in command: assistant.speak('opening whatsapp') webbrowser.open('https://web.whatsapp.com/') elif 'open facebook' in command: assistant.speak('opening facebook') webbrowser.open('www.facebook.com') elif 'open stackoverflow' in command or 'open stack overflow' in command: assistant.speak('opening stackoverflow') webbrowser.open('www.stackoverflow.com') elif 'open prime video' in command or 'open primevideo' in command: assistant.speak('opening prime video') webbrowser.open('www.primevideo.com') elif 'open netflix' in command: assistant.speak('opening netflix') webbrowser.open('www.netflix.com') elif 'chrome' in command: try: assistant.speak('opening google chrome') chrome_path = "C:\Program Files\Google\Chrome\Application\chrome.exe" os.startfile(chrome_path) except: assistant.speak('Unable to open google chrome') elif 'open calculator' in command: assistant.speak('Opening calculator') subprocess.Popen("C:\\Windows\\System32\\calc.exe") elif 'explorer' in command: assistant.speak('Opening file explorer') os.system('explorer') elif 'open vs code' in command or 'i want to work on flutter' in command or 'open code' in command: try: vsCodePath = 'S:\\Development\\Tools\\Microsoft VS Code\\Code.exe' assistant.speak('Opening VS Code') os.startfile(vsCodePath) except: assistant.speak('Could not find VS Code in given location') elif 'open android studio' in command or 'i want to build an android app' in command: try: studioPath = 'S:\\Development\\Tools\\Android Studio\\bin\\studio64.exe' assistant.speak('Opening Android Studio') os.startfile(studioPath) except: assistant.speak('Could not find Android Studio in given location') elif 'open sublime' in command or 'open note pad' in command or 'open notepad' in command: try: sublimePath = 'C:\\Program Files\\Sublime Text 3\\sublime_text.exe' assistant.speak('Opening Sublime Text editor') os.startfile(sublimePath) except: assistant.speak('Could not find Sublime text in given location') elif 'open python ide' in command or 'i want to work on python' in command or 'python' in command or 'create a new python project' in command\ or 'feel like working on python' in command: try: pycharmPath = 'S:\\Development\\Tools\\PyCharm Community Edition 2021.1\\bin\\pycharm64.exe' assistant.speak('Opening PyCharm') os.startfile(pycharmPath) except: assistant.speak('Could not find PyCharm in given location')