示例#1
0
def store_password():
    """
    Gets an image and then detects the face.  If the database is empty, then it immediately prompts for your name to create a new
    profile.  If the database is not empty but the computer can not recognize you, it prompts for your name to create a new profile. 
    Otherwise, it asks you which website do you want to save the password to.   
    """
    global descript
    global Boolean 
    global FaceGot
    img_array = get_image()
    FaceGot = detect(img_array, False)
    if (len(FaceGot) > 1):
        return statement("Sorry there are multiple people behind you")
    global BestMatch
    #print(len(db.profiles), flush = True)
    if (not(len(db.profiles)) == 0):
        #print((FaceGot[0])[0],flush = True)
        BestMatch = db.computeMatches((FaceGot[0])[0], db.profiles)
        #print(BestMatch, flush = True)
        if (BestMatch in db.profiles):
            msg = "What website do you want to save a password to. After you enter a website, follow the instructions in the computer console"
            return question(msg)
        else:
            Boolean = True
            msg = "Tell me your name"
            return question(msg)
    else: 
        Boolean = True
        msg = "Tell me your name"
        return question(msg)
示例#2
0
def completed(payload, name, status, token):
    products = Product(context.System.apiAccessToken)
    logger.info('on-purchase-completed {}'.format( request))
    logger.info('payload: {} {}'.format(payload.purchaseResult, payload.productId))
    logger.info('name: {}'.format(name))
    logger.info('token: {}'.format(token))
    logger.info('status: {}'.format( status.code == 200))
    product_name = products.productName(payload.productId)
    logger.info('Product name'.format(product_name))
    if status.code == '200' and ('ACCEPTED' in payload.purchaseResult):
        return question('To listen it just say - play {} '.format(product_name))
    else:      
        return question('Do you want to buy another product?')
def model_answer(spoken_model):

    alldata = loader_util.load_data_from_s3()

    model = spoken_model;

    result = query_util.find_matches_by_model(alldata, model)

    if result.getlen() < 1:
        session.attributes['answer'] = "No match"
        msg = render_template('no_matching_models', model=model)
        return question(msg)
    else:
        session.attributes['model'] = model   

    # session.attributes['product'] can be unset or empty; check for empty
    try:
        if session.attributes['product'] == "":
            # remove it because it is empty
            session.attributes.pop('product')
    except KeyError:
        # it's unset. Do something meaningless to handle the expected KeyError
        session.attributes['answer'] = ""
        
    # session.attributes['product'] can be unset.
    # We know it isn't empty because we checked above.
    try:
        # if this succeeds, we're querying for a model and we already know
        # the product... so query for a product+model combination
        product=session.attributes['product']
        result = query_util.find_matches_by_product_model(alldata, product, model)

        if result.getlen() < 1:
            session.attributes['answer'] = "No match"
            msg = render_template('no_matching_product_model', product=product, model=model)
        else:
            session.attributes['answer'] = result.toSimpleString()
            msg = render_template('read_matches', result=session.attributes['answer'])
            return statement(msg)
        
    except KeyError:
        # it's unset. This means we're querying for a model WITHOUT knowing product.
        
        # we alredy have the query from above so we just store the answer
        session.attributes['answer'] = result.toSimpleString()
        msg = render_template('read_matches', result=session.attributes['answer'])
        return statement(msg)

    return question(msg)
示例#4
0
def get_first_event(day):
    month_name = day.strftime("%B")
    day_number = day.day
    events = _get_json_events_from_wikipedia(month_name, day_number)
    if not events:
        speech_output = "There is a problem connecting to Wikipedia at this time. Please try again later."
        return statement("<speak>{}</speak>".format(speech_output))
    else:
        card_title = "Events on {} {}".format(month_name, day_number)
        speech_output = "<p>For {} {}</p>".format(month_name, day_number)
        card_output = ""
        for i in range(PAGINATION_SIZE):
            speech_output += "<p>{}</p>".format(events[i])
            card_output += "{}\n".format(events[i])
        speech_output += " Wanna go deeper into history?"
        card_output += " Wanna go deeper into history?"
        reprompt_text = (
            "With History Buff, you can get historical events for any day of the year. "
            + "For example, you could say today, or August thirtieth. "
            + "Now, which day do you want?"
        )
        session.attributes[SESSION_INDEX] = PAGINATION_SIZE
        session.attributes[SESSION_TEXT] = events
        speech_output = "<speak>{}</speak>".format(speech_output)
        return question(speech_output).reprompt(reprompt_text).simple_card(card_title, card_output)
