arazzo: 1.0.1 info: title: Amazon Polly Start Synthesis Task and Poll to Completion summary: Start an async speech synthesis task, then poll it until it completes. description: >- The core asynchronous text-to-speech pattern in Amazon Polly. The workflow starts a SpeechSynthesisTask that writes its audio output to an S3 bucket, captures the returned task id, and then polls GetSpeechSynthesisTask in a loop until the task status leaves the scheduled or inProgress state. On completion it surfaces the S3 output URI. Each step spells out its request inline, including the AWS Signature Version 4 signing headers, so the flow can be read and executed without opening the underlying OpenAPI description. version: 1.0.0 sourceDescriptions: - name: pollyApi url: ../openapi/amazon-polly-openapi-original.yaml type: openapi workflows: - workflowId: start-synthesis-task-poll summary: Start an asynchronous synthesis task and poll it until it reaches a terminal state. description: >- Submits a long-form synthesis task to an S3 bucket, captures the task id, and polls the task status until it is no longer scheduled or inProgress, branching back to poll again while still running. inputs: type: object required: - amzDate - authorization - text - outputFormat - outputS3BucketName - voiceId properties: amzDate: type: string description: The X-Amz-Date timestamp used to sign the requests. authorization: type: string description: The full SigV4 Authorization header value for the request. contentSha256: type: string description: The X-Amz-Content-Sha256 hex digest of the request payload. securityToken: type: string description: Optional X-Amz-Security-Token for temporary credentials. engine: type: string description: Engine to use for synthesis (standard or neural). text: type: string description: The input text (plain text or SSML) to synthesize. textType: type: string description: Whether the input text is plain text or ssml. outputFormat: type: string description: The audio output format (mp3, ogg_vorbis, pcm, or json). outputS3BucketName: type: string description: The S3 bucket name to which the output file will be saved. outputS3KeyPrefix: type: string description: Optional S3 key prefix for the output speech file. voiceId: type: string description: Voice ID to use for the synthesis (e.g. Joanna). steps: - stepId: startTask description: >- Start an asynchronous speech synthesis task that writes its output audio to the supplied S3 bucket, returning a task id to poll on. operationId: StartSpeechSynthesisTask parameters: - name: X-Amz-Date in: header value: $inputs.amzDate - name: Authorization in: header value: $inputs.authorization - name: X-Amz-Content-Sha256 in: header value: $inputs.contentSha256 - name: X-Amz-Security-Token in: header value: $inputs.securityToken requestBody: contentType: application/json payload: Engine: $inputs.engine OutputFormat: $inputs.outputFormat OutputS3BucketName: $inputs.outputS3BucketName OutputS3KeyPrefix: $inputs.outputS3KeyPrefix Text: $inputs.text TextType: $inputs.textType VoiceId: $inputs.voiceId successCriteria: - condition: $statusCode == 200 outputs: taskId: $response.body#/SynthesisTask/TaskId taskStatus: $response.body#/SynthesisTask/TaskStatus - stepId: pollTask description: >- Poll the synthesis task by id, branching back to poll again while the task is still scheduled or in progress. operationId: GetSpeechSynthesisTask parameters: - name: TaskId in: path value: $steps.startTask.outputs.taskId - name: X-Amz-Date in: header value: $inputs.amzDate - name: Authorization in: header value: $inputs.authorization - name: X-Amz-Content-Sha256 in: header value: $inputs.contentSha256 - name: X-Amz-Security-Token in: header value: $inputs.securityToken successCriteria: - condition: $statusCode == 200 outputs: taskStatus: $response.body#/SynthesisTask/TaskStatus outputUri: $response.body#/SynthesisTask/OutputUri taskStatusReason: $response.body#/SynthesisTask/TaskStatusReason onSuccess: - name: stillRunning type: goto stepId: pollTask criteria: - context: $response.body condition: $.SynthesisTask.TaskStatus == "scheduled" || $.SynthesisTask.TaskStatus == "inProgress" type: jsonpath - name: terminal type: end criteria: - context: $response.body condition: $.SynthesisTask.TaskStatus == "completed" || $.SynthesisTask.TaskStatus == "failed" type: jsonpath outputs: taskId: $steps.startTask.outputs.taskId taskStatus: $steps.pollTask.outputs.taskStatus outputUri: $steps.pollTask.outputs.outputUri