Python Wake Word Detection Guide
Step-by-step guide to adding on-device wake word detection to your Python application.
New to voice activation? Read what a wake word is and how wake word detection works before choosing an integration path.
Python Integration Guide
📦 Repository
GitHub: https://github.com/frymanofer/Python_WakeWordDetection
Python SDK for wake word detection with NumPy and ONNX Runtime.
Step 1: Installation
# Install from PyPI pip install davoice-wake-word # Or install from source git clone https://github.com/frymanofer/Python_WakeWordDetection cd python-wake-word pip install -e .
Step 2: Basic Usage
from davoice import KeywordDetector
import sounddevice as sd
def on_detection(result):
print(f"Wake word detected!")
print(f"Confidence: {result['confidence']:.2f}")
print(f"Timestamp: {result['timestamp']}")
# Initialize detector
detector = KeywordDetector(
model_path="models/hey_jarvis.onnx",
threshold=0.97,
sample_rate=16000
)
# Start detection
print("Listening for wake word...")
detector.start(callback=on_detection)
# Keep running
try:
while True:
sd.sleep(1000)
except KeyboardInterrupt:
detector.stop()
print("Stopped listening")Step 3: Advanced Configuration
from davoice import KeywordDetector, DetectorConfig
import numpy as np
# Advanced configuration
config = DetectorConfig(
model_path="models/custom_wake_word.onnx",
threshold=0.95,
buffer_count=3,
min_detection_interval=2.0, # seconds
enable_noise_reduction=True,
log_level="INFO"
)
detector = KeywordDetector(config)
# Custom audio processing
def audio_callback(indata, frames, time, status):
if status:
print(f"Audio status: {status}")
# Process audio chunk
audio_data = np.frombuffer(indata, dtype=np.float32)
result = detector.process_audio(audio_data)
if result and result['detected']:
print(f"Wake word detected! Confidence: {result['confidence']:.3f}")
# Start streaming with custom callback
import sounddevice as sd
stream = sd.InputStream(
samplerate=16000,
channels=1,
callback=audio_callback,
blocksize=1024
)
with stream:
print("Listening...")
sd.sleep(60000) # Run for 60 secondsStep 4: Multi-Model Detection
from davoice import MultiModelDetector
# Detect multiple wake words simultaneously
detector = MultiModelDetector([
{
'name': 'hey_jarvis',
'model_path': 'models/hey_jarvis.onnx',
'threshold': 0.97
},
{
'name': 'ok_computer',
'model_path': 'models/ok_computer.onnx',
'threshold': 0.95
}
])
def on_multi_detection(result):
print(f"Detected: {result['model_name']}")
print(f"Confidence: {result['confidence']:.2f}")
detector.start(callback=on_multi_detection)
# Or check manually
while True:
results = detector.get_latest_detections()
for result in results:
if result['detected']:
print(f"{result['name']}: {result['confidence']:.2f}")✅ Use Cases
- • Desktop applications and voice assistants
- • Raspberry Pi and IoT devices
- • Server-side voice processing
- • Research and prototyping
Need Help Getting Started?
Our team provides free integration support and custom wake word training for all platforms.
Free Development Support • Code Examples • Community Discord • Custom Wake Words in 1–2 Working Days