From 3c38f113b54427f17d9905cdf8b784e3534f7abd Mon Sep 17 00:00:00 2001 From: Menyadar <> Date: Sun, 25 Sep 2022 06:32:54 +0200 Subject: [PATCH] TextToSpeech: list voices & select voice to use selecting voice directly overrides language + region + variant --- CMakeLists.txt | 1 + scripts/termux-tts-speak.in | 7 +++++-- scripts/termux-tts-voices.in | 26 ++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 scripts/termux-tts-voices.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a10345..3e52b80 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,6 +60,7 @@ set(script_files scripts/termux-toast scripts/termux-torch scripts/termux-tts-engines + scripts/termux-tts-voices scripts/termux-tts-speak scripts/termux-usb scripts/termux-vibrate diff --git a/scripts/termux-tts-speak.in b/scripts/termux-tts-speak.in index bd95037..2507080 100644 --- a/scripts/termux-tts-speak.in +++ b/scripts/termux-tts-speak.in @@ -3,12 +3,14 @@ set -e -u SCRIPTNAME=termux-tts-speak show_usage () { - echo "Usage: $SCRIPTNAME [-e engine] [-l language] [-n region] [-v variant] [-p pitch] [-r rate] [-s stream] [text-to-speak]" + echo "Usage: $SCRIPTNAME [-e engine] [-l language] [-n region] [-v variant] [-i voice] [-p pitch] [-r rate] [-s stream] [text-to-speak]" 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." echo " -e engine TTS engine to use (see termux-tts-engines)" echo " -l language language to speak in (may be unsupported by the engine)" echo " -n region region of language to speak in" echo " -v variant variant of the language to speak in" + echo " -i voice voice to speak in (see termux-tts-voices)," + echo " overrides language, region and variant options." echo " -p pitch pitch to use in speech. 1.0 is the normal pitch," echo " lower values lower the tone of the synthesized voice," echo " greater values increase it." @@ -24,7 +26,7 @@ show_usage () { PARAMS="" -while getopts :he:l:n:v:p:r:s: option +while getopts :he:l:n:v:i:p:r:s: option do case "$option" in h) show_usage;; @@ -32,6 +34,7 @@ do l) PARAMS="$PARAMS --es language $OPTARG";; n) PARAMS="$PARAMS --es region $OPTARG";; v) PARAMS="$PARAMS --es variant $OPTARG";; + i) PARAMS="$PARAMS --es voice $OPTARG";; p) PARAMS="$PARAMS --ef pitch $OPTARG";; r) PARAMS="$PARAMS --ef rate $OPTARG";; s) PARAMS="$PARAMS --es stream $OPTARG";; diff --git a/scripts/termux-tts-voices.in b/scripts/termux-tts-voices.in new file mode 100644 index 0000000..de64468 --- /dev/null +++ b/scripts/termux-tts-voices.in @@ -0,0 +1,26 @@ +#!@TERMUX_PREFIX@/bin/sh +set -e -u + +SCRIPTNAME=termux-tts-voices +show_usage () { + echo "Usage: $SCRIPTNAME" + echo "Get information about the available text-to-speech (TTS) voices. The name of a voice may be given to the termux-tts-speak command using the -e option." + echo " -e engine TTS engine to use (see termux-tts-engines)" + exit 0 +} + +PARAMS="" + +while getopts :he: option +do + case "$option" in + h) show_usage;; + e) PARAMS="$PARAMS --es engine $OPTARG";; + ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1; + esac +done +shift $((OPTIND-1)) + +if [ $# != 0 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi + +@TERMUX_PREFIX@/libexec/termux-api TextToSpeech "$PARAMS" --es voice LIST_AVAILABLE