This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| searchObjects = ["bandeja para hacer hielo", | |
| "charco", | |
| "altavoces", | |
| "mando de tv", | |
| "borrador", | |
| "camara fotográfica", | |
| "taza", | |
| "camiseta", | |
| "escritorio", | |
| "patito de goma", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sb.add_request_handler(LaunchRequestHandler()) | |
| sb.add_request_handler(HelpIntentHandler()) | |
| sb.add_request_handler(CancelAndStopIntentHandler()) | |
| sb.add_request_handler(SessionEndedRequestHandler()) | |
| sb.add_request_handler(ListItemsIntent()) | |
| sb.add_exception_handler(AllExceptionsHandler()) | |
| handler = sb.lambda_handler() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "version": "1.0", | |
| "session": { | |
| "new": false, | |
| "sessionId": "amzn1.echo-api.session.123456789012", | |
| "application": { | |
| "applicationId": "amzn1.ask.skill.987654321" | |
| }, | |
| "attributes": {}, | |
| "user": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from random import sample |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "AWSTemplateFormatVersion": "2010-09-09", | |
| "Description": "Deploy an HTTP Proxy API Gateway", | |
| "Parameters": { | |
| "AuthorizationURL": { | |
| "Type": "String", | |
| "Default": "<authorization_uri_from_alexa_dev_portal>", | |
| "Description": "URI de Autorización de la sección Account Linking del Portal de Desarrollador de Alexa" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def generatePollyMix(polly, text, voice, backgroundSFX, format='mp3'): | |
| resp = polly.synthesize_speech(OutputFormat=format, Text=text, VoiceId=voice) | |
| soundfile = open(f"/tmp/sound.mp3", 'wb') | |
| soundBytes = resp['AudioStream'].read() | |
| soundfile.write(soundBytes) | |
| soundfile.close() | |
| audio = MP3("/tmp/sound.mp3") | |
| audio_length = audio.info.length |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| my_region = 'eu-west-1' | |
| bucket_name = '<bucket_name>' | |
| polly_url = f'https://polly.{my_region}.amazonaws.com/' | |
| s3_url = f'https://s3-{my_region}.amazonaws.com/' | |
| background_file_intro = f"{os.environ['LAMBDA_TASK_ROOT']}/audio/pavane_aws.mp3" | |
| hello_file = f"{os.environ['LAMBDA_TASK_ROOT']}/audio/inspirational_aws.mp3" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def prepareTools(): | |
| exists = os.path.isfile('/tmp/sox') | |
| if not exists: | |
| logger.info('FILE DOES NOT EXISTS') | |
| cp_cmd_output = subprocess.run([f"cp {os.environ['LAMBDA_TASK_ROOT']}/audio/sox /tmp; chmod 755 /tmp/sox"], shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE) | |
| logger.info(f"CP {cp_cmd_output}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def connectToPolly(regionName=my_region, endpointUrl=polly_url): | |
| return boto3.client('polly', region_name=regionName, endpoint_url=endpointUrl) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def getS3AudioFile(): | |
| s3_filename = hashlib.md5(open('/tmp/output.mp3', 'rb').read()).hexdigest() + '.mp3' | |
| s3.Bucket(bucket_name).upload_file(Filename='/tmp/output.mp3', Key=s3_filename, ExtraArgs={'ACL':'public-read'}) | |
| os.remove('/tmp/sound.mp3') | |
| os.remove('/tmp/output.mp3') | |
| return f'<audio src="{s3_url}{bucket_name}/{s3_filename}"/>' |