Custom wake word for Python
Add a wake word to any Python project with one short script. Load one file, stream the microphone, and run your own code when it hears you.
91%of wake word utterances caught, on average, in our benchmark
~45 minfrom typing your phrase to a finished model
Why it works well here
- ✓Standard ONNX, so it works with openWakeWord out of the box
- ✓Fast on a normal CPU, with no GPU needed
- ✓Easy to plug into scripts, bots and background services
How to set it up
- 01Train your wake word. Type your phrase on Outspoken and download the .onnx file.
- 02Install the packages. pip install openwakeword sounddevice numpy.
- 03Load the model. Create an openwakeword Model with your .onnx file.
- 04Stream the microphone. Feed 16 kHz audio in chunks of 1280 samples and check the score.
import openwakeword
import sounddevice as sd
openwakeword.utils.download_models()
model = openwakeword.Model(wakeword_models=["hey_kitchen.onnx"], inference_framework="onnx")
def on_audio(indata, frames, time, status):
scores = model.predict(indata[:, 0])
for name, score in scores.items():
if score > 0.5:
print("Wake word detected:", name)
with sd.InputStream(samplerate=16000, channels=1, dtype="int16", blocksize=1280, callback=on_audio):
input("Listening. Press Enter to stop.\n")Questions
Do I need a GPU?
No. It runs in real time on a CPU.
What audio does it expect?
16 kHz mono, in chunks of 1280 samples (about 80 ms). The guide's script handles it for you.
Does it work offline?
After the first run downloads two small shared models, yes.