Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for using <amazon:effect> SSML #224

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

MattLodge
Copy link

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

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