def default_response():

    msg = render_template('default')
    session.attributes['product'] = ""
    session.attributes['model'] = ""

    return question(msg)
def give_welcome():

    welcome_msg = render_template('welcome')
    session.attributes['product'] = ""
    session.attributes['model'] = ""

    return question(welcome_msg)
示例#7
0
def alexa_ask_game():
    """Return the five three games in the list"""
    card_title = render_template('card_title')
    game_list = moonlight_games()
    game_list_msg = render_template('game_list', games=game_list[:5])
    session.attributes['games'] = game_list[:5]
    return question(game_list_msg).simple_card(card_title, game_list_msg)
示例#8
0
def take_image():
    """
    Takes an image, gets the image array from get_image() and then asks who is in the photo
    """
    global img_array
    img_array = get_image()
    msg = "Who's in the photo?"
    return question(msg)
示例#9
0
def alexafavorite():
    alexafavorite_msg = 'My favourite quote is from William Butler Yeats. \
    It goes, How many loved your moments of glad grace, \
    And loved your beauty with love false or true, \
    But one man loved the pilgrim soul in you, \
    And loved the sorrows of your changing face. \
    The words are so beautiful. I hope I could fall in love someday.'
    return question(alexafavorite_msg)
示例#10
0
def launch():
    speech_output = "History buff. What day do you want events for?"
    reprompt_text = (
        "With History Buff, you can get historical events for any day of the year. "
        + "For example, you could say today, or August thirtieth. "
        + "Now, which day do you want?"
    )
    return question(speech_output).reprompt(reprompt_text)
示例#11
0
def next_round():

    numbers = [randint(0, 9) for _ in range(3)]

    round_msg = render_template('round', numbers=numbers)

    session.attributes['numbers'] = numbers[::-1]  # reverse

    return question(round_msg)
示例#12
0
def askWhichQueryType():
    """
    Used for control low
    Return: Asks if the user wnats a list of docs or a list of entities
    """
    global Query
    Query = Input
    msg = "Do you want a list of documents or a list of entities"
    return question(msg)
示例#13
0
def whats_my_color():
    card_title = render_template('card_title')
    color = session.attributes.get(COLOR_KEY)
    if color is not None:
        statement_text = render_template('known_color_bye', color=color)
        return statement(statement_text).simple_card(card_title, statement_text)
    else:
        question_text = render_template('unknown_color_reprompt')
        return question(question_text).reprompt(question_text).simple_card(card_title, question_text)
示例#14
0
def add_profile(name):
    """
    Parameter: User Name
    Asks for the name of the user.  
    """
    global Name
    Name = "{}".format(name) 
    msg = "What website do you want to save a password to.  After you enter a website, follow the instructions in the computer console"
    return question(msg)
示例#15
0
def my_color_is(color):
    card_title = render_template('card_title')
    if color is not None:
        session.attributes[COLOR_KEY] = color
        question_text = render_template('known_color', color=color)
        reprompt_text = render_template('known_color_reprompt')
    else:
        question_text = render_template('unknown_color')
        reprompt_text = render_template('unknown_color_reprompt')
    return question(question_text).reprompt(reprompt_text).simple_card(card_title, question_text)
示例#16
0
def alexa_launch_game(game_title):
    """Launch the desired GameStream App"""
    card_title = render_template('card_title')
    if game_title is not None:
      statement_msg = render_template('known_game', game=game_title.title())
      launch_game(game_title.title())
      return statement(statement_msg).simple_card(card_title, statement_msg)
    else:
      question_msg = render_template('unknown_game')
      return question(question_msg).simple_card(card_title, question_msg)
示例#17
0
def askWhichType(input):
    """
    Paramter: What the user wants to know more about
    This function is used for control flow
    Return: Asks if this is an entity or a query
    """
    global Input
    Input = "{}".format(input)
    print(Input, flush = True)
    newsQ = "Alright. Please tell me if this is an entity or query"
    return question(newsQ) 
def list_products():

    alldata = loader_util.load_data_from_s3()

    products_supported = query_util.get_list_of_products_string(alldata, ", ")
    session.attributes['product_supported'] = products_supported
    session.attributes['product'] = ""
    session.attributes['model'] = ""

    msg = render_template('list_products', product_names=products_supported)

    return question(msg)
