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>
<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>