voice-js-lite-by-ashish
v1.0.1
Published
Lightweight voice command library for the browser
Maintainers
Readme
🎤 Voice JS Lite
Voice JS Lite is a lightweight JavaScript library that lets you control your website using voice commands.
It is designed for:
- Speed
- Simple setup
- Internal tools
- Reducing repeated clicking (submit, next, save, etc.)
✨ Features
- Voice command detection in the browser
- Simple API (
on,start,stop) - Unlimited custom commands
- Continuous listening
- No external dependencies
- Works with any frontend (Vanilla JS, React, Next.js)
📁 Project Structure
voice-js/
├─ src/
│ └─ index.js
├─ test.html
├─ package.json
└─ README.md
🚀 How to Run
Voice recognition requires a local server.
Option 1: VS Code
- Install Live Server
- Open the project folder
- Right-click
test.html - Click Open with Live Server
Option 2: Node.js
npx serve .Then open:
http://localhost:3000/test.html🧠 Basic Usage
Import
import Voice from "./src/index.js";Create instance
const voice = new Voice();Register commands
voice.on("submit", () => {
console.log("Submit command triggered");
});
voice.on("login", () => {
console.log("Login command triggered");
});Start listening (required user action)
voice.start();🗣 How Commands Work
The library uses partial matching.
Examples:
- Saying
"submit form"→ triggerssubmit - Saying
"please login"→ triggerslogin
This makes voice commands flexible and fast.
🛑 Stop Listening
voice.on("stop", () => {
voice.stop();
});📚 API
new Voice(options)
new Voice({ lang: "en-US" });| Option | Description | Default | | ------ | ------------------------------- | ------- | | lang | Language for speech recognition | en-US |
voice.on(command, callback)
Register a voice command.
voice.on("save", () => {});voice.off(command)
Remove a command.
voice.off("save");voice.start()
Start voice recognition ⚠️ Must be called after a user interaction (click, tap).
voice.stop()
Stop listening.
🌐 Browser Support
- Chrome ✅
- Edge ✅
- Brave ✅
- Firefox ❌ (not supported)
🔐 Permissions
Microphone access is required. You must allow it when the browser asks.
🧪 Debugging
Open browser DevTools → Console.
You will see logs like:
HEARD: submit📄 License
MIT License Free to use and modify.
👤 Author
Built for learning, fun, and productivity.
---
If you want, next I can help you:
- Make it **npm publish–ready**
- Write a **short README** version
- Add **examples section**
- Convert README to **professional open-source style**
Just tell me what’s next 👌