Hands-freePrivacy Warning
Wake Word Detection
Enable hands-free activation using a custom phrase like 'Hey Computer'.
How it Works
Wake word mode keeps the microphone listener active but silences command execution until a specific keyword is heard. This creates a "Hands Free" experience similar to smart home devices.
⚠️ Privacy Warning
This feature works by continuously streaming audio to the speech recognition provider (e.g., Google) to convert it to text. JSVoice then checks that text stream for your keyword.
This is not an offline, on-device wake word engine. Do not use this feature if you require strict privacy or if you are using a paid API (like OpenAI Whisper) usage-based pricing, as "listening" costs money.
Configuration
Enable wake word by passing the wakeWord option to the constructor.
javascript
1const voice = new JSVoice({
2 wakeWord: 'hey assistant',
3 wakeWordTimeout: 5000,
4 onWakeWordDetected: (word) => {
5 // 1. Play a 'ding' sound
6 playSound('wake');
7
8 // 2. Show UI feedback
9 console.log('Listening for command...');
10 }
11});Interaction Flow
- Standby: The microphone listens, but commands are ignored.
- Activation: User says "Hey Assistant". System fires `onWakeWordDetected`.
- Active Window: The system enters an "Active" state for 5 seconds (configurable).
- Execution: If a valid command (e.g. "Scroll Down") is spoken within the window, it executes.
- Reset: After the timeout or command execution, the system returns to Standby.