Skip to main content

onnx-wakeword (Python package)

中文说明

Offline wake-word / keyword-spotting for Python — powered by ONNX Runtime, no cloud, models as small as ~130 KB.

  • pip installable: pip install onnx-wakeword
  • Zero audio-library lock-in: core inference is pure numpy + onnxruntime; microphone support is an optional extra
  • Bundled English demo model ("Hey Jarvis", false-trigger-optimized edition) — works out of the box
  • Bring your own model: any bundle from voicute.com (Chinese, English, French, German, Japanese, Spanish, Hindi) or trained yourself

Supported Python versions

Python 3.9 – 3.13, on Windows / Linux / macOS (x86_64 and arm64 — anything ONNX Runtime supports).

Install

pip install onnx-wakeword                # core: inference only (numpy + onnxruntime)

# optional microphone support — pick ONE, you don't need both:
pip install "onnx-wakeword[audio]"        # pyaudio — for WakeWordEngine.start()
pip install "onnx-wakeword[sounddevice]"  # sounddevice — for mic_test.py / infer.py scripts

The core package never imports an audio library. pyaudio and sounddevice are deliberately separate extras so servers / CI can skip them.

Quick start — bundled demo

from onnx_wakeword import WakeWordEngine, get_demo_model

engine = WakeWordEngine()
engine.load(*get_demo_model())   # bundled "Hey Jarvis" model, absolute paths
engine.set_L1(True)              # consecutive-frames gate
engine.start(
    lambda word, probability, info: print(word, probability)
)

Or from your terminal:

onnx-wakeword-demo                        # microphone (needs the [audio] extra)
onnx-wakeword-demo --wav speech.wav       # offline scan of a WAV file — no mic needed
onnx-wakeword-demo --info /path/model_info.json --mel /path/melspectrogram.onnx

Quick start — your own model

from onnx_wakeword import WakeWordEngine

engine = WakeWordEngine()
# Absolute or relative paths both work; model files inside the JSON are
# resolved relative to the JSON file, never the current working directory.
engine.load("/path/to/model_info.json")          # mel resolved automatically
# engine.load("/path/to/model_info.json",        # explicit mel override
#             mel_path="/path/to/melspectrogram.onnx")
engine.start(lambda word, prob, info: print(word, prob))

You usually only need your keyword model (model.onnx + model_info.json, or the ZIP export) — the shared melspectrogram.onnx preprocessing module ships inside the wheel. Resolution order: explicit mel_path > a melspectrogram.onnx inside your bundle > the bundled copy. No head.h needed on Python — the classification head is inside the ONNX graph (that split only exists on the ESP32/TFLite path).

A model bundle is model_info.json + one or more keyword .onnx files + melspectrogram.onnx — or a single .zip containing all of them (the format voicute.com exports). See the models directory for free demo models in 7 languages.

Detection layers (L1–L5)

