#!/bin/sh # hear.sh MODEL: a WAV clip on stdin, whisper's transcript on stdout. # The Nix build fills in @sox@ and @whisper@ (server.nix). set -eu model=$1 tmp=$(mktemp -d) trap 'rm -rf "$tmp"' EXIT cat > "$tmp/in.wav" # mono, 16-bit, normalized: the box's mics are quiet (speech peaks near -27 dBFS) @sox@/bin/sox "$tmp/in.wav" -r 16000 -c 1 -b 16 "$tmp/clip.wav" remix - gain -n -3 @whisper@/bin/whisper-cli -m "$model" -f "$tmp/clip.wav" -t 4 -nt -np 2>"$tmp/err" \ || { cat "$tmp/err" >&2; exit 1; }