Speech Synthesis Markup Language (SSML) provides a standard way to mark up text for the generation of synthesized speech. It supports 27 languages and more than 40 voices, and allows developers to control pronunciation, pitch, and volume.

For more information on SSML, see Getting Started with SSML.

Speak elements with SSML can be nested inside GetDigits and GetInput XML element tags.

from flask import Flask, Response, request, url_for
from plivo import plivoxml

app = Flask(__name__)

@app.route("/ssml/", methods=["GET", "POST"])
def ssml():
    element = plivoxml.ResponseElement()
    response = (
        element.add(
            plivoxml.SpeakElement(content="The word", voice="Polly.Joey", language="en-US")
            .add_say_as("read", interpret_as="characters")
            .add_s("may be interpreted as either the present simple form")
            .add_w("read", role="amazon:VB")
            .add_s("or the past participle form")
            .add_w("read", role="amazon:VBD")
        )
        .to_string(False)
    )
    print(response)
    return Response(response, mimetype="text/xml")

if __name__ == "__main__":
    app.run(host="0.0.0.0", debug=True)

Response

<Response>
  <Speak voice="Polly.Amy">
    <prosody rate="medium">
    Hello and welcome to the Plivo text-to-speech engine.
    <break/>
    <break/>
    We’re now testing the
    <say-as interpret-as="spell-out">SSML</say-as>
    feature.
    </prosody>
  </Speak>
</Response>
<Response>
  <GetDigits numDigits="1" playBeep="true">
  <Speak voice="Polly.Salli">
  <prosody rate="fast">
  Please press 1 to proceed.
  <break/>
  <break/>
  We’re now testing the
  <say-as interpret-as="spell-out">SSML</say-as>
  feature.
  </prosody>
  </Speak>
  </GetDigits>
</Response>