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:
@@ -20,7 +20,15 @@
|
|||||||
# ── Config ──────────────────────────────────────────────────────
|
# ── Config ──────────────────────────────────────────────────────
|
||||||
API_KEY="''${ELEVENLABS_API_KEY:?Set ELEVENLABS_API_KEY in your environment}"
|
API_KEY="''${ELEVENLABS_API_KEY:?Set ELEVENLABS_API_KEY in your environment}"
|
||||||
VOICE_ID="''${ELEVENLABS_VOICE_ID:-KXxZd16DiBqt82nbarJx}"
|
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"
|
AUDIO_FILE="/tmp/voice-notify-$$.mp3"
|
||||||
ACTION_FILE="/tmp/voice-action-$$"
|
ACTION_FILE="/tmp/voice-action-$$"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user