An open API service indexing awesome lists of open source software.

https://github.com/morganney/tts-react

Convert text to speech using React.
https://github.com/morganney/tts-react

aws-polly htmlaudioelement react speechsynthesis speechsynthesisutterance text-to-speech

Last synced: 3 months ago
JSON representation

Convert text to speech using React.

Awesome Lists containing this project

README

        

# [`tts-react`](https://www.npmjs.com/package/tts-react)

![CI](https://github.com/morganney/tts-react/actions/workflows/ci.yml/badge.svg)
[![codecov](https://codecov.io/gh/morganney/tts-react/branch/main/graph/badge.svg?token=ZDP1VBC8E1)](https://codecov.io/gh/morganney/tts-react)
[![NPM version](https://img.shields.io/npm/v/tts-react.svg)](https://www.npmjs.com/package/tts-react)

TextToSpeech React component

Repository for `tts-react`, a React component and hook that uses the [`SpeechSynthesis`](https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis) and [`SpeechSynthesisUtterance`](https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesisUtterance) API's to convert text to speech. You can fallback to the [`HTMLAudioElement`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio) API by providing a `fetchAudioData` prop to the hook or component.

> [!IMPORTANT]
> Requires a peer dependency of React and ReactDOM >= 19.
> Use `tts-react@3` if your project is on React 18.

## Install

```console
npm i react react-dom tts-react
```

For projects using React 18:

```console
npm i react@18 react-dom@18 tts-react@3
```

## Table of Contents

* [tts-react](./packages/tts-react)
* [storybook](./packages/story)
* [examples](./docs/examples.md)

## Demo (Storybook)

[morganney.github.io/tts-react](https://morganney.github.io/tts-react/)

## Progress

* Helped fix a `SpeechSynthesisUtterance` default volume [Chrome bug](https://bugs.chromium.org/p/chromium/issues/detail?id=1385117).