New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

reactjs-texttospeech

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reactjs-texttospeech

A React Component for text to speech conversion

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-66.67%
Maintainers
0
Weekly downloads
 
Created
Source

reactjs-texttospeech

reactjs-texttospeech is a lightweight React hook for converting text to speech using the Web Speech API. This hook allows developers to easily add text-to-speech capabilities to their React applications.

Features

  • Simple and easy-to-use API.
  • Support play,pause and stop function.
  • Customize pitch and rate.

Installation

To install the package, use npm or yarn:


npm install reactjs-texttospeech

or


yarn add reactjs-texttospeech

Usage

Here's a quick example of how to use the useSpeeched hook in your React component:

import React, { useState } from 'react';
import { useSpeeched } from './useSpeeched';

const TextToSpeechComponent = () => {
    const [text, setText] = useState("Hello, this is a test");
    const [rate, setRate] = useState(1);
    const [pitch, setPitch] = useState(1);
    const { handlePlay, handlePause, handleStop, isPaused } = useSpeeched(text, rate, pitch);

    return (
        <div>
            <textarea value={text} onChange={(e) => setText(e.target.value)} />
            <div>
                <label>Rate:
                    <input type="number" value={rate} onChange={(e) => setRate(Number(e.target.value))} min="0.1" max="2" step="0.1" />
                </label>
            </div>
            <div>
                <label>Pitch:
                    <input type="number" value={pitch} onChange={(e) => setPitch(Number(e.target.value))} min="0" max="2" step="0.1" />
                </label>
            </div>
            <button onClick={handlePlay}>Play</button>
            <button onClick={handlePause}>{isPaused ? 'Resume' : 'Pause'}</button>
            <button onClick={handleStop}>Stop</button>
        </div>
    );
};

export default TextToSpeechComponent;

Development

If you want to contribute or modify the package, clone the repository and install the dependencies:

git clone https://github.com/SubramanyaKS/reactjs-texttospeech.git
cd reactjs-texttospeech
npm install

To build the package, run:

npm run build

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgements

  • Inspired by the simplicity of the Web Speech API.
  • Thanks to all contributors and the open-source community for making this possible.

Keywords

FAQs

Package last updated on 03 Jul 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc