livekit-wakeword-bench 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. livekit_wakeword_bench-0.1.0/.gitignore +9 -0
  2. livekit_wakeword_bench-0.1.0/LICENSE +201 -0
  3. livekit_wakeword_bench-0.1.0/PKG-INFO +154 -0
  4. livekit_wakeword_bench-0.1.0/README.md +112 -0
  5. livekit_wakeword_bench-0.1.0/docs/README.md +13 -0
  6. livekit_wakeword_bench-0.1.0/pyproject.toml +86 -0
  7. livekit_wakeword_bench-0.1.0/src/livekit_wakeword_bench/__init__.py +36 -0
  8. livekit_wakeword_bench-0.1.0/src/livekit_wakeword_bench/_version.py +24 -0
  9. livekit_wakeword_bench-0.1.0/src/livekit_wakeword_bench/augment.py +277 -0
  10. livekit_wakeword_bench-0.1.0/src/livekit_wakeword_bench/bench.py +630 -0
  11. livekit_wakeword_bench-0.1.0/src/livekit_wakeword_bench/card.py +148 -0
  12. livekit_wakeword_bench-0.1.0/src/livekit_wakeword_bench/cli.py +510 -0
  13. livekit_wakeword_bench-0.1.0/src/livekit_wakeword_bench/config.py +217 -0
  14. livekit_wakeword_bench-0.1.0/src/livekit_wakeword_bench/dataset.py +179 -0
  15. livekit_wakeword_bench-0.1.0/src/livekit_wakeword_bench/detectors.py +176 -0
  16. livekit_wakeword_bench-0.1.0/src/livekit_wakeword_bench/export.py +70 -0
  17. livekit_wakeword_bench-0.1.0/src/livekit_wakeword_bench/generate.py +398 -0
  18. livekit_wakeword_bench-0.1.0/src/livekit_wakeword_bench/loader.py +267 -0
  19. livekit_wakeword_bench-0.1.0/src/livekit_wakeword_bench/media.py +216 -0
  20. livekit_wakeword_bench-0.1.0/src/livekit_wakeword_bench/mix.py +153 -0
  21. livekit_wakeword_bench-0.1.0/src/livekit_wakeword_bench/phonemes.py +313 -0
  22. livekit_wakeword_bench-0.1.0/src/livekit_wakeword_bench/report.py +312 -0
  23. livekit_wakeword_bench-0.1.0/src/livekit_wakeword_bench/scaffold.py +103 -0
  24. livekit_wakeword_bench-0.1.0/src/livekit_wakeword_bench/sources.py +595 -0
  25. livekit_wakeword_bench-0.1.0/src/livekit_wakeword_bench/text.py +332 -0
  26. livekit_wakeword_bench-0.1.0/src/livekit_wakeword_bench/tts.py +155 -0
  27. livekit_wakeword_bench-0.1.0/src/livekit_wakeword_bench/verify.py +191 -0
  28. livekit_wakeword_bench-0.1.0/src/livekit_wakeword_bench/viz.py +626 -0
  29. livekit_wakeword_bench-0.1.0/src/livekit_wakeword_bench/voices.json +1014 -0
  30. livekit_wakeword_bench-0.1.0/src/livekit_wakeword_bench/voices.py +100 -0
