mosh: Fix /bin/sh -> $PREFIX/bin/sh in mosh.pl
[termux-packages] / packages / termux-api / termux-tts-speak
1 #!/bin/sh
2 set -e -u
3
4 SCRIPTNAME=termux-tts-speak
5 show_usage () {
6 echo "Usage: $SCRIPTNAME [-e engine] [-l language] [-p pitch] [-r rate] [-s stream] [text-to-speak]"
7 echo "Speak text with a system text-to-speech (TTS) engine. The text to speak is either supplied as arguments or read from stdin if no arguments are given."
8 echo ""
9 echo " -e engine TTS engine to use (see termux-tts-engines)"
10 echo " -l language language to speak in (may be unsupported by the engine)"
11 echo " -p pitch pitch to use in speech. 1.0 is the normal pitch,"
12 echo " lower values lower the tone of the synthesized voice,"
13 echo " greater values increase it."
14 echo " -r rate speech rate to use. 1.0 is the normal speech rate,"
15 echo " lower values slow down the speech"
16 echo " (0.5 is half the normal speech rate)"
17 echo " while greater values accelerates it"
18 echo " (2.0 is twice the normal speech rate)."
19 echo " -s stream audio stream to use (default:NOTIFICATION), one of:"
20 echo " ALARM, MUSIC, NOTIFICATION, RING, SYSTEM, VOICE_CALL"
21 echo ""
22 exit 0
23 }
24
25 PARAMS=""
26
27 while getopts :he:l:p:r:s: option
28 do
29 case "$option" in
30 h) show_usage;;
31 e) PARAMS="$PARAMS --es engine $OPTARG";;
32 l) PARAMS="$PARAMS --es language $OPTARG";;
33 p) PARAMS="$PARAMS --ef pitch $OPTARG";;
34 r) PARAMS="$PARAMS --ef rate $OPTARG";;
35 s) PARAMS="$PARAMS --es stream $OPTARG";;
36 ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
37 esac
38 done
39 shift $(($OPTIND-1))
40
41 CMD="@TERMUX_API@ TextToSpeech $PARAMS"
42 if [ $# = 0 ]; then
43 $CMD
44 else
45 echo $@ | $CMD
46 fi
47