From aea9d07ae94d1dd666d596557788ae3c6c94e69f Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Wed, 11 Mar 2026 20:04:18 -0400 Subject: [PATCH] feat: voice to text --- config/nvim/lua/plugins/guard.lua | 2 ++ scripts/ctl | 15 +++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/config/nvim/lua/plugins/guard.lua b/config/nvim/lua/plugins/guard.lua index ce83b8a..a7f002f 100644 --- a/config/nvim/lua/plugins/guard.lua +++ b/config/nvim/lua/plugins/guard.lua @@ -43,6 +43,8 @@ return { ft('sh,bash'):lint('shellcheck') ft('zsh'):lint('zsh') + ft('html'):fmt('prettierd') + ft('proto'):fmt('buf'):lint('buf') ft('dockerfile'):lint('hadolint') ft('tex'):fmt('latexindent') diff --git a/scripts/ctl b/scripts/ctl index b4a3088..317902a 100755 --- a/scripts/ctl +++ b/scripts/ctl @@ -548,33 +548,32 @@ dictate) rm -f "$dpid" sleep 0.2 if [ ! -s "$daudio" ]; then - notify-send -a ctl "no audio" + notify-send -a ctl -t 1250 "no audio" exit 1 fi - notify-send -a ctl "transcribing..." + notify-send -a ctl -t 1250 "transcribing..." text=$(whisper-cli \ --model "$dmodel_file" \ --language "${DICTATE_LANG:-en}" \ --no-prints --no-timestamps \ - "$daudio" 2>/dev/null) + "$daudio" 2>/dev/null | tr '\n' ' ' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | tr -s ' ') rm -f "$daudio" - text=$(printf '%s' "$text" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | tr -s ' ') if [ -z "$text" ]; then - notify-send -a ctl "no speech detected" + notify-send -a ctl -t 1250 "no speech detected" exit 1 fi printf '%s' "$text" | wl-copy - notify-send -a ctl "$text" + notify-send -a ctl -t 1250 "$text" exit 0 fi if [ ! -f "$dmodel_file" ]; then - notify-send -a ctl "downloading whisper $dmodel model..." + notify-send -a ctl -t 1250 "downloading whisper $dmodel model..." mkdir -p "$dmodel_dir" curl -L -o "$dmodel_file" \ "https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-$dmodel.bin" fi - notify-send -a ctl "recording..." + notify-send -a ctl -t 1250 "recording..." pw-record "$daudio" & printf '%s' "$!" > "$dpid" ;;