BotBuilderCommunity / botbuilder-community-js

Part of the Bot Builder Community Project. Repository for extensions for the Bot Builder JavaScript SDK, including middleware, dialogs, recognizers and more.
MIT License
118 stars 38 forks source link

Validate SSML for Speech #158

Open szul opened 4 years ago

szul commented 4 years ago

Mentioned by @iMicknl in #157--for speech-enabled functionality that accepts SSML, we should validate the data. XSD files can be found at: https://www.w3.org/TR/2009/REC-speech-synthesis-20090303/#AppD

iMicknl commented 4 years ago
szul commented 4 years ago

@iMicknl Are you looking to validate the SSML or looking to build it without explicitly working with XML? I think we need both as options.

iMicknl commented 4 years ago

My main point in #157 was removing the duplicate <speak> tags and wrapping it with <speak> tags if not present. However, good idea to validate the SSML, I am just wondering if this has a performance impact.. So not sure if we should include it by default in the adapters.

szul commented 4 years ago

We can include the validation as optional and/or tie it to the environment (i.e., on for development; off for production).

Could be a moot point though. Do you know if Alexa does some minor validation on its end? Last I checked the optional SSML in MessageFactory.text() in the Bot Framework didn't require the <speak> tags since you were passing the text using a second parameter. Not sure if Alexa has something similar.

iMicknl commented 4 years ago

We can include the validation as optional and/or tie it to the environment (i.e., on for development; off for production).

Possibly we could add SSML validation in a separate helper util, later on? Tying it to environments doesn't make sense for me.

Could be a moot point though. Do you know if Alexa does some minor validation on its end? Last I checked the optional SSML in MessageFactory.text() in the Bot Framework didn't require the <speak> tags since you were passing the text using a second parameter. Not sure if Alexa has something similar.

Amazon does validation server side, which means that they reject your message. Thus the reason that the Alexa adapter is adding tags around the message if you are using activity.speak.

szul commented 4 years ago

@iMicknl Plenty of applications tie certain functionality to what environment you're running in. For example: Template compilation in the Express framework. ASP.NET Core does a few different things depending on environment too. My point was that if you're concerned about the overhead of validating against an XML Schema, you can either make the validation an optional check via a settings property, or you can explicitly validate in non-production environments, but skip the check in production, if there is any concern about developer overhead with the option setting.

Only validating against the wrapped tags seems like a halfway solution. Do you know what happens if you put invalid tags in outside of the <speak> tag? Does Amazon's validation fail, or does it ignore it?