💾 Archived View for ait.place › dot › bin › .local › bin › say.txt captured on 2022-04-28 at 18:10:53.

View Raw

More Information

⬅️ Previous capture (2021-12-03)

-=-=-=-=-=-=-

#!/bin/sh
# say "text"
# https://cloud.google.com/translate/docs/languages

line="$@"

# Reads form stdin if - is first argument or empty
if [ -z "$line" ] || [ "$line" = "-" ] ; then
	# if stdin empty then exit
	[ -t 0 ] && echo "Usage: say <your sentence>" && exit 255
	line="$(cat /dev/stdin)"
	[ -z "$line" ] && exit 255
fi
send="$(echo "$line" | tr -d "&\"'" | sed 's/.\{100\}/&\n/g')"
echo $send
mpv --msg-level=all=no --force-window=no "https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl=en&q=$send"