def lambda_handler()

in lambda_polly/lambda_function.py [0:0]


def lambda_handler(event, context):
    print(event)
    now = datetime.now()
    date_time = now.strftime("%m-%d-%Y")
    # TODO get this variables from event source
    text_to_audio = event["responsePayload"]["message"]
    
    audio_id = f"{text_to_audio[:20].replace(' ', '')}{date_time}"
    bucket_name = os.getenv("BUCKET_NAME", "ai-services-for-demo")

    polly_client = aws_connection()
    audio_response = change_text_to_audio(polly_client, text_to_audio)
    change_audio_stream(audio_response, audio_id)

    send_audio_to_s3(f"/tmp/{audio_id}.mp3", 
        text_to_audio[:100], audio_id, bucket_name)