I am trying to define a one-liner alias like the following:
alias speak='curl -G --data-urlencode "text=$(cat /dev/stdin)" "https://speech.botiumbox.com/api/tts/en?&tts=marytts" -H "accept: audio/wav" | mpv -'
such that I can use it like this
echo Hello World! | speak
speak Hello World!
speak<RET> # continuously do TTS per line until ^D
Hello World!
Another line!
<Ctrl-D>
The API I am using works if I use
curl -G --data-urlencode "text=Hello World!" "https://speech.botiumbox.com/api/tts/en?&tts=marytts" -H "accept: audio/wav" | mpv -
As demonstrated above, simply taking the standard input by cat /dev/stdin
didn't seem to create a interactive CLI program. Any ideas to wrap this API into an interactive CLI program? Ideally, be POSIX compliant so it can run in a bash
shell in Unixen.