예제 #1
0
def playOnYoutube(query):
    query_string = urllib.parse.urlencode({"search_query": query})
    search_string = str("http://www.youtube.com/results?" + query_string)
    append_csv(search_string)
    speak("Here's what you asked for. Enjoy!")
    append_csv("jarvis : Here's what you asked for. Enjoy")
    webbrowser.open_new_tab(search_string)
def print_weather(result, city):
    p = inflect.engine()
    temperature = str("{}'s temperature {}°Celcius ".format(
        city, result['main']['temp']))
    t = str(temperature)
    temp = re.findall(r'\d+', t)
    res = list(map(int, temp))
    ntw = "temperature is " + p.number_to_words(res[0])

    speak(ntw)
    append_csv(ntw)
예제 #3
0
def greeting():
    currentH = int(datetime.datetime.now().hour)
    if currentH >= 0 and currentH < 12:
        speak('Good Morning')
        append_csv("jarvis : Good Morning")
    if currentH >= 12 and currentH < 17:
        speak('Good Afternoon')
        append_csv("jarvis : Good Afternoon")
    if currentH >= 17 and currentH != 0:
        speak('Good Evening')
        append_csv("jarvis : Good Evening")

    speak('jarvis here.')
    append_csv("jarvis : jarvis here")
    speak('What would you like me to do for you ?')
    append_csv("jarvis : What would you like me to do for you?")
예제 #4
0
def command():
    cmd = sr.Recognizer()
    with sr.Microphone() as source:
        cmd.adjust_for_ambient_noise(
            source
        )  # Adjusts the level to recieve voice even in case of noise in surroundings
        #speak('I am listening')
        print('Listening..')
        audio = cmd.listen(source)
        try:
            query = cmd.recognize_google(audio, language='en-in')
            print('User: '******'\n')
            db = "user : "******"jarvis : " + 'Sorry ! I did not get that. Could you please type it out ?'
            append_csv(j_db)
            #query = str(input('Command: '))
            # query = simpledialog.askstring("COMMAND","Enter your command")
            query = command_interface()
            jt_db = "jarvis : " + query
            append_csv(jt_db)
            print(query)
    return query
예제 #5
0
def tellAJoke():
    res = requests.get('https://icanhazdadjoke.com/',
                       headers={"Accept": "application/json"})
    if res.status_code == 200:
        speak("Okay. Here's one")
        append_csv("jarvis : Okay. Here's one")
        speak(str(res.json()['joke']))
        append_csv("jarvis : " + str(res.json()['joke']))
    else:
        speak('Oops!I ran out of jokes')
        append_csv("jarvis : Oops!I ran out of jokes")
예제 #6
0
def main_voice():

    time.sleep(5)
    while True:

        query = command()
        query = query.lower()

        if 'play music' in query or 'play a song' in query:
            speak("Here's your music. Enjoy !")
            append_csv("jarvis : Here's your music. Enjoy !")
            os.system('spotify')

        if 'find file' in query:
            speak('What is the name of the file that I should find ?')
            append_csv(
                "jarvis : What is the name of the file that I should find ?")
            query = command()
            filename = query
            print(filename)
            append_csv("jarvis : File name :- " + filename)
            speak('What would be the extension of the file ?')
            append_csv("jarvis : What would be the extension of the file ?")
            query = command()
            query = query.lower()
            extension = query
            print(extension)
            fullname = str(filename) + '.' + str(extension)
            print(fullname)
            append_csv("jarvis : Full name " + fullname)
            path = r'D:\\'
            location = find(fullname, path)
            speak('File is found at the below location')
            append_csv("jarvis : File is found at the below location")
            print(location)
            append_csv("jarvis : " + location)

        if 'search' in query:
            speak('What should I search for ?')
            append_csv("jarvis : What should I search for ?")
            query = command()
            lib = query
            url = "https://www.google.co.in/search?q=" + (str(lib)) + "&oq=" + (
                str(lib)
            ) + "&gs_l=serp.12..0i71l8.0.0.0.6391.0.0.0.0.0.0.0.0..0.0....0...1c..64.serp..0.0.0.UiQhpfaBsuU"
            webbrowser.open_new(url)
            append_csv("jarvis : " + url)

        if 'play on youtube' in query:
            speak('What should I look up for ?')
            append_csv("jarvis : What should I look up for ?")
            query = command()
            playOnYoutube(query)

        if 'joke' in query:
            tellAJoke()
        if 'temperature' in query:
            temperature()
            #append_csv("jarvis" + str(temperature()))

        if 'open word' in query:
            os.system('libreoffice word')
            append_csv("jarvis : Successfully opened word")
            speak("successfully opened word")

        if 'send an email' in query:
            speak('whom would you like to send')
            append_csv("jarvis : whom would you like to send")
            query = command()
            sender = query
            append_csv("user : "******"jarvis : what would you like to send")
            query = command()

            # creates SMTP session
            s = smtplib.SMTP('smtp.gmail.com', 587)

            # start TLS for security
            s.starttls()

            # Authentication
            s.login("*****@*****.**", "jarvis@123")

            # message to be sent
            message = query
            append_csv("jarvis : " + message)

            # sending the mail
            s.sendmail("*****@*****.**", sender, message)
            speak("mail sent")
            append_csv("jarvis : mail sent")

            # terminating the session
            s.quit()
        if 'conversation' in query:
            #read_csv()

            #path = os.getcwd()
            #print(path)
            #f_path = path+"/conversation.csv"
            #print(f_path)
            #os.startfile(f_path)
            csv_open()

        if 'that would be all' in query or 'that is it' in query or 'go to sleep jarvis' in query:
            speak('Alright. Have a nice day')
            append_csv("jarvis : Alright. Have a nice day")
            sys.exit()
예제 #7
0
def temperature():
    city = "bangalore"
    query = 'q=' + city
    w_data = weather_data(query)
    print_weather(w_data, city)
    append_csv(print_weather(w_data, city))