Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 99e73ea653 | |||
| ab1784f5e1 | |||
| 2c73493bf8 | |||
| ff202c0c35 | |||
| 02d96e611d | |||
| 62eef01c18 | |||
| 1a8aed35b8 |
@@ -71,15 +71,30 @@ func newWakeModels(melPath, embedPath, headPath, libPath string) (*wakeModels, e
|
||||
return nil, fmt.Errorf("wake word: onnx runtime: %w", err)
|
||||
}
|
||||
}
|
||||
// One thread per session, not the default of every core. Measured on
|
||||
// workpc: the default took mavwaked from 68% of one core to 335% of
|
||||
// three, for three graphs that each run in well under 80ms single
|
||||
// threaded. An always-on gate that eats a quarter of the workstation is
|
||||
// not a gate he will leave running.
|
||||
opts, err := ort.NewSessionOptions()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("wake word: session options: %w", err)
|
||||
}
|
||||
defer opts.Destroy()
|
||||
if err := opts.SetIntraOpNumThreads(1); err != nil {
|
||||
return nil, fmt.Errorf("wake word: intra-op threads: %w", err)
|
||||
}
|
||||
if err := opts.SetInterOpNumThreads(1); err != nil {
|
||||
return nil, fmt.Errorf("wake word: inter-op threads: %w", err)
|
||||
}
|
||||
open := func(p string, in, out []string) (*ort.DynamicAdvancedSession, error) {
|
||||
s, err := ort.NewDynamicAdvancedSession(p, in, out, nil)
|
||||
s, err := ort.NewDynamicAdvancedSession(p, in, out, opts)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("wake word: load %s: %w", p, err)
|
||||
}
|
||||
return s, nil
|
||||
}
|
||||
m := &wakeModels{}
|
||||
var err error
|
||||
if m.mel, err = open(melPath, []string{"input"}, []string{"output"}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -21,11 +21,15 @@ import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
// defaultWakeThreshold — score above which the keyword was said. Picked from
|
||||
// the false-accept rate on held-out Russian speech, not from accuracy: a miss
|
||||
// costs him a repeat, a false accept costs a turn nobody asked for. See
|
||||
// docs/evals for the wakes-per-hour this buys.
|
||||
const defaultWakeThreshold = 0.99
|
||||
// defaultWakeThreshold — score above which the keyword was said.
|
||||
//
|
||||
// Picked from the false-accept rate on held-out Russian speech, not from
|
||||
// accuracy: a miss costs him a repeat, a false accept costs a turn nobody
|
||||
// asked for. Over 65 minutes of Common Voice, 0.99 woke her three times and
|
||||
// 0.999 once, and the difference in recall was one render out of 126. So the
|
||||
// default is the strict one. `docs/evals/2026-08-09-wake-word.md` has both
|
||||
// tables.
|
||||
const defaultWakeThreshold = 0.999
|
||||
|
||||
// wakeWord is the streaming state around wakeModels. It is fed the same
|
||||
// capture frames the VAD sees and answers whether the keyword has just been
|
||||
|
||||
+37
-14
@@ -4,11 +4,22 @@
|
||||
# user unit because it needs his ALSA session and his ssh agent, and because
|
||||
# it should stop when he logs out.
|
||||
#
|
||||
# THERE IS NO WAKE WORD YET (V-487 stage two). Anything spoken near the fifine
|
||||
# becomes a turn. What makes that safe rather than expensive is voiceSender:
|
||||
# it sends Surface=SurfaceVoice, which caps every command at L0, so no
|
||||
# accidental trigger runs a destructive act. It does not stop her answering
|
||||
# out loud, so this unit is his to stop when the room is not his alone.
|
||||
# The keyword is "Мэйвен" and the three -wake- flags are what require it
|
||||
# (V-487 stage two). Without them anything spoken near the fifine becomes a
|
||||
# turn, which voiceSender makes safe rather than expensive: it sends
|
||||
# Surface=SurfaceVoice, capping every command at L0. That does not stop her
|
||||
# answering out loud, which is the whole reason the keyword exists.
|
||||
#
|
||||
# The threshold is 0.999 and it is the binary's default, so it is not passed.
|
||||
# It came from 65 minutes of held-out Russian speech through this same binary:
|
||||
# 0.9 false wakes an hour against 2.8 at 0.99, for one lost render out of 126
|
||||
# (docs/evals/2026-08-09-wake-word.md). If the room proves noisier than the
|
||||
# corpus, read the scores out of this unit's journal and pass -wake-threshold.
|
||||
# Do not lower it by guessing.
|
||||
#
|
||||
# A keyword shorter than 1.32s can be heard too late to be used, because the
|
||||
# head scores 1.28s of audio and the VAD has closed the utterance by then.
|
||||
# "Мэйвен, <request>" is unaffected. A bare "Мэйвен" is the case that fails.
|
||||
#
|
||||
# -vad-model is passed on purpose. Silero answers "is this frame speech" where
|
||||
# the energy floor answers "is this frame loud". It declines white noise at
|
||||
@@ -24,27 +35,39 @@
|
||||
# systemctl --user enable --now mavwaked.service
|
||||
|
||||
[Unit]
|
||||
Description=Maven always-on listening (VAD, no wake word yet)
|
||||
Description=Maven always-on listening (silero VAD, "Мэйвен" keyword)
|
||||
# The tunnel is the only path to mavend and the only thing authenticating it.
|
||||
Requires=maven-voice-tunnel.service
|
||||
After=maven-voice-tunnel.service
|
||||
|
||||
[Service]
|
||||
# card 0 is the fifine USB microphone. Named, and not "default", because the
|
||||
# default device follows whatever pipewire last decided and this daemon should
|
||||
# not change ears when he plugs in a headset.
|
||||
# The Scarlett Solo 4th Gen, and not the fifine. The fifine was the device
|
||||
# here for three days and mavwaked never logged one utterance in them, because
|
||||
# it returns RMS 0.00004 with its capture switch on and its ALSA volume at the
|
||||
# full 496 of 496. That silence is in the hardware, so no flag reaches it.
|
||||
#
|
||||
# Named CARD=Gen and not card 4, because a USB card number moves when
|
||||
# something else is replugged and this daemon must not change ears quietly.
|
||||
# Not "default" either: that follows whatever pipewire last decided.
|
||||
#
|
||||
# plughw and not hw. mavwaked asks arecord for 16kHz mono, which is what the
|
||||
# whole pipeline is canonical in. The fifine offers 2 channels at 44100 or
|
||||
# 48000 and nothing else, so bare hw:0,0 dies on "Channels count non
|
||||
# available" before a frame is read. plughw puts ALSA's downmix and resampler
|
||||
# in front. Any replacement microphone wants the same treatment.
|
||||
# whole pipeline is canonical in. Neither microphone offers it, so bare hw
|
||||
# dies on "Channels count non available" before a frame is read. plughw puts
|
||||
# ALSA's downmix and resampler in front. Any replacement wants the same.
|
||||
#
|
||||
# The Scarlett measured RMS 0.003 against 0.14 on the onboard input, so its
|
||||
# front-panel gain is the thing to raise if she mishears. That is a knob, not
|
||||
# a control ALSA exposes. The two loud devices, the onboard ALC897 and the
|
||||
# camera, both clip at peak 1.0 and are worse candidates, not better ones.
|
||||
Environment=LD_LIBRARY_PATH=%h/.local/lib
|
||||
ExecStart=%h/.local/bin/mavwaked \
|
||||
-device plughw:0,0 \
|
||||
-device plughw:CARD=Gen,DEV=0 \
|
||||
-addr 127.0.0.1:9100 \
|
||||
-lang ru \
|
||||
-vad-model %h/.local/share/maven/models/silero_vad.onnx \
|
||||
-wake-model %h/.local/share/maven/models/maven_wakeword.onnx \
|
||||
-wake-mel %h/.local/share/maven/models/melspectrogram.onnx \
|
||||
-wake-embed %h/.local/share/maven/models/embedding_model.onnx \
|
||||
-onnx-lib %h/.local/lib/libonnxruntime.so
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
|
||||
+13
-1
@@ -170,7 +170,19 @@ The device is `plughw:0,0` and not `hw:0,0`. The fifine offers 2 channels at
|
||||
44100 or 48000 and nothing else, and mavwaked asks arecord for 16kHz mono. Bare
|
||||
`hw` dies on "Channels count non available" before a frame is read.
|
||||
|
||||
There is no wake word yet (V-487 stage two), so the loop runs open.
|
||||
The three `-wake-` flags require the keyword "Мэйвен" (V-487 stage two). Drop
|
||||
them and the loop runs open, which is what it did before. The threshold is the
|
||||
binary's default of 0.999 and is not passed. Over 65 minutes of held-out
|
||||
Russian speech it woke her 0.9 times an hour against 2.8 at 0.99. That cost one
|
||||
lost render out of 126 (`docs/evals/2026-08-09-wake-word.md`).
|
||||
|
||||
The three sessions are pinned to one thread each. onnxruntime otherwise sizes
|
||||
its pool to every core and spins between runs, which took mavwaked from 68% of
|
||||
one core to 335%. With the cap it sits at 81%, so the gate costs about 13%.
|
||||
|
||||
A keyword shorter than 1.32s can be heard too late to be used. The head scores
|
||||
1.28s of audio, and the VAD has closed the utterance by then.
|
||||
"Мэйвен, <request>" is unaffected. A bare "Мэйвен" is the case that fails.
|
||||
|
||||
mavwaked connects at startup and holds the conn, so a nudge routed to voice
|
||||
reaches the speaker before he has said anything (V-671). It used to connect
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
# The "Мэйвен" wake word: what it hears and what it invents
|
||||
|
||||
*Measured 2026-08-09 on workpc and homesrv. V-487, stage two of two.*
|
||||
|
||||
Stage one gave mavwaked silero-vad, which answers "is this frame speech".
|
||||
Nothing answered "was this said to her", so every utterance near the
|
||||
microphone became a turn. SurfaceVoice caps acts at L0, which made that safe
|
||||
rather than expensive. L0 does not cap reading, so the room could still hear
|
||||
his facts read back.
|
||||
|
||||
The keyword is "Мэйвен". openWakeWord's two frozen feature models do the
|
||||
hearing and a 100KB head trained here draws the boundary. It runs on CPU
|
||||
beside silero and never touches the GPU.
|
||||
|
||||
## Why a per-window accuracy is not a number anyone can act on
|
||||
|
||||
The gate scores every 80ms. A 1.7% false-accept rate per window sounds small
|
||||
and means a wake every few seconds. The useful question is how many times an hour
|
||||
it wakes on speech that was not the keyword. So every table below counts
|
||||
threshold crossings over whole clips and divides by the audio duration.
|
||||
|
||||
A crossing, not a window above the threshold. A keyword held high for half a
|
||||
second is one wake, not six.
|
||||
|
||||
## The data
|
||||
|
||||
Positives are 600 silero TTS renders of three stressings of the keyword, six
|
||||
speakers, ten trailing phrases, augmented eight ways each. Hard negatives are
|
||||
560 renders of confusable Russian words. Real speech is Common Voice ru and Golos.
|
||||
The 74257 Common Voice clips were already on workpc from the CrisperWhisper
|
||||
work. The 200 Golos clips came from the CW2 WER eval.
|
||||
|
||||
Splits are by source file. Augmented copies of one render on both sides of a
|
||||
split would measure memorisation.
|
||||
|
||||
Golos was never trained on at any stage, so it answers the harder question:
|
||||
does this survive a change of speakers and rooms.
|
||||
|
||||
## Three heads
|
||||
|
||||
Each row is a full retrain. The false-accept column is 8.89 hours of Common
|
||||
Voice that no stage of training had seen.
|
||||
|
||||
| trained on | recall (window) | false wakes/hour @0.99 |
|
||||
|---|---|---|
|
||||
| TTS + 13.7 min of Golos | 0.869 | not measurable |
|
||||
| + 4000 Common Voice clips | 0.836 | 21.9 |
|
||||
| + 3837 mined hard negatives | 0.784 | 4.2 |
|
||||
| + 753 more mined | 0.810 | 3.4 |
|
||||
|
||||
The first row is why the second exists. Thirteen minutes of held-out speech
|
||||
cannot measure a rate for a gate that scores twelve times a second. A head
|
||||
trained only against TTS learns to tell TTS from not-TTS.
|
||||
|
||||
Mining is the whole story after that. Random negatives teach the head what
|
||||
most speech sounds like. They do not teach it the few syllable sequences that
|
||||
score high, because 4000 clips barely contain them. So the current head was
|
||||
run over 20000 fresh clips, keeping every window it scored above 0.05. That
|
||||
found 3837 windows in 855512. Repeating those ten times in the next training
|
||||
run cut the rate five-fold.
|
||||
|
||||
The second round found 753 in 852240, a fifth of the yield, and bought a
|
||||
further 20%. It also recovered recall, which the first round had cost. Whether
|
||||
a third round is worth 25 minutes of workpc is untested.
|
||||
|
||||
## Where the threshold came from
|
||||
|
||||
Both columns are held out. Positives are the 126 renders in the test split.
|
||||
Speech is 65.1 minutes of Common Voice, disjoint from every training and
|
||||
mining pool. Both were run through the built `mavwaked` binary reading PCM from a
|
||||
file, not through the python that trained the head.
|
||||
|
||||
| threshold | renders shipped | false wakes/hour |
|
||||
|---|---|---|
|
||||
| 0.99 | 116 / 126 | 2.8 |
|
||||
| 0.999 | 115 / 126 | 0.9 |
|
||||
|
||||
One render against a third of the false wakes. `defaultWakeThreshold` is
|
||||
0.999.
|
||||
|
||||
Golos disagrees. It gave 2 wakes in 14 minutes at every threshold, which is
|
||||
8.7 per hour. Two events is not a rate. What it does say is that a handful of real utterances score above 0.999
|
||||
and no threshold will move them.
|
||||
|
||||
## What it costs him
|
||||
|
||||
Ten of the 126 held-out renders were heard and still dropped, and every one
|
||||
was an utterance shorter than 1.32s. The head scores 16 embeddings, or 1.28s of
|
||||
audio. The score therefore peaks up to a second after a short keyword ends.
|
||||
By then the VAD has closed the utterance and dispatch has already asked.
|
||||
|
||||
Real commands are "Мэйвен, <request>" and run past two seconds, which gives
|
||||
the head the whole request to peak during. A bare "Мэйвен" with nothing after
|
||||
it is the case that fails. One fix would hold an ignored utterance for a grace
|
||||
period and ship it if the keyword lands late. It is not built.
|
||||
|
||||
## What it costs the workstation
|
||||
|
||||
Under systemd on workpc, mavwaked sat at 335% of a core with the gate on and
|
||||
68% with only silero. onnxruntime sizes its thread pool to every core and spins
|
||||
between runs, and this gate runs three graphs twelve times a second. Pinning
|
||||
all three sessions to one thread brought it to 81%, so the keyword costs about
|
||||
13% of one core. The three graphs each finish in well under 80ms that way.
|
||||
|
||||
## What was not measured
|
||||
|
||||
No room recordings. Every negative above is a clean corpus clip. This gate
|
||||
will live among a television, a fan and the far side of a kitchen. None of
|
||||
those are in these numbers.
|
||||
|
||||
No measurement of him. Training on his voice means copying his transcripts off
|
||||
homesrv, which is his call and has not been asked.
|
||||
Reference in New Issue
Block a user