feat(speech): the speech capability over Cap'n Web, behind a gate

The agent's ears and voice: a server on the home server transcribes
a clip (sox, whisper.cpp) and speaks text (piper), one job at a time.
A gate hands the capability to whoever presents its key; the key comes
from systemd's credentials, not argv.

make test runs the unit tests in Nix's sandbox; make smoke starts a
real server on localhost, speaks a phrase, and hears it back.

Generated-by: Claude Opus 5.5
This commit is contained in:
dckc committed 2026-12-02 15:27:50 -06:00
1 parent 147bfdc55e
commit 65e38c23cf
20 files changed
+468

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
# The speech server and clients, with node, and the sox, whisper, and piper the server's scripts use.
# bin/speech-server HOST PORT MODEL VOICE
# bin/hear-client URL < clip.wav
# bin/speak-client URL < text > speech.wav
{ callPackage, runCommand, nodejs-slim, sox, whisper-cpp, piper-tts }:
let
js = callPackage ./default.nix { };
dir = "${js}/lib/node_modules/pdtv26-speech";
in
runCommand "pdtv26-speech" { } ''
mkdir -p $out/bin
substitute ${./hear.sh} $out/bin/hear.sh --subst-var-by sox ${sox} --subst-var-by whisper ${whisper-cpp}
substitute ${./speak.sh} $out/bin/speak.sh --subst-var-by piper ${piper-tts}
chmod +x $out/bin/hear.sh $out/bin/speak.sh
cat > $out/bin/speech-server <<EOF
#!/bin/sh
exec ${nodejs-slim}/bin/node ${dir}/server.js "\$1" "\$2" $out/bin/hear.sh "\$3" $out/bin/speak.sh "\$4"
EOF
for c in hear-client speak-client; do
printf '#!/bin/sh\nexec %s %s/%s.js "$@"\n' ${nodejs-slim}/bin/node ${dir} $c > $out/bin/$c
done
chmod +x $out/bin/speech-server $out/bin/hear-client $out/bin/speak-client
''