示例#19
0
def add_child(name):
    if name is None:
        return question(render_template("child_name")).reprompt(render_template("child_name_reprompt"))
    user_token = session.user.accessToken
    endpoint = "/api/child"
    r = requests.post(BASE+endpoint,
                      headers={'Authorization': 'Basic %s' % b64encode(bytes(user_token+":"))},
                      data={'name': name})
    if r.status_code != 200:
        return statement(render_template("failed_request"))
    resp = f"{name} was added as your child"
    return statement(resp).simple_card(resp)
示例#20
0
def next_round():
    nextx = session.attributes['search_item']
    nextx = nextx.title()
    try:
        quotes = wikiquote.quotes(nextx)       
    except wikiquote.utils.DisambiguationPageException:
        nextx = wikiquote.search(nextx)[0]
        quotes = wikiquote.quotes(nextx)
    except wikiquote.utils.NoSuchPageException:
        for search in wikiquote.search(nextx):
            if nextx.lower() in search.lower():
                quotes = wikiquote.quotes(search)
                break
        else:
            # raise wikiquote.utils.NoSuchPageException('No pages matched' + search_item)
            return question("Sorry, I can't find proper quotes, please try a more specific word.")
    nquotes = random.choice(quotes)
    nquote_msg = 'From {}, {}'.format(nextx, nquotes)
    reprompt_msg = 'Would you like one more quote?'
    return question(nquote_msg) \
          .reprompt(reprompt_msg)
def request_message_body(message_body):
    message.message_body = message_body

    client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
    client.messages.create(
        to = '2105553998',
        from_ = '2105551244',
        body = "Message: " + message.message_body
    )

    
    response_text = render_template('request_body', message_body=message_body)
    return question(response_text)
示例#22
0
def wisdom_quotes(search_item):
    search_item = search_item.title()
    try:
        quotes = wikiquote.quotes(search_item)       
    except wikiquote.utils.DisambiguationPageException:
        search_item = wikiquote.search(search_item)[0]
        quotes = wikiquote.quotes(search_item)
    except wikiquote.utils.NoSuchPageException:
        for search in wikiquote.search(search_item):
            if search_item.lower() in search.lower():
                quotes = wikiquote.quotes(search)
                break
        else:
            # raise wikiquote.utils.NoSuchPageException('No pages matched' + search_item)
            return question("Sorry, I can't find proper quotes, please try a more specific word.")
    wquotes = random.choice(quotes)
    wquote_msg = 'From {}, {}'.format(search_item, wquotes)
    reprompt_msg = 'Would you like one more quote?'
    session.attributes['search_item'] = search_item
    session.attributes['reply'] = wquote_msg
    return question(wquote_msg) \
          .reprompt(reprompt_msg)
def list_models_for_product(spoken_product):

    product = spoken_product;
    alldata = loader_util.load_data_from_s3()

    models_supported = query_util.get_list_of_models_by_product_string(alldata, product, ", ")

    session.attributes['product'] = spoken_product
    session.attributes['model'] = ""
    session.attributes['models_supported_by_product'] = models_supported
    
    msg = render_template('list_models', product=product, model_names=models_supported)

    return question(msg)
示例#24
0
def price(commodity):
    try:
        commodity = commodity.lower()
        url = 'http://spot.seanmckaybeck.com/api/' + commodity
        r = requests.get(url)
        if 'error' in r.json():
            speech_output = "I'm sorry but I don't track the commodity {}. ".format(commodity)
            speech_output += "You can ask about any of the following: " + ", ".join(app.config['SUPPORTED'])
            return question(speech_output)
        else:
            d = datetime.datetime.strptime(r.json()['last'], '%Y-%m-%d %H:%M:%S.%f')
            if d.date() == datetime.datetime.today():
                date_str = 'As of {} today, '.format(d.time().strftime('%I:%M %p'))
            else:
                date_str = 'As of {} on {}, '.format(d.time().strftime('%I:%M %p'), d.date().strftime('%B %d'))
            speech_output = "{} the price of {} is ${}.".format(date_str, commodity, r.json()[commodity])
    except requests.exceptions.HTTPError:
        speech_output = "I'm sorry, there was an error retrieving the price. Please try again later."
    except AttributeError:
        # happens when commodity is None
        speech_output = "I'm sorry, I didn't receive a valid commodity in your request. "
        speech_output += "You can ask about any of the following: " + ", ".join(app.config['SUPPORTED'])
        return question(speech_output)
    return statement(speech_output).simple_card('Commodity Prices', speech_output)
