treethought / flask-assistant

Framework for Building Virtual Assistants with Dialogflow and python
Apache License 2.0
379 stars 101 forks source link

Remove SSML tags from display_text #83

Closed gmolau closed 6 years ago

gmolau commented 6 years ago

Adds a strip_ssml() function to the response module, which can be used to clean up a rendered speech response with SSML tags before displaying it to the user in the Google Assistant app.

Changes the default behavior of the display_text attribute of the _Response class. Currently this defaults to None, which leads Google to display the 'speech' text on GUI surfaces. This is suboptimal, as that speech response might contain SSML tags, which are currently shown to the user. This change sets the display_text explicitly to the same text as the speech response, but with the SSML tags stripped.

Current users of this class don't have to change anything, they just get the added benefit of not having to worry about SSML tags.

Also adds two small unittests for the strip_ssml() function.

gmolau commented 6 years ago

Turns out this isn't necessary because Google does strip the tags automatically, it just didn't work in my case because I was using a XML special character (&).

gmolau commented 6 years ago

See #84 for a proper solution for this problem.