1.0.10 • Published 4 years ago

ssml-tsx v1.0.10

Weekly downloads
56
License
MIT
Repository
github
Last release
4 years ago

ssml-tsx

Version CircleCI License: MIT

Write SSML (Speech Synthesis Markup Language) inline within JSX or TSX. This module includes type definitions for SSML.

Install

$ npm install --save ssml-tsx

Add "jsx": "react" into your tsconfing.json .

 {
   "compilerOptions": {
     ...,
+    "jsx": "react",
   }
 }

Usage

For simple usage, write ssml tag with the file name as .tsx extension. Don't forget the JSX pragma @jsx ssml.

Passing it to renderToString renders it as a string.

/** @jsx ssml */
import ssml, { rendetToString } from "ssml-tsx";

console.log(renderToString(
  <speak>
    <say-as interpret-as="date">10/1</say-as>
  </speak>
));
// => "<speak><say-as interpret-as=\"date\">10/1</say-as></speak>"

It also works with component styles. Currently only function components are supported.

/** @jsx ssml */
import ssml, { rendetToString, FC } from "ssml-tsx";

const Foo: FC<{ name: string }> = ({ name }) => (
  <speak>
    <say-as interpret-as="characters">{name}</say-as>
    <break time="2s" />
    <p>What would you like to do today?</p>
  </speak>
);
console.log(renderToString(<Foo name="bar" />));

Supported tags

  • <amazon-domain /> (amazon:domain)
  • <amazon-effect /> (amazon:effect)
  • <amazon-emotion /> (amazon:emotion)
  • <audio />
  • <break />
  • <emphasis />
  • <lang />
  • <p />
  • <phoneme />
  • <prosody />
  • <s />
  • <say-as />
  • <speak />
  • <sub />
  • <voice />
  • <w />

Using with eslint

Use eslint-pllugin-react to make lint work correctly.

$ npm install --save-dev eslint-pllugin-react

Add this lines into your .eslintrc.js

 plugins: [
   ...,
+  "react"
 ],
 rules: {
   ...,
+  "react/jsx-uses-react": "error",
+  "react/jsx-uses-vars": "error",
 }
1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.0

4 years ago

0.0.2-alpha.2

4 years ago

0.0.2-0

4 years ago