fluent-ssml
Compose Alexa SSML (Speech Synthesis Markup Language) with a fluent interface.
Features:
- support for the full Alexa SSML Reference
- everything is immutable, which makes it reusable and composable (like strings)
- simple templating
- extensible and testable
- typescript types!
NOTE: this package is tested on node v8.4.0
install it
npm install --save fluent-ssml
use it
Most basic template
; ; // prints <speak>I am a template</speak>console.logrenderXmltemplate;
Using templated strings for parametric templates
; // prints <speak>Jon is a cool dude</speak>console.logrenderXmltemplate, ;
Use the fluent api for more complicated templates
This code...
.p ssml .sayAs"characters", "ssml" .say"templates can get quite complicated" .p"it's important to keep them composable and parametric" .p ssml .say"if you do" .break .say`you are gonna keep your ` .sayAs"interjection", "abracadabra"; // produces a simple object model with the rendered template// easy to use for testing or debugging; // produces the final xml; console.logxml;
...renders this (reformatted for clarity)
ssml templates can get quite complicated it's important to keep them composable and parametric if you do you are gonna keep your sanity abracadabra