Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

react-webspeech

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-webspeech

Official WebSpeech for React.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

⭐️ If you like react-webspeech, give it a star! ⭐️


react-webspeech

react-webspeech

react-webspeech – Official WebSpeech for React.

NPM downloads npm bundle size Build Status JavaScript Style Guide

Features

  • Compatible with both JavaScript and TypeScript
  • useSpeechSynthesis (text-to-speech)
  • useSpeechRecognition (speech-to-text)

Install

react-webspeech is available on npm:

npm install react-webspeech --save

react-webspeech is available on yarn as well:

yarn add react-webspeech

useSpeechSynthesis

useSpeechSynthesis is a text-to-speech react hook.

Usage

import React, { useState } from 'react';
import { useSpeechSynthesis } from 'react-webspeech';

function App() {
  const [text, setText] = useState('I love React');
  const { speak } = useSpeechSynthesis();

  return (
    <div>
      <textarea
        value={text}
        onChange={(event) => setText(event.target.value)}
      />
      <button onClick={() => speak({ text })}>Speak</button>
    </div>
  );
}

export default App;

Prop

PropTypeRequireDescription
onEnd() => voidCalled when SpeechSynthesis has finished being spoken.

Return

ReturnTypeDescription
isSupportedbooleantrue if the browsers supports SpeechSynthesis otherwise false.
isSpeakingbooleantrue if SpeechSynthesis is speaking otherwise false.
voicesSpeechSynthesisVoice[]Use to get an array of SpeechSynthesisVoice that is passed to the speak function.
cancel(): voidCalled to stop reading.
speak(speak Params): voidCalled to make SpeechSynthesis read the text.

speak Params

PropTypeDefaultRequireDescription
textstring""The text that will be read by SpeechSynthesis.
voiceSpeechSynthesisVoicespeechSynthesis.getVoices()[0]The voice that will be used to speak.
ratenumber1The speed at which SpeechSynthesis will be spoken at.
pitchnumber1The pitch at which SpeechSynthesis will be spoken at.
volumenumber1The volume that SpeechSynthesis will be spoken at.

💖 Wrap Up

If you think any of the react-webspeech can be improved, please do open a PR with any updates and submit any issues. Also, I will continue to improve this, so you might want to watch/star this repository to revisit.

🌟 Contribution

We'd love to have your helping hand on contributions to react-webspeech by forking and sending a pull request!

Your contributions are heartily ♡ welcome, recognized and appreciated. (✿◠‿◠)

How to contribute:

  • Open pull request with improvements
  • Discuss ideas in issues
  • Spread the word
  • Reach out with any feedback

⚖️ License

The MIT License License: MIT

Keywords

react

FAQs

Package last updated on 21 Jul 2020

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