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 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-voice-search-widget

v1.0.1

Published

A plug-and-play React voice search widget using speech-to-text.

Readme

🔊 react-voice-search-widget

A plug-and-play React component that lets users search either by typing or using voice input (speech-to-text). Built for reusability, flexibility, and quick integration into any modern React application.


✨ Features

  • 🎤 Voice Input Support
    Capture audio from the microphone and transcribe it using a backend speech-to-text service (e.g., Vosk).

  • ⌨️ Text Input Support
    Supports both voice and manual text input in the same field.

  • 🔍 Real-Time Search
    Automatically queries a backend search API as you speak or type (with debounce).

  • 🎯 Keyword Highlighting
    Matched words are highlighted in the search results and transcript text.

  • ⚛️ Modular and Reusable
    Packaged as a standalone React component that can be embedded in any React app.

  • 💬 Error Handling
    Includes fallback for unsupported browsers and clear messages when audio isn't captured or no results are found.


📦 Installation

Install the component via NPM:

npm install react-voice-search-widget
# or
yarn add react-voice-search-widget

🚀 Usage

import React from 'react';
import VoiceInput from 'react-voice-search-widget';

function App() {
  return (
    <div style={{ maxWidth: 800, margin: '0 auto', padding: '1rem' }}>
      <VoiceInput />
    </div>
  );
}

export default App;

🧱 Component Overview

VoiceInput.tsx

The main component that handles:

  • Microphone access
  • Recording and sending audio to the backend
  • Typing + voice input management
  • Displaying real-time search results

SearchResults.tsx

Displays the result list and highlights matched keywords.

UnsupportedBrowserFallback.tsx

Renders a fallback message if the browser doesn't support MediaRecorder or microphone access.


🛠️ Backend API Expectations

Your backend should expose two endpoints:

/api/transcribe (POST)

  • Accepts an audio file (multipart/form-data) and returns a JSON { text: "transcribed text" }.

/search?q=query (GET)

  • Accepts a search query and returns results in the following format:
{
  "results": [
    {
      "id": "1",
      "name": "<highlighted text>",
      "category": "<highlighted category>",
      "matchedWords": ["keyword1", "keyword2"]
    }
  ]
}

🔗 Example backend repo: speech-to-text (GitHub)


🧪 Development & Build

To work locally and customize:

# Start dev server
npm run dev

# Lint the code
npm run lint

# Build for production
npm run build

🧩 Project Structure

react-voice-search-widget/
├── src/
│   ├──components/
│   │    ├── VoiceInput.tsx
│   │    ├── SearchResults.tsx
│   │    ├── UnsupportedBrowserFallback.tsx
│   ├── types/
│   │   └── types.ts
│   └── assets/
│   │    └── microphone-icon.webp
│   ├── App.tsx
│   ├── main.tsx
│   ├── style.css
├── dist/              # Compiled output
├── package.json
├── tsconfig.json
├── vite.config.ts
└── README.md

🎨 Styling

Tailwind CSS is used for styling. If your host app uses Tailwind, styles will integrate seamlessly. Otherwise, you may want to adjust or override styles accordingly.


📌 Customization (Coming Soon)

Planned for future versions:

  • Props to override API endpoints
  • Custom result renderers
  • Adjustable debounce delay
  • Theming via CSS variables

📃 License

MIT License


🙋‍♀️ Maintainer

@aarathi01
Contributions and feedback are welcome!


🌐 Related Projects