Git Product home page Git Product logo

ssml-tsx's Introduction

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",
 }

ssml-tsx's People

Contributors

dependabot[bot] avatar fujikky avatar renovate-bot avatar renovate[bot] avatar semantic-release-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

hideokamoto

ssml-tsx's Issues

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Can not use `amazon:~` tags.

Hi!
Thanks for publishing a cool library!.

I try to use it for my Alexa Skill, but I found the following issue.

Expect

Render to string my SSML using amazon:XXX tag.

Example

<speak>
      <amazon:effect name="whispered">effect</amazon:effect>
      <amazon:emotion name="excited" intensity="low">emotion</amazon:emotion>
      <amazon:domain name="news">domain</amazon:domain>
      </speak>

Actual

TypeScript throw Error.

スクリーンショット 2020-04-09 23 42 07

Problem

Probably, we can not use JSX/TSX element using :.

Solution

We have to convert these component name and re-convert to a valid name.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/publish-release.yml
  • actions/checkout v3
  • actions/setup-node v3
  • 8398a7/action-slack v3
.github/workflows/test.yml
  • actions/checkout v3
  • actions/setup-node v3
nodenv
.node-version
  • node 16.20.2
npm
package.json
  • @semantic-release/changelog 6.0.3
  • @semantic-release/commit-analyzer 9.0.2
  • @semantic-release/git 10.0.1
  • @semantic-release/github 8.1.0
  • @semantic-release/npm 9.0.2
  • @semantic-release/release-notes-generator 10.0.3
  • @types/jest 29.5.12
  • cz-conventional-changelog 3.3.0
  • eslint 8.57.0
  • eslint-config-timetree 1.7.3
  • husky 8.0.3
  • jest 29.7.0
  • npm-run-all2 6.1.2
  • prettier 3.2.5
  • rimraf 5.0.5
  • semantic-release 19.0.5
  • ts-jest 29.1.2
  • typescript 5.1.6

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.