feat: add auto-language detection support to stt-ptt

- Add STT_LANGUAGE environment variable (default: auto)
- Modify whisper-cli call to use -l flag with language code
- Add language option to HM module (enum with 23 common languages + auto)
- Update help text to document STT_LANGUAGE variable
This commit is contained in:
m3tm3re
2026-01-10 09:36:21 +01:00
parent 3933e380c6
commit 9f284a8c21
3 changed files with 55 additions and 2 deletions

View File

@@ -19,6 +19,7 @@
# Configurable via environment
STT_MODEL="''${STT_MODEL:-$MODEL_DIR/ggml-large-v3-turbo.bin}"
STT_LANGUAGE="''${STT_LANGUAGE:-auto}"
STT_NOTIFY_TIMEOUT="''${STT_NOTIFY_TIMEOUT:-3000}"
NOTIFY="${libnotify}/bin/notify-send"
@@ -52,7 +53,7 @@
"$RM" -f "$AUDIO"
exit 1
fi
text=$("$WHISPER" -m "$STT_MODEL" -f "$AUDIO" -np -nt 2>/dev/null | "$TR" -d '\n' | "$SED" 's/^[[:space:]]*//;s/[[:space:]]*$//')
text=$("$WHISPER" -m "$STT_MODEL" -f "$AUDIO" -l "$STT_LANGUAGE" -np -nt 2>/dev/null | "$TR" -d '\n' | "$SED" 's/^[[:space:]]*//;s/[[:space:]]*$//')
"$RM" -f "$AUDIO"
[[ -n "$text" ]] && "$WTYPE" -- "$text"
fi
@@ -62,6 +63,7 @@
echo ""
echo "Environment variables:"
echo " STT_MODEL - Path to whisper model (default: \$XDG_DATA_HOME/stt-ptt/models/ggml-large-v3-turbo.bin)"
echo " STT_LANGUAGE - Language code or 'auto' for auto-detection (default: auto)"
echo " STT_NOTIFY_TIMEOUT - Notification timeout in ms (default: 3000)"
exit 1
;;