def call_back_intent_handler(request): """ You can insert arbitrary business logic code here """ rap = get_rhyme(chains["toponehundredraps"], 8) upload_rap(rap[7:-94]) return r.create_response(is_ssml=True, message="<speak>Aight yo I'm gonna rap. Alexa <break time=\"1.5s\" /> start beatboxing <break time=\"1.5s\" /> " + rap + '<audio src="https://s3.amazonaws.com/danielgwilson.com/MLG+Horns+Sound+Effect.mp3" /></speak>')
def get_rapper_intent_handler(request): """ Use the 'intent' field in the VoiceHandler to map to the respective intent. You can insert arbitrary business logic code here """ # Get variables like userId, slots, intent name etc from the 'Request' object rapper = request.get_slot_value("Rapper") rapper = rapper if rapper else "" with open("models/intros.json") as file: intros = json.load(file) try: intro = intros[rapper] except KeyError: intro = "" try: rap = get_rhyme(chains[rapper], 8) except KeyError: return r.create_response(message="I heard, %s, but I don't know that rapper." % rapper, end_session=False) rap = "<speak>Yo my name is {}. ".format(rapper) + intro + " " + rap + '<audio src="https://s3.amazonaws.com/danielgwilson.com/MLG+Horns+Sound+Effect.mp3" /></speak>' upload_rap(rap[7:-94]) # Use ResponseBuilder object to build responses and UI cards card = r.create_card(title="Rapping", subtitle=None, content=rap) return r.create_response(message=rap, is_ssml=True, end_session=False, card_obj=card)