示例#1
0
def get_driver_preferences():
    """Get driver preferences.

    :return: (list) driver preferences
    """
    driver = json.loads(request.data)

    return status.get_resource(SONICROAD.load_user_preferences(driver))
示例#2
0
def get_mood():
    """Get mood update params.

    :return: (dict) params update
    """
    mood = json.loads(request.data)["mood"]

    return status.get_resource(SONICROAD.load_mood_preferences(mood))
示例#3
0
def update_params():
    """Update the params with new params.

    :return: (dict) spotify params
    """
    new_params = json.loads(request.data)

    return status.get_resource(SONICROAD.add_config_dict(new_params))
示例#4
0
def get_speed_energy():
    """Get target_energy based on speed.

    :return: (dict) energy target
    """
    speed = json.loads(request.data)["speed"]

    return status.get_resource(
        (SONICROAD.sigmoid_from_speed(speed, -0.1, 0.4, 50)))
示例#5
0
def get_day_time():
    """Get category over (among night, afternoon, morning, sunset, sunrise).

    :return: (str) day time
    """
    day_time = json.loads(request.data)

    return status.get_resource(
        SONICROAD.category_from_now_sunset_sunrise_time(**day_time))
示例#6
0
def get_recommendations():
    """Get spotify get_recommendations.

    :return: (dict) spotify get_recommendations
    """
    params = json.loads(request.data)

    return status.get_resource(
        SONICROAD.get_recommendations_from_params(params))
def get_face_from_image():
    """Get the face'name from a picture.

    :return: (src) face'name
    """
    try:
        data = base64.b64decode(json.loads(request.data.decode())["data"])
    except Exception as _:
        data = base64.b64decode(json.loads(request.content.decode())["data"])
    img = np.fromstring(data, np.uint8)
    img = cv2.imdecode(img, cv2.IMREAD_COLOR)

    return status.get_resource(FACE_MODEL.predict(img))
示例#8
0
def get_landscape_from_image():
    """Get the landscape from a picture.

    :return: (src) landscape
    """
    try:
        data = request.data
    except Exception as _:
        data = request.content
    img = np.fromstring(data, np.uint8)
    img = cv2.imdecode(img, cv2.IMREAD_COLOR)

    return status.get_resource(LANDSCAPE_MODEL.predict(img))
示例#9
0
def get_mood_from_image():
    """Get the mood from a picture.

    :return: (src) mood
    """
    try:
        data = base64.b64decode(json.loads(request.data.decode())["data"])
    except Exception as _:
        data = base64.b64decode(json.loads(request.content.decode())["data"])

    img_array = np.fromstring(data, np.uint8)
    img = cv2.imdecode(img_array, cv2.IMREAD_COLOR)

    return status.get_resource(MOOD_MODEL.predict(img))
示例#10
0
def sound_to_play():
    """Define which sound to play based on poi.

    :return: (list) sound key
    """
    dict_poi = json.loads(request.data)
    l_sounds = []
    for k, v in dict_poi.items():
        if "stadium" in v[0]:
            l_sounds.append("stadium")
        if 'museum' in v[0]:
            l_sounds.append("museum")
        if "park" in v[0]:
            l_sounds.append("park")
        if "school" in v[0]:
            l_sounds.append("school")
        if "church" in v[0]:
            l_sounds.append("church")

    return status.get_resource(l_sounds)
示例#11
0
def get_speed():
    """Get speed from gps.

    :return: (dict) speed
    """
    return status.get_resource(GPS.get_speed_from_gps())
示例#12
0
def get_latlon():
    """Get latlon from gps.

    :return: (dict) latlon
    """
    return status.get_resource(GPS.get_latlon_from_gps())
示例#13
0
def get_params():
    """Get the spotify params.

    :return: (dict) spotify params
    """
    return status.get_resource(SONICROAD.rules)