Amazon polly

From calesthio/generative-media-skills · View interactive version

Amazon polly is an AI agent skill from the GitHub repository calesthio/generative-media-skills. Use Amazon Polly for production text-to-speech work: selecting Standard, Neural, Long-form, or Generative engines and compatible voices; authoring SSML; creating speech marks for captions, word highlighting, or lip-sync; managing pronunciation lexicons; running synchronous, streaming, or asynchronou

How to use this skill

Skill file

Amazon Polly production TTS

Use Amazon Polly when the job needs AWS-hosted text-to-speech with predictable API operations, IAM governance, lexicons, SSML, and reusable generated audio. Treat Polly as a production TTS service, not a voice-cloning system: it provides AWS-managed voices and engines, not custom voice training or arbitrary speaker imitation.

Facts below were verified from official AWS documentation on 2026-07-10. Re-check AWS docs before relying on volatile facts such as prices, quotas, regions, voice lists, or engine feature compatibility.

First decision: which operation and engine

Choose the operation first, because it defines latency, output custody, and timing options:

Then select the engine:

Do not omit Engine in production. Some SDK/CLI paths default to standard; if the selected voice does not support Standard, the request can fail. Verify voice-engine-region compatibility with DescribeVoices or the current AWS voice pages before committing to a production voice.

Capability boundaries that affect media production

Documented facts:

Production heuristics:

SSML and pronunciation control

Use SSML when the script needs deterministic pauses, dates, acronyms, foreign-language spans, pronunciation fixes, or structural marks. Set TextType="ssml" and wrap the payload in <speak>...</speak>.

Documented facts:

Production heuristics:

Example SSML for a product explainer:

<speak>
  <p>
    Meet <sub alias="Acme Cloud One">ACME C1</sub>.
    <break time="250ms"/>
    It turns noisy incident data into a ranked action plan.
  </p>
  <p>
    In <say-as interpret-as="date" format="mdy">07-10-2026</say-as> tests,
    teams cut triage time by <say-as interpret-as="cardinal">42</say-as> percent.
  </p>
  <p>
    <mark name="cta_start"/>Start with one service, then expand.
  </p>
</speak>

Why this structure works: <sub> avoids letter-by-letter acronym drift, <break> creates an edit point, <say-as> disambiguates data, and <mark> gives a deterministic cue for overlay timing when the chosen engine supports SSML speech marks.

Speech marks for captions, highlighting, and lip sync

Use speech marks when the downstream artifact needs timing:

Documented facts:

Production workflow:

  1. Finalize the narration text before generating timing.
  2. Synthesize audio with the chosen engine, voice, text, text type, sample rate, and lexicons.
  3. Make a second request with the exact same text, engine, voice, text type, and lexicons, but OutputFormat="json" and the needed SpeechMarkTypes.
  4. Use the speech-mark JSON to build captions or mouth cues; do not edit the text afterward without regenerating both audio and marks.
  5. Validate by playing the final mixed audio with overlays. Word marks are timing aids, not a substitute for human caption QA.

For lip sync, map Polly viseme names to the rig’s mouth-shape set and smooth transitions. Visemes are not phoneme-level ground truth; add blend windows and test plosives/fricatives visually.

If the selected voice/engine cannot provide speech marks, use a different compatible voice/engine or run forced alignment/ASR after synthesis. This is a production workaround, not an AWS-documented equivalence.

Lexicons

Use lexicons for repeated pronunciation fixes: product names, acronyms, stylized spellings, names, jargon, and locale-specific terms.

Documented facts:

Production heuristics:

Example PLS lexicon:

<?xml version="1.0" encoding="UTF-8"?>
<lexicon version="1.0"
  xmlns="http://www.w3.org/2005/01/pronunciation-lexicon"
  alphabet="ipa"
  xml:lang="en-US">
  <lexeme>
    <grapheme>ACME C1</grapheme>
    <alias>Acme Cloud One</alias>
  </lexeme>
  <lexeme>
    <grapheme>Qdrant</grapheme>
    <phoneme>ˈkjuː drænt</phoneme>
  </lexeme>
</lexicon>

Output and mastering choices

For video editing, request a high enough sample rate to survive mixing and exports:

Production QA checklist:

IAM, S3, custody, and privacy

Documented facts:

Production security heuristics:

Rights, consent, and disclosure

Documented boundary: Polly provides AWS voices; it is not a custom voice clone service. Production policy still matters:

Examples

Example: short video narration with captions and mouth cues

Intent: produce a 30-second product narration with word captions and optional avatar mouth movement.

Decision:

Python sketch:

import boto3

polly = boto3.client("polly", region_name="us-east-1")

text = """<speak>
<p>Meet ACME Cloud One. <break time="200ms"/> It turns noisy incident data into a ranked action plan.</p>
<p><mark name="cta"/>Start with one service, then expand.</p>
</speak>"""

common = {
    "Engine": "neural",
    "VoiceId": "Joanna",
    "Text": text,
    "TextType": "ssml",
    "SampleRate": "24000",
    "LexiconNames": ["BrandLex"],
}

audio = polly.synthesize_speech(**common, OutputFormat="mp3")
with open("narration.mp3", "wb") as f:
    f.write(audio["AudioStream"].read())

marks = polly.synthesize_speech(
    **common,
    OutputFormat="json",
    SpeechMarkTypes=["word", "sentence", "viseme", "ssml"],
)
with open("narration.marks.jsonl", "wb") as f:
    f.write(marks["AudioStream"].read())

QA: check that BrandLex exists in us-east-1, that the voice language matches the lexicon language, and that generated captions match the approved script.

Example: asynchronous chapter render to S3

Intent: convert a long training chapter into a single audio file without managing many short requests.

Decision:

Python sketch:

import boto3

polly = boto3.client("polly", region_name="us-east-1")

response = polly.start_speech_synthesis_task(
    Engine="long-form",
    VoiceId="Ruth",
    TextType="ssml",
    Text=open("chapter_01.ssml", encoding="utf-8").read(),
    OutputFormat="mp3",
    SampleRate="24000",
    OutputS3BucketName="company-media-prod",
    OutputS3KeyPrefix="tts/training-2026/chapter-01/",
    SnsTopicArn="arn:aws:sns:us-east-1:123456789012:polly-render-events",
)

print(response["SynthesisTask"]["TaskId"])
print(response["SynthesisTask"].get("OutputUri"))

QA: poll GetSpeechSynthesisTask or subscribe to SNS, verify the output file exists under the expected S3 prefix, listen end-to-end, and compare duration against the chapter estimate.

Example: choosing against Generative for accessible captions

User asks: “Use the most human Amazon Polly voice and give me exact word-level captions.”

Strong production response: explain that Generative may sound most conversational but currently does not support speech-mark generation, so exact word-level captions require either a Neural/Long-form voice with Polly marks or a post-synthesis alignment workflow. Recommend Neural if captions are mandatory and the voice is acceptable; choose Generative only if the user accepts ASR/forced-alignment timing as an additional QA step.

Troubleshooting

Official sources checked on 2026-07-10

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.