feat(talk): support stdin piping

Argument has priority, otherwise read from stdin when piped.
Enables: echo 'Build fertig' | talk
         nixos-rebuild build 2>&1 | tail -3 | talk
This commit is contained in:
2026-07-02 19:09:52 +02:00
parent b7ba13db9b
commit fa2f3dfbc6
+9 -1
View File
@@ -20,7 +20,15 @@
# Config
API_KEY="''${ELEVENLABS_API_KEY:?Set ELEVENLABS_API_KEY in your environment}"
VOICE_ID="''${ELEVENLABS_VOICE_ID:-KXxZd16DiBqt82nbarJx}"
TEXT="''${1:?Usage: talk \"Text zum Sprechen\"}"
# Argument hat Vorrang, sonst stdin lesen wenn Pipe
if [ $# -ge 1 ]; then
TEXT="$1"
elif [ ! -t 0 ]; then
TEXT=$(cat)
else
echo "Usage: talk \"Text\" oder echo Text | talk" >&2
exit 1
fi
AUDIO_FILE="/tmp/voice-notify-$$.mp3"
ACTION_FILE="/tmp/voice-action-$$"