GithubHelp home page GithubHelp logo

react-voice's Introduction

react-speech-recognition A React hook that converts speech from the microphone to text and makes it available to your React components.

npm version npm downloads license Coverage Status

How it works useSpeechRecognition is a React hook that gives a component access to a transcript of speech picked up from the user's microphone.

SpeechRecognition manages the global state of the Web Speech API, exposing functions to turn the microphone on and off.

Under the hood, it uses Web Speech API. Note that browser support for this API is currently limited, with Chrome having the best experience - see supported browsers for more information.

This version requires React 16.8 so that React hooks can be used. If you're used to version 2.x of react-speech-recognition or want to use an older version of React, you can see the old README here. If you want to migrate to version 3.x, see the migration guide here.

Useful links Basic example Why you should use a polyfill with this library Cross-browser example Supported browsers Polyfills API docs Troubleshooting Version 3 migration guide TypeScript declaration file in DefinitelyTyped Installation To install:

npm install --save react-speech-recognition

To import in your React code:

import SpeechRecognition, { useSpeechRecognition } from 'react-speech-recognition'

Basic example The most basic example of a component using this hook would be:

import React from 'react'; import SpeechRecognition, { useSpeechRecognition } from 'react-speech-recognition';

const Dictaphone = () => { const { transcript, listening, resetTranscript, browserSupportsSpeechRecognition } = useSpeechRecognition();

if (!browserSupportsSpeechRecognition) { return Browser doesn't support speech recognition.; }

return (

Microphone: {listening ? 'on' : 'off'}

Start Stop Reset

{transcript}

); }; export default Dictaphone;

๐Ÿ“‹ react-use-clipboard NPM version Test build status Bundle size Bundle size

A React Hook that provides copy to clipboard functionality.

Install You can install react-use-clipboard with NPM or Yarn.

npm install react-use-clipboard yarn add react-use-clipboard Usage Here's how to use react-use-clipboard:

import useClipboard from "react-use-clipboard";

function App() { const [isCopied, setCopied] = useClipboard("Text to copy");

return ( Was it copied? {isCopied ? "Yes! ๐Ÿ‘" : "Nope! ๐Ÿ‘Ž"} ); } You can reset the isCopied value after a certain amount of time with the successDuration option.

import useClipboard from "react-use-clipboard";

function App() { const [isCopied, setCopied] = useClipboard("Text to copy", { // isCopied will go back to false after 1000ms. successDuration: 1000, });

return ( Was it copied? {isCopied ? "Yes! ๐Ÿ‘" : "Nope! ๐Ÿ‘Ž"} ); }

react-voice's People

Contributors

alokkumar167 avatar

Watchers

 avatar

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.