Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextToSpeech: list voices & select voice to use #159

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions scripts/termux-tts-speak.in
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand All @@ -24,14 +26,15 @@ 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;;
e) PARAMS="$PARAMS --es engine $OPTARG";;
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";;
Expand Down
26 changes: 26 additions & 0 deletions scripts/termux-tts-voices.in
Original file line number Diff line number Diff line change
@@ -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