Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-speech-to-text-toolkit

Package Overview
Dependencies
Maintainers
0
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-speech-to-text-toolkit

A lightweight library for integrating speech-to-text functionality into your React applications, using the Web Speech API under the hood.

  • 1.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

react-speech-to-text-toolkit

react-speech-to-text-toolkit is a lightweight library for integrating speech-to-text functionality into your React applications. Leveraging the Web Speech API, this package provides a simple and effective way to convert speech into text.

Installation

To add react-speech-to-text-toolkit to your React project, use the following command:

  npm install react-speech-to-text-toolkit

or if you are using Yarn:

  yarn add react-speech-to-text-toolkit

Usage

Import the useSpeechRecognition hook from the package:

import { useSpeechRecognition } from "react-speech-to-text-toolkit";

Initialize the useSpeechRecognition hook in your component:

const { startRecording, stopRecording, text, isRecording, isBrowserSupported } =
  useSpeechRecognition();

Example

Here's a basic example of how to use react-speech-to-text-toolkit:

import { useSpeechRecognition } from "react-speech-to-text-toolkit";
function App() {
  const {
    startRecording,
    stopRecording,
    text,
    isRecording,
    isBrowserSupported,
  } = useSpeechRecognition();

  if (!isBrowserSupported) {
    return <p>Browser does not support speech recognition</p>;
  }
  return (
    <>
      <button onClick={startRecording}>Start Recording</button>
      <button onClick={stopRecording}>Stop Recording</button>
      <p>Speech To Text: {text}</p>
    </>
  );
}

export default App;

API

The useSpeechRecognition hook provides the following functionalities and state information:

startRecording

  • Type: Function
  • Description: Starts the speech recognition process. Use this function to begin capturing and transcribing speech.

stopRecording

  • Type: Function
  • Description: Stops the speech recognition process. Use this function to end the current speech recognition session.

text

  • Type: String
  • Description: The current transcript of the speech. This state is updated with the transcribed text from the user's speech.

isRecording

  • Type: Boolean
  • Description: Indicates if recording is in progress. This boolean value is true while the speech recognition is active and false otherwise.

isBrowserSupported

  • Type: Boolean
  • Description: Indicates if the browser supports speech recognition. This value is true if the Web Speech API is available in the browser and false otherwise.

Author

Zohaib Ahmad

Keywords

FAQs

Package last updated on 26 Aug 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