Introduction
react-text-to-speech is an easy-to-use React.js component that leverages the Web Speech API to convert text to speech.
Features
- Text-to-Speech: Converts text to speech using the Web Speech API.
- Text Highlighting: Highlights text as it is read aloud using the
useSpeech
hook orSpeech
component. - Error and Event Handling: Provides APIs for managing errors and events via
useSpeech
hook orSpeech
component. - Multiple Speech Instances: Supports multiple speech instances using
useSpeech
hook orSpeech
component. - Customization: Fully customizable through the
useSpeech
hook orSpeech
component. - Unlimited Text Input: Overcomes the Web Speech API's text length limit for continuous speech.
- Dynamic Controls: Dynamically adjust
pitch
,rate
,volume
,lang
, andvoiceURI
during speech. - Auto Cleanup: Automatically stops speech when the component unmounts.
Installation
Install react-text-to-speech
using:
- npm
- yarn
- pnpm
- bun
npm install react-text-to-speech --save
yarn add react-text-to-speech
pnpm add react-text-to-speech
bun add react-text-to-speech
Usage
react-text-to-speech offers two main ways to integrate text-to-speech functionality into your React.js applications.