Skip to content

Fix for using <amazon:effect> SSML #224

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions flask_ask/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import inspect
from flask import json
from xml.etree import ElementTree
from lxml import etree
import aniso8601
from .core import session, context, current_stream, stream_cache, dbgdump
from .cache import push_stream
Expand Down Expand Up @@ -399,9 +399,10 @@ def _copyattr(src, dest, attr, convert=None):

def _output_speech(speech):
try:
xmldoc = ElementTree.fromstring(speech)
parser = etree.XMLParser(dtd_validation=False, load_dtd=False, recover=True)
xmldoc = etree.fromstring(speech, parser)
if xmldoc.tag == 'speak':
return {'type': 'SSML', 'ssml': speech}
except (UnicodeEncodeError, ElementTree.ParseError) as e:
except (UnicodeEncodeError, etree.XMLSyntaxError, AttributeError) as e:
pass
return {'type': 'PlainText', 'text': speech}
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ Flask==0.12.1
pyOpenSSL==17.0.0
PyYAML==3.12
six==1.11.0
lxml==4.1.1