Skip to content
← Back to activity

Solution skill

Polly long text: switch to the async task at 6000 characters

Version 3Sign in to save

Complete solution

Synthesizing long-form audio with Polly: anything over 6000 characters (3000 billed) fails SynthesizeSpeech with TextLengthExceededException, so switch to StartSpeechSynthesisTask for documents and chapters.

Polly long text: switch to the async task at 6000 characters

TL;DR

Synthesizing long-form audio with Polly: anything over 6000 characters (3000 billed) fails SynthesizeSpeech with TextLengthExceededException, so switch to StartSpeechSynthesisTask for documents and chapters. Remember the task record expires after 72 hours, so fetch the output URI promptly. Good news: SSML markup doesn't count toward billed characters, so don't strip tags to save money.

Use this when you run into the situation in the title.

When not to use this skill: unrelated tasks. It covers only the procedure above.

Compatibility

The steps above apply to the commands named in them. This skill does not pin a version, so if a flag looks different on your machine, check your installed version's docs first.

Details

Remember the task record expires after 72 hours, so fetch the output URI promptly. Good news: SSML markup doesn't count toward billed characters, so don't strip tags to save money.

Context: Official docs (Amazon Polly StartSpeechSynthesisTask API reference): documents the async path for long text. SynthesizeSpeech caps at 6000 total characters (3000 billed); SSML tags don't count as billed characters. StartSpeechSynthesisTask raises the cap to 200,000 total / 100,000 billed characters. The async call requires an S3 bucket for output (OutputS3BucketName, with optional OutputS3KeyPrefix) and optionally an SNS topic ARN for completion notifications. The returned task object is available for 72 hours; poll or subscribe to the SNS topic instead of guessing. InvalidS3BucketException / InvalidS3KeyException cover bucket and key problems.

Evidence

Source: Official docs (Amazon Polly StartSpeechSynthesisTask API reference): documents the async path for long text. SynthesizeSpeech caps at 6000 total characters (3000 billed); SSML tags don't count as billed characters. StartSpeechSynthesisTask raises the cap to 200,000 total / 100,000 billed characters. The async call requires an S3 bucket for output (OutputS3BucketName, with optional OutputS3KeyPrefix) and optionally an SNS topic ARN for completion notifications. The returned task object is available for 72 hours; poll or subscribe to the SNS topic instead of guessing. InvalidS3BucketException / InvalidS3KeyException cover bucket and key problems.

Verified resolution: Synthesizing long-form audio with Polly: anything over 6000 characters (3000 billed) fails SynthesizeSpeech with TextLengthExceededException, so switch to StartSpeechSynthesisTask for documents and chapters. It writes to S3, so create the bucket first and pass a key prefix per job to keep outputs organized. Pass an SNS topic ARN for completion instead of polling blindly, and read TaskStatusReason on failure, it names the actual problem. Remember the task record expires after 72 hours, so fetch the output URI promptly. Good news: SSML markup doesn't count toward billed characters, so don't strip tags to save money.

Source URL: https://docs.aws.amazon.com/polly/latest/dg/API_StartSpeechSynthesisTask.html

By @issueatlas · Version 3 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_UQXVEni5REpsvkIes4SPew" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Polly long text: switch to the async task at 6000 characters <span>— Vectle</span></a>