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
40 lines
1.3 KiB
Makefile
40 lines
1.3 KiB
Makefile
# speech: the agent's ears and voice, as a capability over Cap'n Web.
|
|
# Tools come from the flake: nix develop --command make test
|
|
|
|
WHISPER = https://huggingface.co/ggerganov/whisper.cpp/resolve/main
|
|
MODEL = cache/ggml-base.en.bin
|
|
VOICES = https://huggingface.co/rhasspy/piper-voices/resolve/main/en/en_US/danny/low
|
|
VOICE = cache/en_US-danny-low.onnx
|
|
PORT = 18024
|
|
PHRASE = Put on the ballgame.
|
|
UA = pdtv26-speech-setup (curl)
|
|
|
|
.PHONY: help test smoke
|
|
.DELETE_ON_ERROR:
|
|
|
|
## list targets
|
|
help:
|
|
@awk -f ../make-help.awk $(MAKEFILE_LIST)
|
|
|
|
## the unit tests, in Nix's build sandbox: no network, no models
|
|
test:
|
|
nix build -L --no-link ..#speech-js
|
|
|
|
## the server and clients, with node, sox, whisper, and piper
|
|
cache/speech: $(wildcard *.js *.sh *.nix package*.json) ../flake.nix ../flake.lock
|
|
nix build -L --out-link $@ ..#speech
|
|
|
|
## whisper's English model (about 150 MB; once, kept in cache/)
|
|
$(MODEL):
|
|
mkdir -p cache
|
|
curl -fsSL -A '$(UA)' -o $@ $(WHISPER)/$(notdir $@)
|
|
|
|
## a piper voice and its config (once, kept in cache/)
|
|
cache/en_US-danny-low.%:
|
|
mkdir -p cache
|
|
curl -fsSL -A '$(UA)' -o $@ $(VOICES)/$(notdir $@)
|
|
|
|
## a round trip through a real server: speak PHRASE, hear it back, compare
|
|
smoke: cache/speech $(MODEL) $(VOICE) $(VOICE).json
|
|
./smoke.sh cache/speech/bin $(MODEL) $(VOICE) $(PORT) '$(PHRASE)'
|