@@ -0,0 +1,9 @@
1
+ .venv/
2
+ __pycache__/
3
+ .cache/
4
+ out/
5
+ results/
6
+ .env.local
7
+ .env
8
+ *.egg-info/
9
+ src/livekit_wakeword_bench/_version.py
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 LiveKit, Inc.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,154 @@
1
+ Metadata-Version: 2.5
2
+ Name: livekit-wakeword-bench
3
+ Version: 0.1.0
4
+ Summary: Generate wake word datasets (LiveKit Inference TTS + real noise) and benchmark any wake word model
5
+ Project-URL: Homepage, https://github.com/livekit/wakeword-bench
6
+ Project-URL: Repository, https://github.com/livekit/wakeword-bench
7
+ Project-URL: Dataset, https://huggingface.co/datasets/binhpham/wakeword-bench-hey-livekit
8
+ Author-email: Binh Pham <binh.pham@livekit.io>
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: benchmark,dataset,keyword-spotting,livekit,tts,wake-word
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
20
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
+ Requires-Python: >=3.12
22
+ Requires-Dist: aiohttp>=3.14.5
23
+ Requires-Dist: datasets>=3
24
+ Requires-Dist: huggingface-hub>=2.2.0
25
+ Requires-Dist: livekit-agents>=1.2
26
+ Requires-Dist: numpy>=2.5.4
27
+ Requires-Dist: pandas>=3.0.6
28
+ Requires-Dist: pronouncing>=0.3.0
29
+ Requires-Dist: pyarrow>=26.0.0
30
+ Requires-Dist: pydantic>=2.14.1
31
+ Requires-Dist: python-dotenv>=1.2.4
32
+ Requires-Dist: pyyaml>=6.0.3
33
+ Requires-Dist: rich>=15.0.0
34
+ Requires-Dist: scipy>=1.18.1
35
+ Requires-Dist: soundfile>=0.14.0
36
+ Requires-Dist: tqdm>=4.70.1
37
+ Requires-Dist: typer>=0.27.3
38
+ Requires-Dist: wordfreq>=3.1.1
39
+ Provides-Extra: torch
40
+ Requires-Dist: torch>=2.2; extra == 'torch'
41
+ Description-Content-Type: text/markdown
42
+
43
+ # LiveKit WakeWord Bench
44
+
45
+ Generate a benchmark or training dataset for your wake word, with labeled speech, near-miss phrases and realistic audio conditions. Use the benchmark to measure any detector against the same test set.
46
+
47
+ [![Python 3.12+](https://img.shields.io/badge/python-3.12%2B-blue)](https://www.python.org/downloads/)
48
+ [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
49
+ [![Dataset](https://img.shields.io/badge/%F0%9F%A4%97-dataset-yellow)](https://huggingface.co/datasets/binhpham/wakeword-bench-hey-livekit)
50
+
51
+ ## Quick start
52
+
53
+ Requires Python 3.12+ and the [LiveKit CLI](https://docs.livekit.io/intro/basics/cli/). Generation uses LiveKit Inference credits.
54
+
55
+ ```bash
56
+ pip install livekit-wakeword-bench
57
+ lk cloud auth
58
+ lk app env -w
59
+
60
+ # Generate train, validation and test splits for your phrase.
61
+ lkwb generate "hey jarvis" --size small -o out/hey_jarvis
62
+ lkwb verify out/hey_jarvis
63
+ ```
64
+
65
+ For a benchmark only, add `--split test`; for training data only, add `--split train`. Use `--size tiny` for a smoke test. Choose `--plan` to match your account (`build` by default). TTS capacity is shared with production agents: leave room for them with a lower `--set tts.concurrency=N`.
66
+
67
+ For unusual names, run `lkwb init "your wake word"` to create a pronunciation config. See [Generate](docs/generate.md) for sizes, pronunciation, custom settings and outputs.
68
+
69
+ ## What gets generated
70
+
71
+ The generator combines phoneme-guided TTS with recorded noise, room responses and speech. Each clip has 16 kHz audio, a label, phrase timing and metadata describing its voice and audio conditions.
72
+
73
+ | Sample | Contents | What it tests |
74
+ |---|---|---|
75
+ | Positive | Your wake word alone or in a sentence, with varied voices, delivery and speaking speed | Does the model detect the intended phrase? |
76
+ | Adversarial negative | Similar-sounding substitutions, partial phrases and your custom hard negatives | Does it reject near misses? |
77
+ | Ordinary speech | Synthesized sentences without the wake word | Does unrelated conversation trigger it? |
78
+ | Recorded speech | Segments from real speech corpora | Does natural speech trigger it? |
79
+ | Noise only | Background sounds without the target phrase | Do environmental sounds trigger it? |
80
+
81
+ Only positives have label `1`; all negatives have label `0`. Category counts depend on the size and split: training presets contain positives, adversarial negatives and synthesized speech. See the [exact sample counts](docs/generate.md#choose-sample-counts).
82
+
83
+ Positive and adversarial phrases are isolated or placed before/after surrounding speech (`p_carrier=0.35` by default). Near misses are generated from phonetic similarity; add known confusions with `hard_negatives`.
84
+
85
+ ## Which conditions are covered
86
+
87
+ Validation and test clips sample combinations of these conditions. They are not an exhaustive test of every combination.
88
+
89
+ | Condition | Default coverage |
90
+ |---|---|
91
+ | Background noise | Clean background plus five SNR buckets, from quiet (20–30 dB) to noise louder than speech (−5–0 dB) |
92
+ | Competing speech | A second voice 0–20 dB quieter; party scenes with 2–4 talkers and crowd noise |
93
+ | Rooms | Recorded room impulse responses for reverberation |
94
+ | Device effects | EQ, band limiting, clipping, codec compression and varying levels |
95
+ | Voice and delivery | Multiple TTS providers, voices and accent labels; speaking speed 0.85–1.2× |
96
+ | Phrasing | Isolated phrases, phrases in sentences and phonetically similar negatives |
97
+
98
+ For example, the same wake word can be detected alone and missed with a competing speaker:
99
+
100
+ <img alt="A wake word is detected alone but missed with a competing voice" src="assets/teaser.svg">
101
+
102
+ Training clips are stored clean by default so you can [add fresh effects while training](docs/train.md). Test voices, noise, rooms and recorded speakers are held apart from training. Never train on the test split or test sources. Some source corpora restrict commercial use; see [sources and licenses](docs/reference.md#audio-sources).
103
+
104
+ Tune the recipe with YAML or `--set key=value`. For example, generate training data with more competing speech:
105
+
106
+ ```bash
107
+ lkwb generate "hey jarvis" --size small --split train -o out/train_talkers \
108
+ --set splits.train.augment=true \
109
+ --set augment.p_interferer=0.6 \
110
+ --set augment.clean_weight=0.2
111
+ ```
112
+
113
+ Run `lkwb knobs` for all settings. TTS is cached, so changing only augmentation reuses synthesized speech.
114
+
115
+ ## How models are evaluated
116
+
117
+ **The headline score is recall at the lowest tested threshold with no more than 0.5 false positives per hour (FPPH).** Higher is better; change the target with `--score-fpph`.
118
+
119
+ | Criterion | Measurement |
120
+ |---|---|
121
+ | Wake word detection | Recall: fraction of positives detected between phrase onset and 1 second after phrase end |
122
+ | Background false alarms | Triggers per hour of ordinary speech, recorded speech and noise; counted triggers are at least 2 seconds apart by default |
123
+ | Near-miss rejection | Fraction of adversarial clips that trigger; reported separately, excluded from FPPH |
124
+ | Response time | Trigger time relative to phrase end; negative latency means early detection |
125
+ | Compute cost | Processing time / audio duration; use `--workers 1` |
126
+
127
+ Reports break results down by noise, competing speech, room, device effects, voice, accent and phrasing, with 95% confidence intervals. Breakdowns use `--threshold` (default 0.5), which may differ from the headline score's threshold.
128
+
129
+ Synthesized positives do not establish recall on real users. Accent labels come from TTS metadata. Treat confidence intervals wider than about 0.2 as weak evidence; rare false alarms need many hours of negative audio.
130
+
131
+ ## Evaluate on your dataset
132
+
133
+ For a livekit-wakeword v2 streaming model:
134
+
135
+ ```bash
136
+ pip install livekit-wakeword
137
+ lkwb bench path/to/your_model.onnx --data out/hey_jarvis --limit 1000
138
+ ```
139
+
140
+ Open `results/report.html` for charts and playable failures. Remove `--limit` for a full run before reporting results. Compare models using the same dataset, split, filters and limit.
141
+
142
+ Other models use the [custom detector interface](docs/benchmark.md#your-own-model). Existing datasets need no LiveKit credentials. Omitting `--data` uses the public [Hey LiveKit dataset](https://huggingface.co/datasets/binhpham/wakeword-bench-hey-livekit), which is an example benchmark for that phrase.
143
+
144
+ ## Documentation
145
+
146
+ | Task | Guide |
147
+ |---|---|
148
+ | Generate and check your benchmark or dataset | [Generate](docs/generate.md) |
149
+ | Look up sample fields, sources and generation settings | [Reference](docs/reference.md) |
150
+ | Load, augment or export training data | [Train](docs/train.md) |
151
+ | Evaluate detectors and compare results | [Benchmark](docs/benchmark.md) |
152
+ | Contribute or release | [Development](docs/development.md) |
153
+
154
+ For coding agents, see [AGENTS.md](AGENTS.md).
@@ -0,0 +1,112 @@
1
+ # LiveKit WakeWord Bench
2
+
3
+ Generate a benchmark or training dataset for your wake word, with labeled speech, near-miss phrases and realistic audio conditions. Use the benchmark to measure any detector against the same test set.
4
+
5
+ [![Python 3.12+](https://img.shields.io/badge/python-3.12%2B-blue)](https://www.python.org/downloads/)
6
+ [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
7
+ [![Dataset](https://img.shields.io/badge/%F0%9F%A4%97-dataset-yellow)](https://huggingface.co/datasets/binhpham/wakeword-bench-hey-livekit)
8
+
9
+ ## Quick start
10
+
11
+ Requires Python 3.12+ and the [LiveKit CLI](https://docs.livekit.io/intro/basics/cli/). Generation uses LiveKit Inference credits.
12
+
13
+ ```bash
14
+ pip install livekit-wakeword-bench
15
+ lk cloud auth
16
+ lk app env -w
17
+
18
+ # Generate train, validation and test splits for your phrase.
19
+ lkwb generate "hey jarvis" --size small -o out/hey_jarvis
20
+ lkwb verify out/hey_jarvis
21
+ ```
22
+
23
+ For a benchmark only, add `--split test`; for training data only, add `--split train`. Use `--size tiny` for a smoke test. Choose `--plan` to match your account (`build` by default). TTS capacity is shared with production agents: leave room for them with a lower `--set tts.concurrency=N`.
24
+
25
+ For unusual names, run `lkwb init "your wake word"` to create a pronunciation config. See [Generate](docs/generate.md) for sizes, pronunciation, custom settings and outputs.
26
+
27
+ ## What gets generated
28
+
29
+ The generator combines phoneme-guided TTS with recorded noise, room responses and speech. Each clip has 16 kHz audio, a label, phrase timing and metadata describing its voice and audio conditions.
30
+
31
+ | Sample | Contents | What it tests |
32
+ |---|---|---|
33
+ | Positive | Your wake word alone or in a sentence, with varied voices, delivery and speaking speed | Does the model detect the intended phrase? |
34
+ | Adversarial negative | Similar-sounding substitutions, partial phrases and your custom hard negatives | Does it reject near misses? |
35
+ | Ordinary speech | Synthesized sentences without the wake word | Does unrelated conversation trigger it? |
36
+ | Recorded speech | Segments from real speech corpora | Does natural speech trigger it? |
37
+ | Noise only | Background sounds without the target phrase | Do environmental sounds trigger it? |
38
+
39
+ Only positives have label `1`; all negatives have label `0`. Category counts depend on the size and split: training presets contain positives, adversarial negatives and synthesized speech. See the [exact sample counts](docs/generate.md#choose-sample-counts).
40
+
41
+ Positive and adversarial phrases are isolated or placed before/after surrounding speech (`p_carrier=0.35` by default). Near misses are generated from phonetic similarity; add known confusions with `hard_negatives`.
42
+
43
+ ## Which conditions are covered
44
+
45
+ Validation and test clips sample combinations of these conditions. They are not an exhaustive test of every combination.
46
+
47
+ | Condition | Default coverage |
48
+ |---|---|
49
+ | Background noise | Clean background plus five SNR buckets, from quiet (20–30 dB) to noise louder than speech (−5–0 dB) |
50
+ | Competing speech | A second voice 0–20 dB quieter; party scenes with 2–4 talkers and crowd noise |
51
+ | Rooms | Recorded room impulse responses for reverberation |
52
+ | Device effects | EQ, band limiting, clipping, codec compression and varying levels |
53
+ | Voice and delivery | Multiple TTS providers, voices and accent labels; speaking speed 0.85–1.2× |
54
+ | Phrasing | Isolated phrases, phrases in sentences and phonetically similar negatives |
55
+
56
+ For example, the same wake word can be detected alone and missed with a competing speaker:
57
+
58
+ <img alt="A wake word is detected alone but missed with a competing voice" src="assets/teaser.svg">
59
+
60
+ Training clips are stored clean by default so you can [add fresh effects while training](docs/train.md). Test voices, noise, rooms and recorded speakers are held apart from training. Never train on the test split or test sources. Some source corpora restrict commercial use; see [sources and licenses](docs/reference.md#audio-sources).
61
+
62
+ Tune the recipe with YAML or `--set key=value`. For example, generate training data with more competing speech:
63
+
64
+ ```bash
65
+ lkwb generate "hey jarvis" --size small --split train -o out/train_talkers \
66
+ --set splits.train.augment=true \
67
+ --set augment.p_interferer=0.6 \
68
+ --set augment.clean_weight=0.2
69
+ ```
70
+
71
+ Run `lkwb knobs` for all settings. TTS is cached, so changing only augmentation reuses synthesized speech.
72
+
73
+ ## How models are evaluated
74
+
75
+ **The headline score is recall at the lowest tested threshold with no more than 0.5 false positives per hour (FPPH).** Higher is better; change the target with `--score-fpph`.
76
+
77
+ | Criterion | Measurement |
78
+ |---|---|
79
+ | Wake word detection | Recall: fraction of positives detected between phrase onset and 1 second after phrase end |
80
+ | Background false alarms | Triggers per hour of ordinary speech, recorded speech and noise; counted triggers are at least 2 seconds apart by default |
81
+ | Near-miss rejection | Fraction of adversarial clips that trigger; reported separately, excluded from FPPH |
82
+ | Response time | Trigger time relative to phrase end; negative latency means early detection |
83
+ | Compute cost | Processing time / audio duration; use `--workers 1` |
84
+
85
+ Reports break results down by noise, competing speech, room, device effects, voice, accent and phrasing, with 95% confidence intervals. Breakdowns use `--threshold` (default 0.5), which may differ from the headline score's threshold.
86
+
87
+ Synthesized positives do not establish recall on real users. Accent labels come from TTS metadata. Treat confidence intervals wider than about 0.2 as weak evidence; rare false alarms need many hours of negative audio.
88
+
89
+ ## Evaluate on your dataset
90
+
91
+ For a livekit-wakeword v2 streaming model:
92
+
93
+ ```bash
94
+ pip install livekit-wakeword
95
+ lkwb bench path/to/your_model.onnx --data out/hey_jarvis --limit 1000
96
+ ```
97
+
98
+ Open `results/report.html` for charts and playable failures. Remove `--limit` for a full run before reporting results. Compare models using the same dataset, split, filters and limit.
99
+
100
+ Other models use the [custom detector interface](docs/benchmark.md#your-own-model). Existing datasets need no LiveKit credentials. Omitting `--data` uses the public [Hey LiveKit dataset](https://huggingface.co/datasets/binhpham/wakeword-bench-hey-livekit), which is an example benchmark for that phrase.
101
+
102
+ ## Documentation
103
+
104
+ | Task | Guide |
105
+ |---|---|
106
+ | Generate and check your benchmark or dataset | [Generate](docs/generate.md) |
107
+ | Look up sample fields, sources and generation settings | [Reference](docs/reference.md) |
108
+ | Load, augment or export training data | [Train](docs/train.md) |
109
+ | Evaluate detectors and compare results | [Benchmark](docs/benchmark.md) |
110
+ | Contribute or release | [Development](docs/development.md) |
111
+
112
+ For coding agents, see [AGENTS.md](AGENTS.md).
@@ -0,0 +1,13 @@
1
+ # Documentation
2
+
3
+ Start with the [README](../README.md) to generate a dataset and understand its samples, audio conditions and evaluation criteria.
4
+
5
+ | Task | Guide |
6
+ |---|---|
7
+ | Generate a benchmark or training dataset for your phrase | [Generate](generate.md) |
8
+ | Look up sample fields, audio sources and settings | [Reference](reference.md) |
9
+ | Load, augment and export training data | [Train](train.md) |
10
+ | Evaluate a detector on your dataset and compare results | [Benchmark](benchmark.md) |
11
+ | Set up development and publish releases | [Development](development.md) |
12
+
13
+ Keep the generated test set fixed and separate from training when comparing models.
@@ -0,0 +1,86 @@
1
+ [project]
2
+ name = "livekit-wakeword-bench"
3
+ dynamic = ["version"]
4
+ description = "Generate wake word datasets (LiveKit Inference TTS + real noise) and benchmark any wake word model"
5
+ readme = "README.md"
6
+ license = "Apache-2.0"
7
+ license-files = ["LICENSE"]
8
+ authors = [{ name = "Binh Pham", email = "binh.pham@livekit.io" }]
9
+ requires-python = ">=3.12"
10
+ keywords = ["wake-word", "keyword-spotting", "benchmark", "dataset", "tts", "livekit"]
11
+ classifiers = [
12
+ "Development Status :: 4 - Beta",
13
+ "Intended Audience :: Developers",
14
+ "Intended Audience :: Science/Research",
15
+ "Operating System :: OS Independent",
16
+ "Programming Language :: Python :: 3",
17
+ "Programming Language :: Python :: 3.12",
18
+ "Programming Language :: Python :: 3.13",
19
+ "Topic :: Multimedia :: Sound/Audio :: Speech",
20
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
21
+ ]
22
+ dependencies = [
23
+ "aiohttp>=3.14.5",
24
+ "datasets>=3",
25
+ "huggingface-hub>=2.2.0",
26
+ "livekit-agents>=1.2",
27
+ "numpy>=2.5.4",
28
+ "pandas>=3.0.6",
29
+ "pronouncing>=0.3.0",
30
+ "pyarrow>=26.0.0",
31
+ "pydantic>=2.14.1",
32
+ "python-dotenv>=1.2.4",
33
+ "pyyaml>=6.0.3",
34
+ "rich>=15.0.0",
35
+ "scipy>=1.18.1",
36
+ "soundfile>=0.14.0",
37
+ "tqdm>=4.70.1",
38
+ "typer>=0.27.3",
39
+ "wordfreq>=3.1.1",
40
+ ]
41
+
42
+ [project.urls]
43
+ Homepage = "https://github.com/livekit/wakeword-bench"
44
+ Repository = "https://github.com/livekit/wakeword-bench"
45
+ Dataset = "https://huggingface.co/datasets/binhpham/wakeword-bench-hey-livekit"
46
+
47
+ [project.scripts]
48
+ lkwb = "livekit_wakeword_bench.cli:app"
49
+
50
+ [project.optional-dependencies]
51
+ torch = ["torch>=2.2"]
52
+
53
+ [build-system]
54
+ requires = ["hatchling", "hatch-vcs"]
55
+ build-backend = "hatchling.build"
56
+
57
+ [tool.hatch.version]
58
+ source = "vcs"
59
+
60
+ [tool.hatch.build.hooks.vcs]
61
+ version-file = "src/livekit_wakeword_bench/_version.py"
62
+
63
+ [tool.hatch.build.targets.wheel]
64
+ packages = ["src/livekit_wakeword_bench"]
65
+
66
+ [tool.hatch.build.targets.sdist]
67
+ include = ["src/livekit_wakeword_bench", "README.md", "LICENSE"]
68
+
69
+ [dependency-groups]
70
+ dev = [
71
+ "faster-whisper>=1.2.1",
72
+ "matplotlib>=3.11.2",
73
+ "pytest>=9.1.1",
74
+ "ruff>=0.17.0",
75
+ ]
76
+
77
+ [tool.ruff]
78
+ line-length = 100
79
+ target-version = "py312"
80
+
81
+ [tool.ruff.lint]
82
+ select = ["E", "F", "I", "UP"]
83
+ ignore = ["E501"]
84
+
85
+ [tool.pytest.ini_options]
86
+ testpaths = ["tests"]
@@ -0,0 +1,36 @@
1
+ """Generate wake word datasets and benchmark any wake word model."""
2
+
3
+ from importlib.metadata import PackageNotFoundError, version
4
+
5
+ try:
6
+ __version__ = version("livekit-wakeword-bench")
7
+ except PackageNotFoundError: # running from a source tree without an install
8
+ __version__ = "0.0.0"
9
+
10
+ from .bench import BenchConfigRun, BenchResult, benchmark, compare, evaluate, run_detector
11
+ from .config import BenchConfig, load_config, make_config
12
+ from .dataset import DEFAULT_DATASET
13
+ from .detectors import Detector, Prediction, SlidingWindowDetector, load_detector
14
+ from .generate import generate
15
+ from .loader import Sample, WakeWordData
16
+
17
+ __all__ = [
18
+ "__version__",
19
+ "DEFAULT_DATASET",
20
+ "BenchConfig",
21
+ "BenchConfigRun",
22
+ "BenchResult",
23
+ "Detector",
24
+ "Prediction",
25
+ "Sample",
26
+ "SlidingWindowDetector",
27
+ "WakeWordData",
28
+ "benchmark",
29
+ "compare",
30
+ "evaluate",
31
+ "generate",
32
+ "load_config",
33
+ "load_detector",
34
+ "make_config",
35
+ "run_detector",
36
+ ]
@@ -0,0 +1,24 @@
1
+ # file generated by vcs-versioning
2
+ # don't change, don't track in version control
3
+ from __future__ import annotations
4
+
5
+ __all__ = [
6
+ "__version__",
7
+ "__version_tuple__",
8
+ "version",
9
+ "version_tuple",
10
+ "__commit_id__",
11
+ "commit_id",
12
+ ]
13
+
14
+ version: str
15
+ __version__: str
16
+ __version_tuple__: tuple[int | str, ...]
17
+ version_tuple: tuple[int | str, ...]
18
+ commit_id: str | None
19
+ __commit_id__: str | None
20
+
21
+ __version__ = version = '0.1.0'
22
+ __version_tuple__ = version_tuple = (0, 1, 0)
23
+
24
+ __commit_id__ = commit_id = None