
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
react-voice-search-widget
Advanced tools
A plug-and-play React voice search widget using speech-to-text.
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.
π€ 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.
Install the component via NPM:
npm install react-voice-search-widget
# or
yarn add react-voice-search-widget
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;
VoiceInput.tsx
The main component that handles:
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.
Your backend should expose two endpoints:
/api/transcribe
(POST)multipart/form-data
) and returns a JSON { text: "transcribed text" }
./search?q=query
(GET){
"results": [
{
"id": "1",
"name": "<highlighted text>",
"category": "<highlighted category>",
"matchedWords": ["keyword1", "keyword2"]
}
]
}
π Example backend repo: speech-to-text (GitHub)
To work locally and customize:
# Start dev server
npm run dev
# Lint the code
npm run lint
# Build for production
npm run build
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
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.
Planned for future versions:
MIT License
@aarathi01
Contributions and feedback are welcome!
FAQs
A plug-and-play React voice search widget using speech-to-text.
The npm package react-voice-search-widget receives a total of 3 weekly downloads. As such, react-voice-search-widget popularity was classified as not popular.
We found that react-voice-search-widget demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Β It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.