示例#25
0
def summarize_official():
    """
    If there is only one document, gets the summary of that document.  Otherwise, asks the user which document do they want to 
    summarize. 

    Return: Summary or a question of which doc do they want to summarize
    """
    # print(len(TotalDocs), flush = True)
    if (len(TotalDocs) == 1):
        summary = summarize(db, TotalDocs[0], stopwords, summarizeLength = 2)
        # print(len(summary), flush = True)
        msg = "The summary is: {}".format(summary)
        return statement(msg)
    else:   
        return question("Which document? Give a number")
示例#26
0
def get_next_event():
    events = session.attributes[SESSION_TEXT]
    index = session.attributes[SESSION_INDEX]
    card_title = "More events on this day in history"
    speech_output = ""
    card_output = ""
    i = 0
    while i < PAGINATION_SIZE and index < len(events):
        speech_output += "<p>{}</p>".format(events[index])
        card_output += "{}\n".format(events[index])
        i += 1
        index += 1
    speech_output += " Wanna go deeper into history?"
    reprompt_text = "Do you want to know more about what happened on this date?"
    session.attributes[SESSION_INDEX] = index
    speech_output = "<speak>{}</speak>".format(speech_output)
    return question(speech_output).reprompt(reprompt_text).simple_card(card_title, card_output)
示例#27
0
def delete_child(name):
    if name is None:
        return question(render_template("child_name")).reprompt(render_template("child_name_reprompt"))
    user_token = session.user.accessToken
    endpoint = "/api/child"
    child = name_to_id(name, user_token)
    if "children" in child:
        text = render_template("multiple_name")
        return statement(text).simple_card(text)
    child_id = child["_id"]
    r = requests.delete(BASE+endpoint,
                        headers={'Authorization': 'Basic %s' % b64encode(bytes(user_token+":"))},
                        data={'child_id': child_id})
    if r.status_code != 200:
        return statement(render_template("failed_request"))
    resp = f"{name} was deleted"
    return statement(resp).simple_card(resp)
示例#28
0
def saveFAddress(FAddress):
    """
    Takes in the user input of an address in the format of: street address, city, and state. By utilizing geopy,
    convert the input to latitude, longitude coordinates. Then, Alexa will prompt the user to enter the second
    address.
    """
    session.attributes["FAddress"] = FAddress
    addr = session.attributes["FAddress"]
    print(addr, flush = True)
    geolocator = Nominatim()
    location = geolocator.geocode(addr)
    session.attributes["lato"] = location.latitude
    session.attributes["lono"] = location.longitude
    print(session.attributes["lato"], session.attributes["lono"])

    msg = "Would you like to add another address?"
    return question(msg)
示例#29
0
    def perform_switch(self, location, operation):

        try:
            resolved_location = self.match_location(location or "")
            resolved_operation = self.match_operation(operation or "")
        except ActionParseError as ape:
            return question(str(ape)).simple_card(_CARD_TITLE, str(ape))

        switch_id, switch_func = resolved_location
        try:
            r = switch_func(resolved_operation)
            text = "%s %s!" % (
                switch_id.replace('_', ' ').title(), resolved_operation)
            status = int(r.status.split(' ')[0])
            if status < 200 or status > 299:
                raise Exception(status)
        except Exception:
            text = "I had problems communicating with your device!"
        return statement(text).simple_card(_CARD_TITLE, text)
def product_answer(spoken_product):

    product = spoken_product;

    alldata = loader_util.load_data_from_s3()

    # ensure that this is a valid (matching) product
    result = query_util.find_matches_by_product(alldata, product)

    if result.getlen() < 1:
        session.attributes['answer'] = "No match"
        msg = render_template('no_matching_products', product=product)
    else:
        session.attributes['product'] = product

    
    # session.attributes['model'] can be unset or empty; check for empty
    try:
        if session.attributes['model'] == "":
            # remove it because it is empty
            session.attributes.pop('model')
            msg = render_template('get_model', product=product)
        else:
            # it's not empty, so execute a query for product model
            model = session.attributes['model'];

            result = query_util.find_matches_by_product_model(result, product, model)

            if result.getlen() < 1:
                session.attributes['answer'] = "No match"
                msg = render_template('no_matching_product_model', product=product, model=model)
            else:
                session.attributes['answer'] = result.toSimpleString()
                msg = render_template('read_matches', result=session.attributes['answer'])
            return statement(msg)
    except KeyError:
        # model is unset. prompt user for the model
        session.attributes['answer'] = ""
        msg = render_template('get_model', product=product)
        

    return question(msg)
示例#31
0
def SingleItemOrders(item):
    intent = "SingleItemOrdersIntent"
    ans = item_message(item, intent)
    return question(ans)
