diff options
author | tdro <tdro@users.noreply.github.com> | 2025-04-06 00:00:00 +0000 |
---|---|---|
committer | tdro <tdro@users.noreply.github.com> | 2025-04-06 00:00:00 +0000 |
commit | 9d94c4c30acc197d1e36ccd048358d5a2debfdff (patch) | |
tree | 136a977b136498afe4c98a2779a683c249828697 | |
parent | b0d214818c7b78fe880f4bf301cbeffc6048c630 (diff) | |
download | dotfiles-9d94c4c30acc197d1e36ccd048358d5a2debfdff.tar.gz dotfiles-9d94c4c30acc197d1e36ccd048358d5a2debfdff.tar.bz2 dotfiles-9d94c4c30acc197d1e36ccd048358d5a2debfdff.zip |
.local/bin/say: Add basic piping
-rwxr-xr-x | .local/bin/say | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/.local/bin/say b/.local/bin/say index 2e9426a..9c278dd 100755 --- a/.local/bin/say +++ b/.local/bin/say @@ -5,7 +5,7 @@ voices=$HOME/.local/share/piper/voices identifier=jfgOUcZdWu audio=/tmp/say-$identifier.wav -default=${1:-Nothing to say.} +message=${1:-Nothing to say.} trap 'rm $audio $audio.mp3 > /dev/null 2>&1 || true; trap - EXIT; exit' EXIT INT HUP @@ -17,8 +17,13 @@ Usage: %s [FLAGS]... [ARGUMENT]... The program $program shall use TTS (Text to Speech) to convert a given text input into speech. +Voices: $voices + Command List: + printf 'text' | $program - Read piped text. + $program - < ./file Read contents of file. + $program 'text' Say given text. $program echo 'text' Say given text with echo effect. $program check Checks dependencies. @@ -43,7 +48,7 @@ Say() { Piper() { [ ! -e "$voices/en_GB-jenny_dioco-medium.onnx" ] && Download - printf '%s' "$default" | + printf '%s' "$message" | piper \ --model "$voices/en_GB-jenny_dioco-medium.onnx" \ --output_file $audio > /dev/null 2>&1 @@ -63,6 +68,8 @@ Download() { { [ "${1:-}" = "-h" ] || [ "${1:-}" = "-help" ]|| [ "${1:-}" = "--help" ] || [ "$#" = 0 ]; } && Help && Say && exit +[ "${1:-}" = "-" ] && message=$(cat -) Say && exit + [ "${1:-}" = "help" ] && Help && Say && exit [ "${1:-}" = "check" ] && Check && exit |