add pid check

This commit is contained in:
rany 2021-05-24 22:45:26 +03:00
parent e78279eb58
commit b0db6fb3ae

View File

@ -27,10 +27,13 @@ else
stdin=""
fi
edge-tts "${@}" >"$ttsmpeg" <<<"$stdin" &
edgePID=$!
## Wait until temporary file has some data so mpg123 doesn't exit immediately
## because it thinks file is empty and won't have any data.
while [ "$(wc -c <"$ttsmpeg")" == 0 ]
##
## kill -0 checks if PID is still running.
while [ "$(wc -c "$ttsmpeg")" == 0 ] || kill -0 "$edgePID" 2>/dev/null
do
sleep 0.1
done