#!/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 " && 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"