flask-ask icon indicating copy to clipboard operation
flask-ask copied to clipboard

Fix for using <amazon:effect> SSML

Open MattLodge opened this issue 7 years ago • 1 comments

Encountered an issue where if I tried to submit a template with the amazon:effect tag, the parser would raise an error. This would result in the SSML being submitted as plain text.

I've moved from using xml.etree to lxml, which seems to solve the problem, but does add another dependency.

MattLodge avatar Mar 03 '18 12:03 MattLodge

👍 on having this merged... I've been using dirty monkey patching to avoid new dependencies

def _output_speech(speech):
    try:
        xmldoc = ElementTree.fromstring(speech.replace('amazon:effect', 'aaa'))
        if xmldoc.tag == 'speak':
            return {'type': 'SSML', 'ssml': speech}
    except (UnicodeEncodeError, ElementTree.ParseError) as e:
        pass
    return {'type': 'PlainText', 'text': speech}

flask_ask.models._output_speech = _output_speech

fopina avatar Mar 29 '18 07:03 fopina