Speech marks with SSML example - Amazon Polly

Speech marks with SSML example

The process of generating speech marks from SSML-enhanced text is similar to the process when SSML is not present. Use the synthesize-speech command, and specify the SSML-enhanced text and the type of speech marks that you want, as shown in the following example. To make the example easier to read, we don't include viseme speech marks, but these could be included as well.

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 (^) and use full quotation marks (") around the input text with single quotes (') for interior tags.

aws polly synthesize-speech \ --output-format json \ --voice-id Joanna \ --text-type ssml \ --text '<speak><prosody volume="+20dB">Mary had <break time="300ms"/>a little <mark name="animal"/>lamb</prosody></speak>' \ --speech-mark-types='["sentence", "word", "ssml"]' \ output.txt

When you make this request, Amazon Polly returns the following in the .txt file:

{"time":0,"type":"sentence","start":31,"end":95,"value":"Mary had <break time=\"300ms\"\/>a little <mark name=\"animal\"\/>lamb"} {"time":6,"type":"word","start":31,"end":35,"value":"Mary"} {"time":325,"type":"word","start":36,"end":39,"value":"had"} {"time":897,"type":"word","start":40,"end":61,"value":"<break time=\"300ms\"\/>"} {"time":1291,"type":"word","start":61,"end":62,"value":"a"} {"time":1373,"type":"word","start":63,"end":69,"value":"little"} {"time":1635,"type":"ssml","start":70,"end":91,"value":"animal"} {"time":1635,"type":"word","start":91,"end":95,"value":"lamb"}