Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Synthesizing an SSML-enhanced document

Focus mode
Synthesizing an SSML-enhanced document - Amazon Polly

For longer input text, you may find it easier to save your SSML content to a file and simply specify the file name in the synthesize-speech command. For example you could save the following to a file called example.xml:

<?xml version="1.0"?> <speak version="1.1" xmlns="http://www.w3.org/2001/10/synthesis" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/10/synthesis http://www.w3.org/TR/speech-synthesis11/synthesis.xsd" xml:lang="en-US">Hello World</speak>

The xml:lang attribute specifies en-US (US English) as the language of the input text. For information about how the language of the input text and the language of the chosen voice affect the SynthesizeSpeech operation, see Specifying another language for specific words.

To run an SSML-enhanced file
  1. Save the SSML to a file (for example, example.xml).

  2. Run the following synthesize-speech command from the path where the XML file is stored and specify the SSML file as input by substituting file:\\example.xml for the input text. Because this command points to a file instead of containing the actual input text, you don't use quotation marks.

    Note

    The following AWS CLI example is formatted for Unix, Linux, and macOS. For Windows, replace the backslash (\) Unix continuation character at the end of each line with a caret (^).

    aws polly synthesize-speech \ --text-type ssml \ --text file://example.xml \ --output-format mp3 \ --voice-id Joanna \ speech.mp3
  3. To hear the synthesized speech, play the resulting speech.mp3 file using any audio player.

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.