Files
Maven/deploy/mavwaked.service
T

86 lines
4.4 KiB
Desktop File

# mavwaked — always-on listening, on workpc where the microphone is.
#
# User unit, beside mavgpud.service and maven-voice-tunnel.service. It is a
# user unit because it needs his ALSA session and his ssh agent, and because
# it should stop when he logs out.
#
# 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
# the same RMS 0 frames to 68-99, and still hears all four spoken fixtures
# (docs/evals/2026-08-09-silero-vad.md). It costs 509us a frame, 1.7% of one
# core, and never touches the GPU. Drop the flag and the energy floor is back.
#
# -barge-in is NOT passed. The threshold is room-specific and this room has no
# number yet. Turn it on only after reading the "suppressed while speaking"
# means out of this unit's own journal, never by guessing.
#
# install: cp to ~/.config/systemd/user/ on workpc
# cp ../deploy/asoundrc to ~/.asoundrc on workpc
# systemctl --user enable --now mavwaked.service
[Unit]
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]
# 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.
#
# mavmic and not plughw:CARD=Gen,DEV=0. deploy/asoundrc defines mavmic and
# carries the whole reason: the card's capture stream is 4 channels, and two of
# them are a unity-gain loopback of everything the workstation plays. plughw
# downmixes all four, so a TV show woke her with the gain knob at 0. Install
# that file as ~/.asoundrc on workpc or this device does not resolve.
#
# Named CARD=Gen inside mavmic 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.
#
# mavmic is a plug device and not hw. mavwaked asks arecord for 16kHz mono,
# which is what the whole pipeline is canonical in. Neither microphone offers
# it, so bare hw dies on "Channels count non available" before a frame is read.
# Any replacement wants ALSA's resampler in front the same way.
#
# The mic is on the XLR, which is Analogue 2 on this card and not Analogue 1:
# Air and 48V are both named for Line In 2 and both belong to a mic preamp.
# Measured 2026-08-09 through mavmic at 16kHz mono, gain up: rms 0.01826 peak
# 0.09290 spoken, against a 0.00031 preamp floor, and 0.00002 for the whole
# stream with a show playing. Front-panel gain is still the thing to raise if
# she mishears, and it is a knob, not a control ALSA exposes.
Environment=LD_LIBRARY_PATH=%h/.local/lib
ExecStart=%h/.local/bin/mavwaked \
-device mavmic \
-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
[Install]
WantedBy=default.target