示例#32
0
def launch():
    card_title = 'Audio Example'
    text = 'Welcome to an audio example. You can ask to begin demo, or try asking me to play the sax.'
    prompt = 'You can ask to begin demo, or try asking me to play the sax.'
    return question(text).reprompt(prompt).simple_card(card_title, text)
示例#33
0
def sample_questions():
    return question(render_template('sample-questions')) \
        .reprompt(render_template("reprompt"))
示例#34
0
def Users():
    intent = "UsersIntent"
    ans = message(intent)
    return question(ans)
示例#35
0
def new_order():
    welcome_msg = render_template('welcome')
    while (len(pizzas) > 0):
        pizzas.pop()

    return question(welcome_msg)
示例#36
0
def ItemsNotAvailIntent():
    intent = "ItemsNotAvailIntent"
    ans = message(intent)
    return question(ans)
示例#37
0
def launch():
    speech_text = 'What is the registration you want to check?'
    return question(speech_text).reprompt(speech_text).simple_card(
        'Launch', speech_text)
示例#38
0
def start_skill():
    welcome_message = 'Hello Dougie Doo, would you like to hear some reddit news about SpaceX...Python...or SpaceXLounge? For SpaceX just say Yes, for Python say Python...and...for SpaceXLounge please say Another.'
    return question(welcome_message)
示例#39
0
def start_skill():
    welcome_message = "Connected. "  # this should be a question
    welcome_message = render_template('welcome')
    #welcome_message = get_info()
    return question(welcome_message)
示例#40
0
def fallback():
    return question(render_template('error-not-understand')) \
        .reprompt(render_template('error-not-understand'))
示例#41
0
def launch():
    speech_text = "Welcome to Food dashboard "
    return question(speech_text)
示例#42
0
def new_game():
    welcome_msg = render_template('welcome')

    return question(welcome_msg).reprompt(welcome_msg)
示例#43
0
def new_game():
    welcome_msg = render_template('welcome_mqtt')

    return question(welcome_msg)
示例#44
0
def launch():
    speech_text = 'Welcome to the Urban Dictionary, ask for a definition'
    return question(speech_text).reprompt(speech_text).simple_card(
        'HelloWorld', speech_text)
示例#45
0
def help():
    speech_text = 'State the registration of the vehicle that you want to check'
    return question(speech_text).reprompt(speech_text).simple_card(
        'Help', speech_text)
示例#46
0
def start_skill():
   welcome_message = 'Hello there, what would you like to do?'
   return question(welcome_message)
示例#47
0
def cancel():
    pizzas.pop()
    cancel_msg = render_template('cancel')
    return question(cancel_msg)
示例#48
0
def fallback():
    speech_text = "unable to process your request, please try again with another word"
    return question(speech_text)
示例#49
0
def ask_for_size():
    session.attributes['size'] = ""
    session.attributes['toppings'] = []
    size_msg = render_template('size')

    return question(size_msg)
示例#50
0
def start_skill():
    welcome_message = "Hello MHP Lab, would you like to hear some jokes?"
    return question(welcome_message)
示例#51
0
def SingleUserOrders(name):
    intent = "SingleUserOrdersIntent"
    ans = name_message(name, intent)
    return question(ans)
示例#52
0
def start_skill():
    global game
    global game_state
    game = None
    game_state = None
    return question("Hi. I'm Game Buddy. What would you like to play?")
示例#53
0
def help():
    speech_text = "you can ask for operaional data by saying show operational data"
    return question(speech_text).reprompt(speech_text)
示例#54
0
def OrdersIntent():
    intent = "OrdersIntent"
    ans = message(intent)
    return question(ans)
示例#55
0
def welcome():
    return question(render_template('welcome')) \
        .reprompt(render_template("reprompt"))
示例#56
0
def start_skill():
    message = "Do you want to turn the light on or off?"
    return question(message)
示例#57
0
def get_show_genre(show_genre):
    return question(render_template("show_genre.html", genre=show_genre))
示例#58
0
def help():
    return question(render_template('help')) \
        .reprompt(render_template("reprompt"))
示例#59
0
def get_not_watched_movie(boolean):

    recommended_title = "Shrek 2"
    return question(
        render_template("not_watched_show.html", title=recommended_title))
示例#60
0
def about():
    msg = render_template('about')
    reprompt = render_template('about_reprompt')
    msg = voice_mod(msg)
    reprompt = voice_mod(reprompt)
    return question(msg).reprompt(reprompt)