Code Monkey home page Code Monkey logo

react-speakup's Introduction

React SpeakUp: Bringing the power of voice to your React applications with ease.

Overview

React SpeakUp is a powerful React package designed to streamline voice interaction within your web applications. Leveraging the Web Speech API, it empowers developers to effortlessly integrate speech recognition and synthesis functionalities into React.js and Next.js projects.

Key Features:

1. Voice to Text Conversion:

  • Effortlessly convert spoken words into text with our intuitive useVoiceToText hook.
  • Speak with your native language and receive exact results.

2. Text to Voice Synthesis:

  • Transform text content into spoken words using the versatile useTextToVoice hook.
  • Fine-tune voice characteristics such as pitch, rate, and volume for a personalized experience.

3. TypeScript Integration:

  • Seamless integration with TypeScript ensures a robust development experience.

4. Easy Integration:

  • Compatible with up to date versions of React.js and Next.js.

5. Styling Freedom:

  • Unrestricted styling possibilities and no limitations on customization.

Getting Started

Install via your favorite package manager

Installation

npm install react-speakup

or

yarn add react-speakup

Usage

Convert voice to text with useVoiceToText

import React from "react";
import { useVoiceToText } from "react-speakup";

const VoiceToTextComponent = () => {
  const { startListening, stopListening, transcript } = useVoiceToText();

  return (
    <div>
      <button onClick={startListening}>Start Listening</button>
      <button onClick={stopListening}>Stop Listening</button>
      <span>{transcript}</span>
    </div>
  );
};

export default VoiceToTextComponent; 

useVoiceToText can take these options

Properties Description Default Value
lang the language you are speaking, e.g. "en-US" or "fa-IR" "en-US"
continuous if its true, it'll stop listening manually, otherwise it stop listening anytime the speech will finished true

Convert text to voice with useTextToVoice

import React from "react";
import { useTextToVoice } from "react-speakup";

const TextToVoiceComponent = () => {
  const { speak, pause, resume, ref, setVoice, voices } = useTextToVoice<HTMLDivElement>();

  return (
    <div>
      <button onClick={speak}>Speak</button>
      <button onClick={pause}>Pause</button>
      <button onClick={resume}>Resume</button>
      <select
        onChange={(event: React.ChangeEvent<HTMLSelectElement>) =>
          setVoice(event.target.value)
        }
      >
        {voices.map((voice) => (
          <option key={voice}>{voice}</option>
        ))}
      </select>
      <div ref={ref}>
        <h1>It's not important which HTML tag your text is within.</h1>
        <div>
          Or <p>how many levels it is nested.</p>
        </div>
      </div>
    </div>
  );
};

export default TextToVoiceComponent;

voices are the list of voices you can use. you can set the voice using setVoice callback function.

useTextToVoice can take these options

Properties Description Default Value
pitch A float representing the utterance pitch value between 0 (lowest) and 2 (highest) 1
rate A float representing the utterance rate value. It can range between 0.1 (lowest) and 10 (highest) 1
volume A float that represents the volume value, between 0 (lowest) and 1 (highest) 1

Contributing

Contributions are very welcome and wanted.

Keywords

web-speech-api, react-speakup, speech-recognition, speech-synthesis, voice-to-text, text-to-voice, speak

react-speakup's People

Contributors

amin-partovi avatar

Stargazers

Michael 'Misha' Litchev avatar  avatar Kushal Verma avatar Mohsen Esmaeili avatar Gurkeerat Singh avatar David Cervantes Caballero avatar  avatar Yaşar İÇLİ avatar  avatar bahram avatar Emad avatar

Watchers

 avatar

Forkers

rjbtechconsult

react-speakup's Issues

iOS Speech Recognition permission issue

Hi there!

I am using your package and it is not working properly on iOS. I have the latest Chrome version v126.0.6478.153 and iOS version 17.5.1

I have allowed permission for speech recognition in the Chrome iOS setting and microphone. Yet, I am still getting errors, that
"Speech Recognition error detected: aborted".

Please provide a solution for this.

Need a Reset Button

there are two functions startListening and stopListening. How about resetting the transcript?
need a function to reset the transcripted text to the initial value.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.