ssml-builder
This package creates Speech Synthesis Markup Language (SSML) using the builder pattern.
Tired of creating SSML using string concatenation or worring about special characters like '&' ? This project aims to eliminate all these headaches by providing a clean and easy to use API. In addition to making SSML easier to create, this library is fully unit-tested to ensure things work as expected.
Whether you're building an Amazon Alexa Skill using the older version of the JavaScript SDK or the new one, this library is compatible. See the examples in the lower portion of this documentation.
Installation
npm install ssml-builder --save
Features
- Works with both the new and old Alexa SDKs.
- Handles special characters to ensure the SSML is well-formated.
- This library supports the following SSML tags
- amazon:effect
- audio
- break
- emphasis
- prosody
- p
- s
- phoneme
- speak
- say-as which supports all of the known interpret-as values and formats. For more information, see Amazon Documentation here
- characters
- spell-out
- cardinal
- number
- ordinal
- digits
- fraction
- unit
- date
- time
- telephone
- address
- interjection
- expletive
- sub
- w
- ivona:VB: Interpret the word as a verb (present simple).
- ivona:VBD: Interpret the word as a past participle.
- ivona:NN: Interpret the word as a noun.
- ivona:SENSE_1: for more information, see Amazon Documentation here
Code Example for the new Alexa SDK
https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs
see link to the new Alexa SDKvar Speech = ; var speech = ;speech ;var speechOutput = speech;this;
The above code will produce the following SSML
Note: In this example, the SSML is not surrounded by <speak/> because we passed 'true' into the ssml(boolean) method. This is intentional to work with the new SDK due to their current design.
'Hello fellow Alexa developers Testing phone numbers +1-377-777-1888'
Code Example for the old Alexa SDK
var Speech = ; var speech = ;speech ;var speechOutput = speech;response;
The above code will produce the following object
Amazon SSML specific tags
When using Amazon specific tags, like whisper, you will need to import and use the AmazonSpeech object directly.
var AmazonSpeech = ; var speech = ;speech ;var ssml = speech;
Tag Examples
amazon:effect
speech;
audio
speech;
break
speech ;
emphasis
speech;speech;speech;
prosody
speech;speech;speech;speech;speech;speech;speech;speech;speech;speech;speech;speech;
p
speech;
s
speech;
phoneme
speech;speech;
speak
speech;
say-as
speech;speech;speech;
sub
speech;
w
speech;speech;