๐Ÿš€ Big News:Socket Has Acquired Secure Annex.Learn More โ†’
Socket
Book a DemoSign in
Socket

react-text-to-speech

Package Overview
Dependencies
Maintainers
1
Versions
160
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-text-to-speech

An easy-to-use React.js library that leverages the Web Speech API to convert text to speech.

latest
Source
npmnpm
Version
5.1.9
Version published
Weekly downloads
3.7K
-10.88%
Maintainers
1
Weekly downloads
ย 
Created
Source

react-text-to-speech

npm version npm downloads bundle size license

A React.js text-to-speech library with real-time text highlighting, dynamic speech controls, and unlimited text length, powered by the Web Speech API.

Install

# npm
npm install react-text-to-speech --save

# yarn
yarn add react-text-to-speech

# pnpm
pnpm add react-text-to-speech

# bun
bun add react-text-to-speech

Quick Start

Two ways to add speech to your React app. Pick whichever fits your use case.

Option 1 - useSpeech hook (full control)

import React from "react";
import { useSpeech } from "react-text-to-speech";

export default function App() {
  const { Text, speechStatus, start, pause, stop } = useSpeech({
    text: "This library is awesome!",
    stableText: true,
  });

  return (
    <div style={{ display: "flex", flexDirection: "column", rowGap: "1rem" }}>
      <Text />
      <div style={{ display: "flex", columnGap: "0.5rem" }}>
        {speechStatus !== "started" ? (
          <button onClick={start}>Start</button>
        ) : (
          <button onClick={pause}>Pause</button>
        )}
        <button onClick={stop}>Stop</button>
      </div>
    </div>
  );
}

Option 2 - <Speech> component (minimal setup)

import React from "react";
import Speech from "react-text-to-speech";

export default function App() {
  return <Speech text="This library is awesome!" stableText={true} />;
}

What's Included

FeatureDetails
๐Ÿ”Š Text-to-SpeechPowered by the Web Speech API
๐Ÿ–Š๏ธ Text HighlightingHighlights text as it's spoken
๐ŸŽ›๏ธ Dynamic ControlsAdjust pitch, rate, volume, lang, voiceURI mid-speech
โ™พ๏ธ Unlimited InputBypasses the Web Speech API's built-in text length limit
๐Ÿ“‹ DirectivesInline playback control via special text syntax
๐Ÿ” Multiple InstancesRun several speech instances simultaneously
๐Ÿงน Auto CleanupSpeech stops automatically on component unmount
โš ๏ธ Error HandlingBuilt-in APIs for speech errors and events

License

MIT

Keywords

component

FAQs

Package last updated on 09 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts