예제 #1
0
def chooseIntent(response):
    # convert all responses to uniform lower-case
    intent = getIntent(response)
    intent = intent.lower()

    print(intent)

    # parse for commands:
    if intent == "playaudio":
        mpdCommands("playPlaylist", "welcome to the house")  # default hype playlist
        mpdCommands("playSong", None)
    elif intent == "playplaylist":
        voice("playing the playlist " + getEntities(response)["playlist"][0]["value"])
        mpdCommands("playPlaylist", getEntities(response)["playlist"][0]["value"])
        mpdCommands("playSong", None)
    elif intent == "stopsong":
        print("this should stop the song")
        mpdCommands("pauseSong", None)
        print("no?")
    elif intent == "nextsong":
        mpdCommands("nextSong", None)
    elif intent == "appreciation":
        voice("no problem")
    elif intent == "weather":
        loc = getEntities(response)["location"]["value"]
        weatherLocation(loc)
    else:
        main()
        return
    main()
예제 #2
0
def chooseIntent(response):
    # convert all responses to uniform lower-case
    intent = getIntent(response)
    intent = intent.lower()

    print(intent)

    # parse for commands:
    if (intent == 'playaudio'):
        mpdCommands("playPlaylist", "welcome to the house") # default hype playlist
        mpdCommands("playSong", None)
    elif (intent == 'playplaylist'):
        voice("playing the playlist " + getEntities(response)['playlist'][0]['value'])
        mpdCommands("playPlaylist", getEntities(response)['playlist'][0]['value'])
        mpdCommands("playSong", None)
    elif (intent == 'stopsong'):
        mpdCommands('pauseSong', None)
    elif (intent == 'nextsong'):
        mpdCommands('nextSong', None)
    elif (intent == 'appreciation'):
        voice("no problem")
    elif (intent == 'weather'):
        loc = getEntities(response)['location']['value']
        if loc == 'errorparse':
            data = open("config.json")
            data = json.loads(data)
            weatherLocation(data["zip"])
        weatherLocation(loc)
    else: 
        main()
        return
    main()
예제 #3
0
def queryWolfram(query):
    res = client.query(query)
    interpretation = res
    result = res.pods[1].text.encode('utf-8').strip()

    print result
    # This part is used if you want to format a certain response from the text given 
    # back to you from WolframAlpha. 
    if ('weather' or 'forecast' in response):
        voice(result)
예제 #4
0
def weatherLocation(location):
    response = urllib2.urlopen("http://api.aerisapi.com/forecasts/" + location + "?client_id=" + client_id + "&client_secret=" + client_secret).read()
    weather = json.loads(response)
    if weather['success']:
        period = weather['response'][0]['periods'][0]
        tempAvg = period['avgTempF']
        tempMax = period['maxTempF']
        tempMin = period['minTempF']
        precip = period['pop']
        snow = period['snowIN']
        wind = str(period['windGustMPH'])
        # voice output
        voice("The current weather in " + location + " is " + str(period['weather']))
        voice ("There will be a high of " + str(tempMax) + "and low of " + str(tempMin) + " degrees fahrenheit, with a " + str(precip) + " percent chance of rain.")
        voice(weatherComment(tempAvg, precip, snow))
    else: 
        print("An error has occured:" + weather['error']['description'])
예제 #5
0
def checkStartup(intent):
    # convert all responses to uniform lower-case
    intent = intent.lower()

    # if intent is to "startup" we call to the initiate function
    if(intent == 'startup'):
        os.system('aplay -D plughw:1 ~/Repos/Personal-Assistant/sounds/initialization_beep.wav')
        voice('what is up richard?')
        mainQuery()
        return
    elif (intent == 'appreciation'):
        voice("no problem")
        main()
        return
    elif (intent == 'terminate'):
        voice("farewell Richard")
        return
    # if there is no intent we have no command and we wait for another one
    else:
        main()
        return
예제 #6
0
def doubleChargeMeFoDat():
    voice("Ohhhhhhh, don't double charge me fo dat")
예제 #7
0
def mpdCommands(command, query):
    # Plays the next song
    if command == 'playSong':
        voice("playing song")
        client.play()
    elif command == 'nextSong':
        voice("playing next song")
        client.next()
    # Plays the previous song
    elif command == 'prevSong':
        client.previous()
        voice("playing previous song")
    # Pauses/Plays the current song
    elif command == 'pauseSong':
        data = client.status()
        state = data['state']
        if state == 'pause':
            voice("song resumed")
            client.pause()
        else: 
            client.pause()
            voice("song paused")
    # Voices the current song playing
    elif command == 'currentSong':
        client.setvol(5)
        data = client.currentsong()
        currentSong = data['title']
        artist = data['artist']
        voice("the current song is" + currentSong + " by " + artist)
        client.setvol(20)
    # Sets the volume for the MPD: 
    # NOT IMPLEMENTED
    elif command == 'setVolume':
        if query == 'less':
            client.volume(-10)
        elif query == 'more':
            client.volume(10)
        else:
            return
    # QUERY FUNCTIONS
    # query
    elif command == 'querySong':
        return
        # NOT IMPLEMENTED
    # Loads a playlist the user queries
    elif command == 'playPlaylist':
        client.load(query)
    else: 
        #do nothing
        return