JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 22
  • Score
    100M100P100Q62647F
  • License MIT

Utility to generate SSML markup for different voice platforms

Package Exports

  • speech-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 (speech-builder) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

speech-builder

Build Status

Utility to build SSML documents for different voice platforms.

Motivation / Approach

Since the major voice platforms all support slightly different subsets of SSML, documents built for one platform often cause errors when used somewhere else.

To address this issue, speech-builder accepts a list of feature flags as configuration option.

Basic Usage

const { ssml } = require('speech-builder');

const s = ssml().add('Hello').emphasis('world');

console.log(s.toString());
<speak>Hello<emphasis>world</emphasis></speak>

API

Table of Contents

lang

Adds an xml:lang attribute to the current node. If not supported, this is a no-op.

Parameters

addText

Adds text. Characters with special meaning in XML are properly escaped.

Parameters

addToken

Like addText but prepends a space (unless it's the first token or the previous one alreads ends with whitespace).

Parameters

add

Like addToken but also accepts a function.

Parameters

  • content any

sub

Adds a <sub> tag. If substitions are not supported, the alias is added as text instead.

Parameters

phoneme

Adds a <phoneme> tag. When an object with notations in different alphabets is passed as ph, the first one that is supported will be used. For platforms without phoneme support, the special sub alphabet can be used to generate a <sub> tag as fallback.

Parameters

break

Adds a <break> tag. If not supported, this is a no-op.

Parameters

audio

Adds an <audio> tag. If not supported, the alt text is added as plain text.

Parameters

emphasis

Adds an <emphasis> tag. If not supported, the text is added as-is.

Parameters

p

Adds a <p> tag. If not supported, the text is added as-is.

Parameters

  • content any

s

Adds an <s> tag. If not supported, the text is added as-is.

Parameters

  • content any

w

Adds a <w> tag. If not supported, the text is added as-is.

Parameters

effect

Adds an <*:effect> tag. If not supported, the text is added as-is. NOTE: The namespace can be configured via the effect feature setting.

Parameters

sayAs

Adds an <say-as> tag. If not supported, the text is added as-is.

Parameters

prosody

Adds a <prosody> tag. If not supported, the text is added as-is.

Parameters

replace

Duck-type as string to support the Jovo framework.

Parameters

Adding variations

const { ssml, random, chance } = require('speech-builder');

ssml()
  .add(random('hello', 'ciao', 'hola', 'salut'))
  .add(chance(0.5, 'beautiful'))
  .add('world');

License

MIT