Exemplo n.º 1
0
def setReminder(intent):
    reminders = models.Reminder.readReminders("reminder.p")
    speech.speak(intent)
    text = speech.takeCommand()
    speech.speak("when is this reminder due")
    dueDate = speech.takeCommand()
    reminder = models.Reminder(text, dueDate)
    speech.speak("Reminder set for " + reminder.dueDate)
    if speech.confirmCommand():
        reminders.append(reminder)
        models.Reminder.writeReminders(reminders, "reminder.p")
        speech.speak("Ok, done")
    else:
        speech.speak("You didn't confirm, canceling command")
Exemplo n.º 2
0
def takeNotes(intent):
    speech.speak(intent)
    note = speech.takeCommand()
    with open("notes.txt", 'a') as f:
        f.write(note)
        f.write("\n---------------------\n")
    speech.speak("Note added.")
Exemplo n.º 3
0
def downloadMusic(intent):
    speech.speak(intent)
    songName = speech.takeCommand()
    confirmed = speech.confirmCommand()

    if confirmed:
        try:
            
            searchLink = 'https://www.youtube.com/results?search_query={}'.format(songName.replace(" ", "+"))
            htmlPage = urllib.request.urlopen(searchLink)
            video_ids = re.findall(r"watch\?v=(\S{11})", htmlPage.read().decode())
            videoLink = "https://www.youtube.com/watch?v=" + video_ids[0]
            
            video = YouTube(videoLink)
            speech.speak("downloading a song called, {}".format(video.title))
            
            audio = video.streams.last()
            if len(settings['music_folder']) < 1:
                musicPath = os.path.expanduser("~/Desktop")
            else:
                musicPath = settings['music_folder']
            
            audio.download(musicPath)

        except TimeoutError:
            speech.speak("sorry something went wrong, probably the internet connection")
        except Exception as e:
            speech.speak("An error occured, try again later : ", e)
        
        speech.speak("Done downloading.")

    else:
        speech.speak("you did not confirm, canceling song request")
Exemplo n.º 4
0
def startWordProject(intent):
    speech.speak(intent)
    docName = speech.takeCommand()
    speech.speak("ok, creating document")
    doc = docx.Document()
    doc.add_paragraph(docName)
    fileName = os.path.expanduser("~/Desktop") + "\\" + docName + ".docx"
    doc.save(fileName)
    os.startfile(fileName)
Exemplo n.º 5
0
def takeBreak(intent):
    speech.speak(intent)
    minutes = speech.takeCommand()
    minutes = re.findall(r'\d+', minutes)
    if minutes:
        speech.speak("ok sleeping for " + minutes[0] + "minutes")
        sleep(int(minutes[0])*60)
        speech.speak("hi, I'm back")
    else:
        speech.speak("Sorry didnt catch that, canceling command")
Exemplo n.º 6
0
def playMusic(intent):
    speech.speak(intent)
    songName = speech.takeCommand()
    speech.speak("ok, on it")
    try:
        searchLink = 'https://www.youtube.com/results?search_query={}'.format(songName.replace(" ", "+"))
        htmlPage = urllib.request.urlopen(searchLink)
        video_ids = re.findall(r"watch\?v=(\S{11})", htmlPage.read().decode())
        videoLink = "https://www.youtube.com/watch?v=" + video_ids[0]
    except TimeoutError:
        speech.speak("internet connection error occured, try again later")
    webbrowser.open(videoLink, new=2)
    return True
Exemplo n.º 7
0
def mainLoop(app):

    while True:

        speech.waitForWakeupCall("kiwi")
        working = True
        counter = 0

        while working:
            counter += 1
            message = speech.takeCommand()

            if counter > 5:
                message = "enough work for today"
                working = assistant.request(message)
                break
            else:
                working = assistant.request(message)

        if "exit" in message:
            break
    app.destroy()
Exemplo n.º 8
0
def play():

    speak("Ok, what song do you want to listen ?")

    song = s.takeCommand()
    song = song.lower()
    #song = "zikr by desert rock"
    speak("Ok, playing song "+song)

    param = 'youtube-dl -j --dump-json "ytsearch1:{}"'.format(song)

    status, output = subprocess.getstatusoutput(param)
    output = str(output)
    res = json.loads(output)

    ur = res['webpage_url']
    dur = res['duration']

    url = ur
    video = pafy.new(url)
    best = video.getbestaudio()
    media = vlc.MediaPlayer(best.url)
    media.play()
    time.sleep(dur)
Exemplo n.º 9
0
            mu.play()

        elif 'the time' in query:
            strTime = datetime.datetime.now().strftime("%H:%M")
            speak(f"Soorya, the time is {strTime}")

        elif ('weather' in query) or ('climate' in query):
            weather = we.weath()
            speak("Ok scanning the sky to get the weather information...")
            speak("The current weather conditions are as follows, the relative humidity is "+str(weather[0][0])+
                  "percent, the current temperature is "+str(weather[0][1])+
                  "degree celsius. The average wind speed is "+str(weather[0][2])+
                  "kilometer per hour and possibility of "+str(weather[0][3]))

            speak("would you like to know tomorrows weather as well ?")
            tommy = s.takeCommand()
            tommy = tommy.lower()
            #tommy = 'no'
            if 'yes' in tommy:
                speak("Ok, so tomorrows weather is going to be as follows, the relative humidity shall be " + str(weather[1][0]) +
                      "percent, tommorows expected day temperatures might be  " + str(weather[1][1]) +
                      "degree celsius. The average wind speed will be around " + str(weather[1][2]) +
                      "kilometer per hour and possibility of " + str(weather[1][3]))
            elif 'no' in tommy:
                speak('hey, hope that knowing the weather has not spoiled your plans for today hahaha')

        elif 'plant' in query:
            speak('Ok, collecting and analyzing the plant information from my sources....')
            pc.planty()

        elif ('analyze' in query) or ('analyse' in query) or ('animal' in query) or ('general' in query) or ('scan' in query):
Exemplo n.º 10
0
def search(intent):
    speech.speak(intent)
    searchTopic = speech.takeCommand()
    speech.speak("This is what i found for " + searchTopic)
    webbrowser.open("https://www.google.com.tr/search?q={}".format(searchTopic.replace(" ", "+")), new=2)