react-native-openwakeword
v3.1.0
Published
High-performance, offline wake word detection for React Native built with Nitro. Cross-platform (iOS/Android) and powered by openWakeWord.
Maintainers
Readme
react-native-openwakeword
Fully offline, on-device wake word detection for React Native.
Run openWakeWord models directly on iOS and Android with TensorFlow Lite, C++, and Nitro JSI. An open-source alternative to cloud wake word APIs and proprietary SDKs like Picovoice Porcupine and DaVoice.
⭐ We're on our way to 50 stars!
If react-native-openwakeword is useful to you, star the repo and help us get there. It take 2 seconds!
The Problem
Building wake word detection in React Native often means choosing between cloud services or proprietary SDKs:
- Picovoice Porcupine: A commercial, proprietary wake word SDK with its own model and licensing ecosystem.
- DaVoice: A third-party React Native wake word solution with its own commercial licensing and implementation.
react-native-openwakeword provides an open-source alternative: run openWakeWord models directly on iOS and Android with TensorFlow Lite, C++, and Nitro JSI.
This provides full access to the open model ecosystem under a permissive open-source license without third-party commercial blockers.
Wake Word Detection Comparison
| Requirement | Picovoice Porcupine | DaVoice | react-native-openwakeword |
| :--- | :--- | :--- | :--- |
| Offline inference | ✔️ | ✔️️ | ✔️ |
| Open source | ❌ | ❌ | ✔️ Apache-2.0 |
| Commercial license required | Yes | Yes | ❌ None |
| Bring your own .tflite models | ❌ | ❌ | ✔️ |
| Custom wake word models | Restricted | Managed request | ✔️ Compatible .tflite models |
| Cloud dependency | Optional | Managed | ❌ None |
| API key / account | Required | Required | ❌ None |
| React Native | ✔️ | ✔️ | ✔️ |
Performance
Built with a streaming C++ pipeline and fixed ring buffers, designed to stay safely below real-time audio constraints.
Tested on a physical budget device (MediaTek MT8781V/CA, Android 16):
- Average Frame Inference (
processFrame): ~18 ms for an 80 ms audio window (Real-time budget is ~80 ms) - Steady-State CPU Usage: ~5% - 7% while listening
- Memory Footprint: ~32 MB Native Heap PSS
Quick Start
1. Installation
npm install react-native-openwakeword react-native-nitro-modules
(Remember to run cd ios && pod install for iOS)
2. Usage
Supply your own microphone audio stream (16 kHz, mono, signed 16-bit PCM ArrayBuffer) and let the engine handle the rest:
import { Openwakeword } from 'react-native-openwakeword'
// 1. Initialize detector with absolute paths to your .tflite models
const detector = await Openwakeword.createDetector({
melspecPath: '/absolute/path/to/melspectrogram.tflite',
embeddingPath: '/absolute/path/to/embedding_model.tflite',
wakeWordPath: '/absolute/path/to/hey_jarvis.tflite',
})
detector.setThreshold(0.5)
// 2. Feed raw PCM audio frames from your audio recorder library
function onAudioBuffer(buffer: ArrayBuffer) {
const result = detector.processFrame(buffer)
if (result.isDetected) {
console.log('Wake word detected!', result.probability)
}
}
Requirements & Model Setup
- React Native
0.74.0or newer react-native-nitro-modules- Android API
24+ | iOS15.1+ | Node20.0.0+
Model flexibility: Use your own
.tflitemodels and control how they are delivered. On Android, copy bundled models or download them into app storage, then pass their absolute paths to the detector.
Models
Need a wake word model?
- Pre-trained: openWakeWord models
- Custom: LiveKit WakeWord for training and exporting your own models.
API Reference
Openwakeword.createDetector(paths: ModelPaths): Promise<WakeWordDetector>Loads the three.tflitemodels on a background thread. Resolves with a ready detector or rejects with a descriptive error if paths are invalid.WakeWordDetector.processFrame(buffer: ArrayBuffer): DetectionResultProcesses incoming PCM audio (expects 1280-sample / 80ms windows at 16kHz) and returns{ probability: number, isDetected: boolean }.WakeWordDetector.setThreshold(threshold: number): voidSets the probability threshold (0.0to1.0, default0.5). Throws if out of bounds.WakeWordDetector.reset(): voidClears internal streaming audio, mel, and embedding buffers (useful when resetting a voice session).
Profiling & Debugging (Android)
Enable native perf logs via system properties:
adb shell setprop debug.openwakeword.perf 1
adb logcat -s OpenWakeWord
Credits
Built with Nitro Modules and powered by openWakeWord.
License
Apache-2.0
