Beispiel #1
0
def get_news():
    headlines = []
    for article in articles:
        headlines.append(article['title'])
    assistant.speak('Today\'s top 5 Headlines are:')
    for i in range(len(day)):
        assistant.speak(f'{day[i]} headline: {headlines[i]}')
def search_youtube(query):
    try:
        assistant.speak(f'Searching for {query}')
        webbrowser.open(
            f'https://www.youtube.com/results?search_query={query}')
    except:
        assistant.speak(f'Could not find information on {query}')
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()
Beispiel #4
0
def get_weather():
    try:
        search = 'temperature in delhi'
        url = f'https://www.google.com/search?q={search}'
        req = requests.get(url)
        data = BeautifulSoup(req.text, 'html.parser')
        temp = data.find('div', class_='BNeawe').text
        assistant.speak(f'Current {search} is {temp}')
    except:
        assistant.speak('Unable to connect to satellite')
Beispiel #5
0
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 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 perform_calculations(command):
    assistant.speak(f'Calculating {command}')
    try:
        assistant.speak(
            f'Your result is: {eval_binary_expr(*(command.split()))}')
    except:
        assistant.speak(
            'I am unable to calculate. I guess I am not smarter than a 12 year old'
        )
        pass
def get_current_location():
    assistant.speak('checking sir')
    try:
        ipAdd = requests.get('https://api.ipify.org').text
        print(ipAdd)
        url = (f'https://get.geojs.io/v1/ip/geo/{ipAdd}.json')
        geo_requests = requests.get(url)
        geo_data = geo_requests.json()
        print(geo_data)
        city = geo_data['city']
        country = geo_data['country']
        region = geo_data['region']
        latitude = geo_data['latitude']
        longitude = geo_data['longitude']
        assistant.speak(
            f'I believe we are in a city named {city} in {country}')
        assistant.speak(
            f'It is the {region}. Longitude: {longitude}, Latitude: {latitude}'
        )
    except Exception as e:
        assistant.Speak(
            'Sorry, due to network issues could not find current location.')
        pass
def search_google(query):
    assistant.speak(f'Searching for {query}')
    try:
        pywhatkit.search(query)
    except:
        assistant.speak(f'Could not find information on {query}')
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 gratitude_module(command):
    if ('thank you' in command and 'goodnight' in command) or \
         ('thank you' in command and 'good night' in command) or \
         ('thankyou' in command and 'good night' in command) or \
         ('thankyou' in command and 'goodnight' in command):
        assistant.speak('Always at your service sir!')
        assistant.speak('Good Night!')
        assistant.speak('Let me know when you need me')
        return 'sleep'

    elif ('thank you' in command and 'bye bye' in command) or \
         ('thank you' in command and 'byebye' in command) or \
         ('thankyou' in command and 'bye bye' in command) or \
         ('thankyou' in command and 'byebye' in command):
        assistant.speak('Always at your service sir!')
        assistant.speak('Good Bye!')
        assistant.speak('Let me know when you need me')
        return 'sleep'

    elif ('thank you' in command and 'goodbye' in command) or \
         ('thank you' in command and 'good bye' in command) or \
         ('thankyou' in command and 'good bye' in command) or \
         ('thankyou' in command and 'goodbye' in command):
        assistant.speak('Always at your service sir!')
        assistant.speak('Good Bye!')
        assistant.speak('Let me know when you need me')
        return 'sleep'

    elif 'goodbye' in command or 'good bye' in command:
        assistant.speak('Good bye sir!')
        assistant.speak('Let me know when you need me')
        return 'sleep'

    elif 'goodnight' in command or 'good night' in command:
        assistant.speak('Good night sir!')
        assistant.speak('Let me know when you need me')
        return 'sleep'

    elif 'thank you' in command or 'thankyou' in command:
        response_dict = [
            'glad to help sir', 'you\'re being too formal sir', 'anytime sir',
            'always at your service sir'
        ]
        assistant.speak(random.choice(response_dict))
        return 'none'
Beispiel #12
0
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.')
Beispiel #13
0
def close_module(command):
    if 'explorer' in command:
        assistant.speak('Closing file explorer')
        os.system('taskkill /f /im explorer')

    elif 'close vs code' in command or 'flutter' in command:
        try:
            vsCodePath = 'S:\\Development\\Tools\\Microsoft VS Code\\Code.exe'
            assistant.speak('Closing VS Code')
            os.system(f'taskkill /f /im {vsCodePath}')
        except:
            assistant.speak('VS Code is not open')

    elif 'close android studio' in command or 'android' in command:
        try:
            studioPath = 'S:\\Development\\Tools\\Android Studio\\bin\\studio64.exe'
            assistant.speak('Closing Android Studio')
            os.system(f'taskkill /f /im {studioPath}')
        except:
            assistant.speak('Android studio is not open')

    elif 'close sublime' in command or 'close note pad' in command or 'close notepad' in command:
        try:
            sublimePath = 'C:\\Program Files\\Sublime Text 3\\sublime_text.exe'
            assistant.speak('Opening Sublime Text editor')
            os.system(f'taskkill /f /im {sublimePath}')
        except:
            assistant.speak('Sublime text is not open')

    elif 'close python ide' in command or 'python' in command:
        try:
            pycharmPath = 'S:\\Development\\Tools\\PyCharm Community Edition 2021.1\\bin\\pycharm64.exe'
            assistant.speak('Closing PyCharm')
            os.system(f'taskkill /f /im {pycharmPath}')
        except:
            assistant.speak('PyCharm is not open')
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')