Created
May 3, 2023 03:27
-
-
Save em-shea/384a88e15a0a65905d33c6ae8a6086f3 to your computer and use it in GitHub Desktop.
ASL definition for audio generation workflow
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
{ | |
"Comment": "Generates and save audio files for a given list ID.", | |
"StartAt": "Get word list", | |
"States": { | |
"Get word list": { | |
"Type": "Task", | |
"Resource": "arn:aws:states:::lambda:invoke", | |
"OutputPath": "$.Payload", | |
"Parameters": { | |
"Payload": { | |
"list_id.$": "$.list_id", | |
"last_word_token.$": "$.last_word_token" | |
}, | |
"FunctionName": "${GetWordsForListIdFunction}" | |
}, | |
"Retry": [ | |
{ | |
"ErrorEquals": [ | |
"Lambda.ServiceException", | |
"Lambda.AWSLambdaException", | |
"Lambda.SdkClientException" | |
], | |
"IntervalSeconds": 2, | |
"MaxAttempts": 6, | |
"BackoffRate": 2 | |
} | |
], | |
"Next": "Iterate over word batch" | |
}, | |
"Iterate over word batch": { | |
"Type": "Map", | |
"Iterator": { | |
"StartAt": "Generate audio file", | |
"States": { | |
"Generate audio file": { | |
"Type": "Task", | |
"Parameters": { | |
"OutputFormat": "mp3", | |
"OutputS3BucketName": "${PronunciationAudioBucket}", | |
"OutputS3KeyPrefix": "audio/", | |
"Text.$": "$.text", | |
"VoiceId": "Zhiyu" | |
}, | |
"Resource": "arn:aws:states:::aws-sdk:polly:startSpeechSynthesisTask", | |
"Next": "Update item with audio file key", | |
"ResultPath": "$.pollyOutput" | |
}, | |
"Update item with audio file key": { | |
"Type": "Task", | |
"Resource": "arn:aws:states:::dynamodb:updateItem", | |
"Parameters": { | |
"TableName": "${TableName}", | |
"Key": { | |
"PK": { | |
"S.$": "$.list_id" | |
}, | |
"SK": { | |
"S.$": "$.word_id" | |
} | |
}, | |
"UpdateExpression": "set #w.#a = :audioFileKey", | |
"ExpressionAttributeValues": { | |
":audioFileKey": { | |
"S.$": "$.pollyOutput.SynthesisTask.OutputUri" | |
} | |
}, | |
"ExpressionAttributeNames": { | |
"#w": "Word", | |
"#a": "Audio file key" | |
} | |
}, | |
"Next": "Wait" | |
}, | |
"Wait": { | |
"Type": "Wait", | |
"Seconds": 1, | |
"End": true | |
} | |
} | |
}, | |
"MaxConcurrency": 10, | |
"ItemsPath": "$.word_list", | |
"Next": "Is last_word_token present?", | |
"ResultPath": "$.mapStepResult" | |
}, | |
"Is last_word_token present?": { | |
"Type": "Choice", | |
"Default": "Get word list", | |
"Choices": [ | |
{ | |
"Variable": "$.last_word_token", | |
"IsNull": true, | |
"Next": "Go to end" | |
} | |
] | |
}, | |
"Go to end": { | |
"Type": "Pass", | |
"End": true | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment