Compare commits

..
2 Commits
Author SHA1 Message Date
kiskaadee b69701dbc2 chore(flake): update inputs
- antigravity: bump cli to 1.4.5, ide to 2.5.5, app to 2.25.0
  - dms & companions: update dms to c7692f8, dank-greeter to 4034ba1, dankcalendar to e7123fc
  - zen-browser: bump to 1.23.4b
  - home-manager: update to 6750249
2026-10-23 01:29:17 -05:00
kiskaadee 7c45fbe440 feat(shell): add hermetic transcribe CLI backed by whisper-cpp 2026-10-23 01:28:50 -05:00
3 changed files with 224 additions and 30 deletions

No files matched your search

Generated
+30 -30
View File
@@ -8,11 +8,11 @@
]
},
"locked": {
"lastModified": 1792567233,
"narHash": "sha256-k77tiEnyeNZMvxM69cn9RV/jiDdwq6x+mB5sOB/2NEw=",
"lastModified": 1792653625,
"narHash": "sha256-JF5uTZCXse4JurE3WsJmpOxZ8QlmJKr+sd5U7DTD9Sw=",
"owner": "jacopone",
"repo": "antigravity-nix",
"rev": "9676d7761a3d8946359cd5ed6caa021fac6ca978",
"rev": "0e46037bbdb746b531c4d58bf6339032731d2db2",
"type": "github"
},
"original": {
@@ -29,11 +29,11 @@
]
},
"locked": {
"lastModified": 1792524306,
"narHash": "sha256-b9S8kVbAWgynkuYcKLAittwfUr26jaE3VDlvkhqva1o=",
"lastModified": 1792683863,
"narHash": "sha256-S+1g1tKn2QorHHjJA0lMYZUYPWlQkeQ93dLxiafeW8E=",
"owner": "AvengeMedia",
"repo": "dank-greeter",
"rev": "39d3c17ba4349e6ac3af041805132807cd60a056",
"rev": "4034ba1f5035ce384b322e8b2865495dad3cbb93",
"type": "github"
},
"original": {
@@ -61,11 +61,11 @@
"dank-qml-common_2": {
"flake": false,
"locked": {
"lastModified": 1792513666,
"narHash": "sha256-RDqPdPrM5lnwRrfFGLz3IwgTjCV2Ie+nrTD3ldj1t/s=",
"lastModified": 1792694928,
"narHash": "sha256-jb+Ns8c4kw2a9z9bes/9D+fWhG8pmD8NVurFbRMk7G4=",
"owner": "duxlabs-dev",
"repo": "dux-qml-common",
"rev": "ebf5e6c002da1bdaa4aaa2f319fea7b8507abc42",
"rev": "802b4b127b482d85921e464ccc7cd629294b47e3",
"type": "github"
},
"original": {
@@ -77,11 +77,11 @@
"dank-qml-common_3": {
"flake": false,
"locked": {
"lastModified": 1792513666,
"narHash": "sha256-RDqPdPrM5lnwRrfFGLz3IwgTjCV2Ie+nrTD3ldj1t/s=",
"lastModified": 1792696287,
"narHash": "sha256-htrNweCLuw+3TQA2Vm7b4ETCuypIx85Vb3jt6k/DdBw=",
"owner": "duxlabs-dev",
"repo": "dux-qml-common",
"rev": "ebf5e6c002da1bdaa4aaa2f319fea7b8507abc42",
"rev": "abd63f1d329cbffd33ad0d28420944353bbf50ed",
"type": "github"
},
"original": {
@@ -98,11 +98,11 @@
]
},
"locked": {
"lastModified": 1792544049,
"narHash": "sha256-gEJU03lX5rNNjo8rsmIgrrJfrT8Jgi3GdUnLGlAZKRs=",
"lastModified": 1792695118,
"narHash": "sha256-Dx4Jt9kSBiKFsH2mmDPIIhaOe2Ku1pVeIhHHbnh4Cxk=",
"owner": "AvengeMedia",
"repo": "dankcalendar",
"rev": "734d20af76c9f2cdf751086456ad43535777c3f8",
"rev": "e7123fc6583877637fe94eb3436c3f09cb90b466",
"type": "github"
},
"original": {
@@ -118,11 +118,11 @@
]
},
"locked": {
"lastModified": 1792524211,
"narHash": "sha256-GOnNob/tex//NBchfVXAjzk9Gw4K+GxyVmZBZqx0nLA=",
"lastModified": 1792684013,
"narHash": "sha256-JRiqnNHPyXhZiR/RuFksCrX0768S+PVsSOmux6a2lYU=",
"owner": "AvengeMedia",
"repo": "danksearch",
"rev": "9f706cad94f23dd2fd8642a2c06796fa0786e60d",
"rev": "646b0e046f4c806de9501892b9c38fd11612092e",
"type": "github"
},
"original": {
@@ -138,11 +138,11 @@
]
},
"locked": {
"lastModified": 1792524211,
"narHash": "sha256-GTDomQTBU132DVjqX/o3cZBo9ylUWLvUJ74PSlahgTo=",
"lastModified": 1792684000,
"narHash": "sha256-b2Wn6ySG7aqvi/6hF1t+DWpQzg0qA9rixrKIGe9IQ+Q=",
"owner": "AvengeMedia",
"repo": "dgop",
"rev": "43a29526bb651c372c3291eb62c3e0cec3bca6e0",
"rev": "c1dbfaf3d2fab4fb602ef564da9462d3a1482712",
"type": "github"
},
"original": {
@@ -160,11 +160,11 @@
]
},
"locked": {
"lastModified": 1792584169,
"narHash": "sha256-Q7gbbFGwhYzhXgfXeIolmDISNBIWwKkP9ww0yJQVAqA=",
"lastModified": 1792734127,
"narHash": "sha256-iX1jdtofZqrPZ1zKmjTQXlHkNN4g7CiGCnh2dplHHv4=",
"owner": "AvengeMedia",
"repo": "DankMaterialShell",
"rev": "b81954454a7c6a53ffa6d49d65906aa65694eef1",
"rev": "c7692f830c556e1c3a5bbec594ec83acc57bf903",
"type": "github"
},
"original": {
@@ -214,11 +214,11 @@
]
},
"locked": {
"lastModified": 1792495086,
"narHash": "sha256-TyoYH983Nsc++1scw0SoOEKshPSJWJDxK7tTmuZ974M=",
"lastModified": 1792703141,
"narHash": "sha256-3X34FaSeMJXMx8CK/BN6sZ9knwNauuiJXQhLM+bQQuI=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "ec80131710bffcdf3b8498cf41f3a0579833b023",
"rev": "6750249c69969d09d952efaf3fab88a2bdac7ec6",
"type": "github"
},
"original": {
@@ -314,11 +314,11 @@
]
},
"locked": {
"lastModified": 1792522695,
"narHash": "sha256-jTLo+OAKTDjIOEv2YA8xKTkqp1zZ+ZwXjztgXj6E7bk=",
"lastModified": 1792595242,
"narHash": "sha256-kH/E0uJDslOgYcnmU+c0cm6HrUjsEtvZQKZtuQ1+uvo=",
"owner": "0xc000022070",
"repo": "zen-browser-flake",
"rev": "bb286c34998a498df925c7a7b4d69aea8c44931c",
"rev": "f19490ac889eabb05bdb7e8dcb85225ee75bd87b",
"type": "github"
},
"original": {
+177
View File
@@ -0,0 +1,177 @@
#!/usr/bin/env bash
# 🎙️ Whisper Audio Message Transcriber
# Fast, local, offline audio transcription using whisper-cpp and ffmpeg.
# Optimised for voice messages (.ogg, .opus, .m4a, .mp3, .wav).
set -euo pipefail
show_help() {
cat << 'EOF'
Usage: transcribe [OPTIONS] <audio-file> [audio-file2 ...]
Transcribes audio recordings into plain text using local whisper.cpp.
Options:
-c, --clip, --clipboard Copy transcription result to Wayland clipboard (wl-copy)
-s, --save Save transcript alongside audio file as <filename>.txt
-m, --model <name> Whisper model size (default: small, ~488MB)
Options: tiny, base, small, medium, large-v3-turbo
-l, --lang <code|auto> Spoken language (e.g. en, es, auto; default: auto)
-t, --threads <num> Computation threads (default: CPU core count)
-q, --quiet Suppress informational messages to stderr
-h, --help Show this help message and exit
Examples:
transcribe voice_note.ogg
transcribe -c memo.m4a
transcribe -s -l es recording.opus
EOF
}
MODEL="${TRANSCRIBE_MODEL:-small}"
LANG="${TRANSCRIBE_LANG:-auto}"
CLIP=0
SAVE=0
QUIET=0
THREADS="$(nproc 2>/dev/null || echo 4)"
# Parse CLI options
while [ $# -gt 0 ]; do
case "$1" in
-c|--clip|--clipboard)
CLIP=1
shift
;;
-s|--save)
SAVE=1
shift
;;
-m|--model)
if [ $# -lt 2 ]; then
echo "Error: --model requires an argument" >&2
exit 1
fi
MODEL="$2"
shift 2
;;
-l|--lang|--language)
if [ $# -lt 2 ]; then
echo "Error: --language requires an argument" >&2
exit 1
fi
LANG="$2"
shift 2
;;
-t|--threads)
if [ $# -lt 2 ]; then
echo "Error: --threads requires an argument" >&2
exit 1
fi
THREADS="$2"
shift 2
;;
-q|--quiet)
QUIET=1
shift
;;
-h|--help)
show_help
exit 0
;;
--)
shift
break
;;
-*)
echo "Unknown option: $1" >&2
show_help
exit 1
;;
*)
break
;;
esac
done
if [ $# -lt 1 ]; then
echo "Error: No audio files provided." >&2
show_help
exit 1
fi
MODEL_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/whisper-cpp/models"
MODEL_FILE="$MODEL_DIR/ggml-${MODEL}.bin"
# Auto-download model on first run if missing
if [ ! -f "$MODEL_FILE" ]; then
if [ "$QUIET" -eq 0 ]; then
echo "Model 'ggml-${MODEL}.bin' not found in $MODEL_DIR." >&2
echo "Downloading model '${MODEL}'..." >&2
fi
mkdir -p "$MODEL_DIR"
whisper-cpp-download-ggml-model "$MODEL" "$MODEL_DIR"
fi
# Set up temporary working directory for 16kHz audio normalization
TEMP_DIR="$(mktemp -d -t transcribe-XXXXXX)"
cleanup() {
rm -rf "$TEMP_DIR"
}
trap cleanup EXIT INT TERM
ALL_OUTPUT=""
for input_file in "$@"; do
if [ ! -f "$input_file" ]; then
echo "Warning: File '$input_file' not found, skipping." >&2
continue
fi
TEMP_WAV="$TEMP_DIR/converted_$(basename "$input_file").wav"
# Normalize audio to 16kHz mono 16-bit PCM WAV (Whisper specification)
if ! ffmpeg -hide_banner -loglevel error -y -i "$input_file" -ar 16000 -ac 1 -c:a pcm_s16le "$TEMP_WAV"; then
echo "Error: Failed to process audio file '$input_file' with ffmpeg." >&2
continue
fi
# Run whisper-cli
RAW_TRANSCRIPT="$(whisper-cli -m "$MODEL_FILE" -f "$TEMP_WAV" -l "$LANG" -t "$THREADS" -nt -np)"
# Clean transcript: strip leading whitespace from segments
CLEAN_TRANSCRIPT="$(echo "$RAW_TRANSCRIPT" | sed -e 's/^[[:space:]]*//' | sed -e '/^[[:space:]]*$/d')"
# Print to stdout
printf "%s\n" "$CLEAN_TRANSCRIPT"
# Optional: Save next to original audio file
if [ "$SAVE" -eq 1 ]; then
OUT_TXT="${input_file%.*}.txt"
printf "%s\n" "$CLEAN_TRANSCRIPT" > "$OUT_TXT"
if [ "$QUIET" -eq 0 ]; then
echo "Saved transcript to: $OUT_TXT" >&2
fi
fi
if [ -n "$ALL_OUTPUT" ]; then
ALL_OUTPUT="${ALL_OUTPUT}
${CLEAN_TRANSCRIPT}"
else
ALL_OUTPUT="$CLEAN_TRANSCRIPT"
fi
rm -f "$TEMP_WAV"
done
# Optional: Copy accumulated transcript to clipboard
if [ "$CLIP" -eq 1 ] && [ -n "$ALL_OUTPUT" ]; then
if command -v wl-copy >/dev/null 2>&1; then
printf "%s\n" "$ALL_OUTPUT" | wl-copy
if [ "$QUIET" -eq 0 ]; then
echo "Copied transcript to clipboard." >&2
fi
else
echo "Warning: wl-copy not found, skipping clipboard copy." >&2
fi
fi
+17
View File
@@ -29,11 +29,28 @@ let
chmod +x $out/bin/new-repo
patchShebangs $out/bin/new-repo
'';
# Hermetic packaging for local audio transcription via whisper-cpp
transcribeCli = pkgs.writeShellApplication {
name = "transcribe";
runtimeInputs = with pkgs; [
bash
coreutils
gnused
gnugrep
ffmpeg-headless
whisper-cpp
wl-clipboard
curl
];
text = builtins.readFile ./scripts/transcribe.sh;
};
in
{
home.packages = [
tmuxSessionizer
newRepo
transcribeCli
];
programs = {