Flask-ask not recognizing SSML in YAML file and outputting plain text response

663 views Asked by At

Below is a response template in my templates.yaml file:

entity_paused: <speak>I paused {{ entity }} <say-as interpret-as="digits">{{ id }}</say-as></speak>.

According to the flask-ask documents, they automatically detect SSML based on the root element 'speak'. Yet when I test my app, Alexa readys the template varbatim and I can see the response sent back to the Alexa service is Plaintext type. I believe the SSML is correct according to the Amazon documentation

I call the template via:

return statement(render_template('paused_entity', entity='SomeEntity', id=123456))

Apologies in advance if this is something basic as I've only been coding for 7 months. Thanks!

4

There are 4 answers

0
heytimj On

in case anyone finds this in the future, the originally supplied template is correct. Not sure why I had to copy and re-paste it but there was some weird unindent error.

0
Daniel On

For me, the problem was in .../flask_ask/models.py file. Scroll down to def _output_speech(speech): function and replace:

xmldoc = ElementTree.fromstring(speech)
    if xmldoc.tag == 'speak':

with:

if '<speak' in speech:

Easy and works...

0
Kraka On

In my case the string of the yaml has been loaded as unicode.

- <speak> Schön dich zu sehen! </speak> 

I fixed it by encoding the unicode to normal string.

alexa_speaks.encode('utf-8')

Now amazon recognizes the sentences in my yaml file correct as ssml.

1
Adam E. On

I had problems with this too and found that I needed to restart the FlaskAsk instance before it would detect changes with my templates.yaml file.