JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 112
  • Score
    100M100P100Q78768F
  • License Apache-2.0

This package creates Speech Synthesis Markup Language (SSML) using the builder pattern.

Package Exports

  • ssml-builder

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ssml-builder) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

ssml-builder

This package creates Speech Synthesis Markup Language (SSML) using the builder pattern. It is fully unit-tested to ensure the best quality. It works with both the new and old Alexa SDKs. See the code examples below.

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
    • audio
    • break
    • p
    • s
    • phoneme
    • speak
    • say-as which supports all of the known interpt-as values and formats. For more information, see Amazon Documentation here
      • cardinal
      • ordinal
      • digits
      • fraction
      • unit
      • date
      • time
      • telephone
      • address
    • 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

var Speech = require('ssml-builder');

var speech = new Speech();
speech.say('Hello');
speech.pause('1s');
speech.say('fellow Alexa developers');
var speechOutput = speech.ssml(true);
this.emit(':tell', speechOutput);

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 <break time='1s'/> fellow Alexa developers

Code Example for the old Alexa SDK

var Speech = require('ssml-builder');

var speech = new Speech();
speech.say('Hello');
speech.pause('1s');
speech.say('fellow Alexa developers');
var speechOutput = speech.toObject();
response.tell(speechOutput);

The above code will produce the following object

  { 
    "type": "SSML",
    "speech": "<speak>Hello <break time='1s'/> fellow Alexa developers</speak>"
  }