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: synthesize speech to .wav file #160

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 14 additions & 2 deletions scripts/termux-tts-speak.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ 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] [-p pitch] [-r rate] [-s stream] [-f <file>] [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)"
Expand All @@ -19,12 +19,15 @@ show_usage () {
echo " (2.0 is twice the normal speech rate)."
echo " -s stream audio stream to use (default:NOTIFICATION), one of:"
echo " ALARM, MUSIC, NOTIFICATION, RING, SYSTEM, VOICE_CALL"
echo " -f <file> synthesize speech to wav file,"
echo " only first line of text is synthesized (API limit),"
echo " overrides stream option"
exit 0
}

PARAMS=""

while getopts :he:l:n:v:p:r:s: option
while getopts :he:l:n:v:p:r:s:f: option
do
case "$option" in
h) show_usage;;
Expand All @@ -35,6 +38,15 @@ do
p) PARAMS="$PARAMS --ef pitch $OPTARG";;
r) PARAMS="$PARAMS --ef rate $OPTARG";;
s) PARAMS="$PARAMS --es stream $OPTARG";;
f)
if pathchk -pP "$OPTARG" 2> /dev/null; then
FILE=$(realpath "$OPTARG")
PARAMS="$PARAMS --es file $FILE" # still unsafe
else
echo "$SCRIPTNAME: non-portable filename";
exit 1
fi
;;
?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
esac
done
Expand Down