Skip to content

Fix for using <amazon:effect> SSML#224

Open
MattLodge wants to merge 2 commits into
johnwheeler:masterfrom
MattLodge:master
Open

Fix for using <amazon:effect> SSML#224
MattLodge wants to merge 2 commits into
johnwheeler:masterfrom
MattLodge:master

Conversation

@MattLodge
Copy link
Copy Markdown

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.

@fopina
Copy link
Copy Markdown

fopina commented Mar 29, 2018

👍 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants