script things

master
Bel LaPointe 2023-01-22 11:03:34 -07:00
parent 6705be3d43
commit 213aba51ed
2 changed files with 37 additions and 6 deletions

View File

@ -1,6 +1,36 @@
#! /bin/bash
for f in ./script.d/*.wav; do
read -p "enter to play <$f>"
afplay "$f"
done
proc_is_running() {
ps aux | grep -v grep | awk '{print $2}' | grep ^"$1"$ &> /dev/null
}
block_proc() {
local pid="$1"
local limit="${TIMEOUT:-100}"
deadline=$(($(date +%s) + limit))
while [ $(date +%s) -lt $deadline ] && proc_is_running "$pid"; do
sleep 1
done
kill -9 "$pid" &> /dev/null
}
main() {
cleanup() {
kill -9 $(jobs -p)
killall afplay mpv
}
trap cleanup EXIT
for f in ./script.d/*.wav; do
if [ "$#" != "0" ]; then
eval "$1"
else
read -p "enter to play <$f>"
fi
mpv --no-video "$f" &
export pid=${!}
block_proc $pid
done
}
main "$@"

View File

@ -1,10 +1,11 @@
#! /bin/bash
for f in ./script.d/*.txt; do
for f in ${@:-./script.d/*.txt}; do
echo $f...
curl \
-sS \
-X GET \
"http://localhost:15002/api/tts?voice=${1:-"en-us/glados-glow_tts"}&text=$(urlencode $(cat $f))" \
"http://localhost:15002/api/tts?voice=${VOICE:-"en-us/glados-glow_tts"}&text=$(urlencode $(cat $f))" \
> ${f%.*}.wav
echo $?
done