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