From 8a9c0fb416d662a5b4141852bd07dda933f3038c Mon Sep 17 00:00:00 2001 From: mnasell Date: Sat, 19 Jul 2025 12:03:01 +0200 Subject: [PATCH] support intl by adding language selection --- scripts/termux-speech-to-text.in | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/termux-speech-to-text.in b/scripts/termux-speech-to-text.in index 4bc7fd0..88e8b42 100644 --- a/scripts/termux-speech-to-text.in +++ b/scripts/termux-speech-to-text.in @@ -3,17 +3,22 @@ set -e -u SCRIPTNAME=termux-speech-to-text show_usage () { - echo "Usage: $SCRIPTNAME" + echo "Usage: $SCRIPTNAME [-l ]" echo "Converts speech to text, sending partial matches to stdout." + echo "-l: specify other language code. ie -l de-DE" exit 0 } +PARAMS="" + show_progress=false -while getopts :hp option +while getopts :hl:p option do case "$option" in h) show_usage;; p) show_progress=true;; + # default language en_US handled in SpeechToTextAPI + l) PARAMS="--es language $OPTARG";; ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1; esac done @@ -23,7 +28,7 @@ if [ $# != 0 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi CMD=@TERMUX_PREFIX@/libexec/termux-api if [ $show_progress = true ]; then - $CMD SpeechToText + $CMD SpeechToText $PARAMS else - $CMD SpeechToText | tail -1 + $CMD SpeechToText $PARAMS | tail -1 fi