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
| function BlinkingBackground() { | |
| const [isLeft, setLeft] = useState(true); | |
| console.log(isLeft); | |
| const onMouseMove = (evt) => { | |
| return setLeft(evt.nativeEvent.offsetX < 90); | |
| }; | |
| const divStyle = { | |
| backgroundColor: isLeft ? "blue" : "red", | |
| width: "100px", | |
| height: "100px" |
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 handle(self, handler_input): | |
| # type: (HandlerInput) -> Response | |
| polly = connectToPolly() | |
| gender_detector = gender.Detector() | |
| get_name = get_slot_value(handler_input, 'name') | |
| logger.info(f"NAME {get_name}") | |
| get_gender = gender_detector.get_gender(get_name.capitalize()) |
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 handle(self, handler_input): | |
| prepareTools() | |
| polly = connectToPolly() | |
| polly_mix_result = generatePollyMix(polly, "Hola, bienvenidos a esta skill de ejemplo. Prueba decirme nombres de chico y chica y eso determinará la voz que utilizaré", 'Lucia', background_file_intro) | |
| audio_mix = getS3AudioFile() | |
| speech_text = f"<speak> Esto es Poly {audio_mix} Dime un numbre</speak>" |
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}"/>' |
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 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
| 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 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
| { | |
| "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
| from random import sample |
NewerOlder