npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-transcribe

v0.1.0

Published

React component for speech-to-text transcription with silence detection

Downloads

20

Readme

React Transcribe

A React component for speech-to-text transcription with silence detection using the browser's Web Speech API.

Installation

npm install react-transcribe
# or
yarn add react-transcribe

Features

  • Real-time speech transcription
  • Silence detection with automatic pausing
  • Countdown timer for maximum silence duration
  • Customizable UI through render props pattern
  • Callback-based communication

Usage

import { SpeechToText } from 'react-transcribe';
import { useState } from 'react';

const MyComponent = () => {
  const [transcript, setTranscript] = useState('');

  // Handle speech updates
  const handleSpeech = (info) => {
    setTranscript(info.transcript);
    console.log('Interim:', info.interimTranscript);
  };

  // Handle listening state changes
  const handleSpeechToggle = (info) => {
    console.log('Listening:', info.isListening);
  };

  return (
    <SpeechToText 
      onSpeech={handleSpeech}
      onSpeechToggle={handleSpeechToggle}
      silenceDuration={1000}
      maxSilenceDuration={60000}
      countdownThreshold={10000}
      language="en-US"
    >
      {({ 
        listening, 
        isActivelySpeaking, 
        silenceCountdown, 
        transcript, 
        interimTranscript,
        toggleListening 
      }) => (
        <div>
          <button onClick={toggleListening}>
            {listening ? 'Stop Listening' : 'Start Listening'}
          </button>
          
          <div>
            {listening
              ? isActivelySpeaking
                ? 'Active Speech Detected'
                : silenceCountdown
                  ? `No Speech Detected (${silenceCountdown}s)`
                  : 'Waiting for Speech'
              : 'Paused'
            }
          </div>
          
          <div>
            <h3>Transcript:</h3>
            <p>{transcript}</p>
          </div>
        </div>
      )}
    </SpeechToText>
  );
};

Props

| Prop | Type | Description | Default | |------|------|-------------|---------| | onSpeech | Function | Callback triggered when speech is detected | - | | onSpeechToggle | Function | Callback triggered when recognition is toggled | - | | children | ReactNode or Function | Either React elements or a render function that receives component state | - | | silenceDuration | number | Duration of silence (ms) before pausing active speaking state | 1000 | | maxSilenceDuration | number | Maximum allowed silence duration (ms) before stopping | 60000 | | countdownThreshold | number | When to start showing countdown (ms) | 10000 | | language | string | Speech recognition language | 'en-US' |

Callback Information

onSpeech callback

Receives an object with:

{
  transcript: string;       // The complete transcription 
  interimTranscript: string; // In-progress transcription
  resetTranscript: () => string | null; // Function to reset transcript and return previous value
}

onSpeechToggle callback

Receives an object with:

{
  isListening: boolean;     // Whether speech recognition is active
  type: 'device';           // The type of toggling (always 'device' for now)
}

State Object (available in render props)

| Property | Type | Description | |----------|------|-------------| | listening | boolean | Whether speech recognition is active | | isActivelySpeaking | boolean | Whether user is actively speaking (resets after silence) | | silenceCountdown | number | Countdown before auto-stopping (null when not counting down) | | transcript | string | Current transcript text | | interimTranscript | string | Interim (in-progress) transcript text | | browserSupportsSpeechRecognition | boolean | Whether browser supports speech recognition | | resetTranscript | function | Reset the transcript | | startListening | function | Start speech recognition | | stopListening | function | Stop speech recognition | | toggleListening | function | Toggle speech recognition on/off |

Browser Support

This component uses the Web Speech API, which is supported in most modern browsers. Check browser compatibility for details.

License

MIT