Commit | Line | Data |
---|---|---|
cc1ae02e | 1 | #!/bin/sh |
3b43db5d | 2 | set -e -u |
59f0d218 | 3 | |
3b43db5d | 4 | SCRIPTNAME=termux-tts-speak |
59f0d218 | 5 | show_usage () { |
76f60643 | 6 | echo "Usage: $SCRIPTNAME [-e engine] [-l language] [-n region] [-v variant] [-p pitch] [-r rate] [-s stream] [text-to-speak]" |
bea93fbd FF |
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)" | |
76f60643 | 11 | echo " -n region region of language to speak in" |
12 | echo " -v variant variant of the language to speak in" | |
bea93fbd FF |
13 | echo " -p pitch pitch to use in speech. 1.0 is the normal pitch," |
14 | echo " lower values lower the tone of the synthesized voice," | |
15 | echo " greater values increase it." | |
16 | echo " -r rate speech rate to use. 1.0 is the normal speech rate," | |
17 | echo " lower values slow down the speech" | |
18 | echo " (0.5 is half the normal speech rate)" | |
19 | echo " while greater values accelerates it" | |
20 | echo " (2.0 is twice the normal speech rate)." | |
21 | echo " -s stream audio stream to use (default:NOTIFICATION), one of:" | |
22 | echo " ALARM, MUSIC, NOTIFICATION, RING, SYSTEM, VOICE_CALL" | |
23 | echo "" | |
24 | exit 0 | |
59f0d218 FF |
25 | } |
26 | ||
3b43db5d FF |
27 | PARAMS="" |
28 | ||
76f60643 | 29 | while getopts :he:l:n:v:p:r:s: option |
3b43db5d | 30 | do |
bea93fbd FF |
31 | case "$option" in |
32 | h) show_usage;; | |
33 | e) PARAMS="$PARAMS --es engine $OPTARG";; | |
34 | l) PARAMS="$PARAMS --es language $OPTARG";; | |
76f60643 | 35 | n) PARAMS="$PARAMS --es region $OPTARG";; |
36 | v) PARAMS="$PARAMS --es variant $OPTARG";; | |
bea93fbd FF |
37 | p) PARAMS="$PARAMS --ef pitch $OPTARG";; |
38 | r) PARAMS="$PARAMS --ef rate $OPTARG";; | |
39 | s) PARAMS="$PARAMS --es stream $OPTARG";; | |
40 | ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1; | |
41 | esac | |
59f0d218 | 42 | done |
3b43db5d FF |
43 | shift $(($OPTIND-1)) |
44 | ||
45 | CMD="@TERMUX_API@ TextToSpeech $PARAMS" | |
46 | if [ $# = 0 ]; then | |
bea93fbd | 47 | $CMD |
3b43db5d | 48 | else |
bea93fbd | 49 | echo $@ | $CMD |
3b43db5d | 50 | fi |
59f0d218 | 51 |