speechmarkdown / speechmarkdown-js

Speech Markdown grammar, parser, and formatters for use with JavaScript.
MIT License
76 stars 16 forks source link

TypeScript version Node.js version MIT

speechmarkdown-js

Speech Markdown grammar, parser, and formatters for use with JavaScript.

Supported platforms:

Find the architecture here

Quick start

SSML - Amazon Alexa

Convert Speech Markdown to SSML for Amazon Alexa

const smd = require('speechmarkdown-js');

const markdown = `Sample [3s] speech [250ms] markdown`;
const options = {
  platform: 'amazon-alexa',
};

const speech = new smd.SpeechMarkdown();
const ssml = speech.toSSML(markdown, options);

The resulting SSML is:

<speak>
Sample <break time="3s"/> speech <break time="250ms"/> markdown
</speak>

SSML - Google Assistant

Convert Speech Markdown to SSML for Google Assistant

const smd = require('speechmarkdown-js');

const markdown = `Sample [3s] speech [250ms] markdown`;
const options = {
  platform: 'google-assistant',
};

const speech = new smd.SpeechMarkdown();
const ssml = speech.toSSML(markdown, options);

The resulting SSML is:

<speak>
Sample <break time="3s"/> speech <break time="250ms"/> markdown
</speak>

Plain Text

Convert Speech Markdown to Plain Text

const smd = require('speechmarkdown-js');

const markdown = `Sample [3s] speech [250ms] markdown`;
const options = {};

const speech = new smd.SpeechMarkdown();
const text = speech.toText(markdown, options);

The resulting text is:

Sample speech markdown

More

Options

You can pass options into the constructor:

const smd = require('speechmarkdown-js');

const markdown = `Sample [3s] speech [250ms] markdown`;
const options = {
  platform: 'amazon-alexa',
};

const speech = new smd.SpeechMarkdown(options);
const ssml = speech.toSSML(markdown);

Or in the methods toSSML and toText:

const smd = require('speechmarkdown-js');

const markdown = `Sample [3s] speech [250ms] markdown`;
const options = {
  platform: 'amazon-alexa',
};

const speech = new smd.SpeechMarkdown();
const ssml = speech.toSSML(markdown, options);

Available options are:

Working on this project?

Grammar

The biggest place we need help right now is with the completion of the grammar and formatters.

Short Format

Standard Format

Available scripts

License

Licensed under the MIT. See the LICENSE file for details.