in amazon_polly_async_batch/itemprocessor.py [0:0]
def process_sqs_message(event, context):
"""
Given a set of SQS messages in the event, each consisting of a number of text fragments to synthesize into speech,
processes each in turn by posting them to Polly. Adds an in the DynamoDB WORK_TABLE for tracking each. Polly will
synthesize the speech, place the generated sound file in the WORK_BUCKET, and notify the response topic.
:param event: a set of items to synthesize into speech
:param context: Ignored
"""
try:
successes, failures = 0, 0
for record in event['Records']:
payload = json.loads(record['body'])
if process_item(payload) is not None:
successes = successes + 1
else:
failures = failures + 1
logger.info('Successfully processed {} items; {} failures.'.format(successes, failures))
except Exception as ex:
raise Exception('Failed to process SQS messages because {}'.format(str(ex)))