| 1 | #!/bin/sh |
| 2 | |
| 3 | set -u |
| 4 | |
| 5 | PARAMS="" |
| 6 | |
| 7 | show_usage () { |
| 8 | echo "usage: termux-tts-speak [OPTIONS]" |
| 9 | echo "" |
| 10 | echo "Speak stdin input with a system text-to-speech (TTS) engine." |
| 11 | echo "Find out about available engines by executing 'termux-tts-engines'." |
| 12 | echo " -e, --engine <engine> TTS engine to use" |
| 13 | echo " -l, --language <language> language to speak in (may be unsupported by the engine)" |
| 14 | echo " -p, --pitch <pitch> pitch to use in speech" |
| 15 | echo " -r, --rate <rate> rate to use in speech" |
| 16 | } |
| 17 | |
| 18 | O=`busybox getopt -q -l engine: -l help -l language: -l pitch: -l rate: -- e:hl:p:r: "$@"` |
| 19 | if [ $? != 0 ] ; then show_usage; exit 1 ; fi |
| 20 | eval set -- "$O" |
| 21 | while true; do |
| 22 | case "$1" in |
| 23 | -e|--engine) PARAMS="$PARAMS --es engine $2"; shift 2;; |
| 24 | -l|--language) PARAMS="$PARAMS --es language $2"; shift 2;; |
| 25 | -p|--pitch) PARAMS="$PARAMS --ef pitch $2"; shift 2;; |
| 26 | -r|--rate) PARAMS="$PARAMS --ef rate $2"; shift 2;; |
| 27 | -h|--help) show_usage; exit 0;; |
| 28 | --) shift; break;; |
| 29 | *) echo Error; exit 1;; |
| 30 | esac |
| 31 | done |
| 32 | |
| 33 | @TERMUX_API@ TextToSpeech $PARAMS |