All production detection logic (the port of the Voicute Android app's DetectionLogic) is included and individually toggleable. Everything is off by default: the models already carry strong false-trigger rejection, so out of the box the engine is a plain threshold gate — one frame above threshold triggers. Enable layers case-by-case for your environment:

Layer Purpose Default
L1 N consecutive frames above threshold (see below) off
L2 peak ≫ background (model-fluctuation filter) off
L3 cooldown against double-triggers off
L4 burst suppression (playback-loop filter) off
L5 energy-jump gate (video/music filter, post-speech confirmation) off
engine.set_L1(True)              # consecutive frames — the usual first upgrade
engine.set_L3(True)              # cooldown, if the word can repeat rapidly
engine.set_threshold(0.5)        # clamped to [0.3, 0.95]
engine.set_cooldown(1500)        # ms

Consecutive frames (L1) — how it works

The model scores every sliding window (~100 ms of audio at the default mel_time=98). A single window above threshold can be a transient: a click, a syllable of background speech that briefly resembles the wake word, or plain model fluctuation. Real wake-word speech, by contrast, is a 500 ms–1 s utterance — it produces a run of high scores as each window covers more of the phrase.

L1 exploits that difference: it triggers only after the same word scores above threshold in N consecutive windows (cons_frames, default 3, read from model_info.json). Two refinements, matching the production Android behavior:

  • Gap tolerance — up to 2 sub-threshold windows in a row do not reset the counter. Real speech dips between syllables; a hard reset would miss fast or uneven utterances.
  • Same-word check — the counter is per word, so in multi-keyword models two alternating words don't reinforce each other.

Trade-offs: L1 adds ~cons_frames × frame-cadence latency (≈300 ms at 3 windows) and can slightly hurt very fast, clipped utterances. Rule of thumb: start with it off for quiet-room use; turn it on (with set_threshold a bit lower, e.g. 0.4–0.5) for noisy rooms, far-field mics, or unattended always-on devices.

CLI: onnx-wakeword-demo --l1 (or --all for every layer); --cons N sets N when testing.

DetectionLogic is also exported standalone for custom pipelines (see mic_test.py for the record/evaluate pattern).

No microphone? Core still runs

Everything except engine.start() works without any audio hardware:

result = engine.predict(audio)   # float32 array, int16 range, 16 kHz
detected = engine.detect(result['word'], result['prob'], result['cons_frames'])

detect() feeds one frame through the same DetectionLogic pipeline as the Android app (record → evaluate), so call it once per sliding window. If you enable L5, set engine.l5_rms (RMS of the current window) before each call — the built-in mic loop does this for you; L5 also adds ~700 ms trigger latency (post-speech confirmation).

Repository scripts vs. package

The legacy scripts still run unchanged (python wakeword_engine.py, python mic_test.py, python infer.py, python infer_tflite.py) — they now import the package. Use the package API for new code.

ONNX vs. TFLite

This package runs the ONNX models (.onnx) via onnxruntime — the right choice for Linux servers, Raspberry Pi-class SBCs, and desktops. The same models also export to TFLite for ESP32 microcontrollers (infer_tflite.py, and the esp32/ directory); TFLite is not part of this pip package.

License

MIT — the bundled demo model is trained in-house from synthetic speech and is redistributable. Custom wake-word models for your own keyword: voicute.com.


中文说明

离线唤醒词 / 关键词识别 Python 包 — 基于 ONNX Runtime,无云端依赖,模型最小约 130 KB。

pip install onnx-wakeword                 # 核心推理(numpy + onnxruntime)
pip install "onnx-wakeword[audio]"        # 麦克风(pyaudio,engine.start() 用)
pip install "onnx-wakeword[sounddevice]"  # sounddevice(mic_test.py / infer.py 用)
from onnx_wakeword import WakeWordEngine, get_demo_model

engine = WakeWordEngine()
engine.load(*get_demo_model())   # 内置英文 Demo「Hey Jarvis」
engine.start(lambda word, prob, info: print(word, prob))

命令行:

onnx-wakeword-demo                     # 麦克风监听
onnx-wakeword-demo --wav speech.wav    # 离线扫描 WAV,无需麦克风
  • 支持 Python 3.9–3.13,Windows / Linux / macOS
  • 自定义模型:engine.load("你的/model_info.json") 即可 —— mel 预处理模块已内置在包里, 也可显式传第二个参数覆盖;支持绝对路径、ZIP 包(含 ZIP 内嵌 mel)
  • Python 端不需要 head.h:分类头在 ONNX 图内(head.h 拆分只存在于 ESP32/TFLite 路径)
  • L1–L5 检测层全部可开关,默认全关(误触发抑制由模型本身承担,开箱即阈值门控; 嘈杂环境按需 set_L1(True) 开连续帧等,原理见上方 "Detection layers" 一节)
  • 无麦克风环境下核心推理照常可用(predict() / detect() 纯 numpy)
  • 核心包不依赖任何音频库;pyaudio 与 sounddevice 均为可选 extra,二选一即可
  • 免费多语言 Demo 模型见 models/;训练自定义唤醒词模型见 voicute.com
  • 许可证 MIT;内置 Demo 模型为自制 TTS 训练产物,可随包再分发

Metadata

Release files for onnx-wakeword 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for onnx-wakeword 0.1.0
File Size Uploaded Provenance Actions
onnx_wakeword-0.1.0.tar.gz 719.6 kB Without provenance Details for onnx_wakeword-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for onnx-wakeword 0.1.0
File Interpreter ABI Platform Actions
onnx_wakeword-0.1.0-py3-none-any.whl Python 3 none any Details for onnx_wakeword-0.1.0-py3-none-any.whl

Total release size: 1.4 MB

Release files / onnx_wakeword-0.1.0.tar.gz

Download URL onnx_wakeword-0.1.0.tar.gz
Size 719.6 kB
Tags Source
SHA-256 checksum
How to use checksums
099c232d8ad3450cda89c53cbde7f7bc10f531a380809702173f333166a1fcf3
BLAKE2b-256 checksum
How to use checksums
794f0284038e22ecf907dc1549441479638c747cc1c7639fcb3a0934392ce2bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.6

Release files / onnx_wakeword-0.1.0-py3-none-any.whl

Download URL onnx_wakeword-0.1.0-py3-none-any.whl
Size 713.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
076bb1ed159e9145d30ccd1a24a126211d0cb3fb621185c74dc42c84520bb134
BLAKE2b-256 checksum
How to use checksums
71f8336e03d951b93ba43478b956867b5cf4b792122866b223113d5f49149d87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.6

Security for onnx-wakeword 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page