Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maghis/fluent-ssml
Alexa SSML templates
https://github.com/maghis/fluent-ssml
alexa aws nodejs skills speech ssml typescript
Last synced: about 2 months ago
JSON representation
Alexa SSML templates
- Host: GitHub
- URL: https://github.com/maghis/fluent-ssml
- Owner: maghis
- Created: 2017-08-13T22:23:08.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-10-18T13:51:32.000Z (about 6 years ago)
- Last Synced: 2024-11-09T07:12:39.326Z (about 2 months ago)
- Topics: alexa, aws, nodejs, skills, speech, ssml, typescript
- Language: TypeScript
- Homepage:
- Size: 115 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# fluent-ssml
Compose Alexa SSML (*Speech Synthesis Markup Language*) with a fluent interface.
Features:
- support for the full [Alexa SSML Reference](https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/speech-synthesis-markup-language-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
```ts
import { ssml, renderXml } from "fluent-ssml";const template = ssml("I am a template");
// prints I am a template
console.log(renderXml(template));
```Using templated strings for parametric templates
```ts
const template = ssml(p => `${p.name} is a cool dude`);// prints Jon is a cool dude
console.log(renderXml(template, { name: "Jon" }));
```Use the fluent api for more complicated templates
This code...
```ts
const template = ssml()
.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({ strength: "strong" })
.say(p => `you are gonna keep your ${p.quality}`)
)
.sayAs("interjection", "abracadabra");// produces a simple object model with the rendered template
// easy to use for testing or debugging
const rendered = template.render({ quality: "sanity" });// produces the final xml
const xml = renderXml(rendered);console.log(xml);
```...renders this (reformatted for clarity)
```xml
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```