final-space-tts/quote_final_space.sh

45 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env sh
set -eu
working_dir="$(dirname "$0")"
if [ ! -d "$working_dir/venv" ]; then
echo "preparing python virtualenv"
python3 -m venv --system-site-packages "$working_dir/venv" >/dev/null
echo "installing python pip requirements"
python3 -m pip install -U -r "$working_dir/requirements.txt" >/dev/null
fi
supported="KVN, HUE, AVA"
do_notify() { notify-send "$1 says:" "\"$2\"" ; }
if [ $# -eq 0 ]; then
echo "Requires an argument (must be one of $supported)" >&2
exit 1
fi
LINE="$(shuf -n 1 "$working_dir"/quotes.txt)"
case $1 in
[Aa][Vv][Aa])
# shellcheck disable=SC1091
. "$working_dir/venv/bin/activate"
gtts-cli -l 'en' -o '/tmp/ava.mp3' "$LINE"
do_notify "A.V.A" "$LINE" &
mpg321 --stereo >/dev/null 2>&1 '/tmp/ava.mp3'
;;
[Hh][Uu][Ee])
do_notify "H.U.E." "$LINE" &
espeak-ng -a 200 -p 55 -s 126 -v "en-us" "$LINE"
;;
[Kk][Vv][Nn])
do_notify "KVN" "$LINE" &
espeak-ng -a 200 -p 110 -s 160 -v "en-us" "$LINE"
;;
*)
echo "Invalid choice (must be one of $supported)" >&2
exit 1
;;
esac