Skip to content

Commit e31e688

Browse files
committed
audio part refactoring
1 parent 1ae6526 commit e31e688

1 file changed

Lines changed: 16 additions & 13 deletions

File tree

mannaggia.sh

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,19 @@ espeak_best_voice() {
4545
}
4646
ESPEAK="espeak $(espeak_best_voice)"
4747

48+
vocalizza() {
49+
if [ "$audioflag" = true ]
50+
then
51+
if [ "$audiogoogle" = true ]
52+
then
53+
MANNAGGIAURL="http://translate.google.com/translate_tts?tl=it&q=$1"
54+
$PLAYER "$MANNAGGIAURL" 2>/dev/null
55+
else
56+
$ESPEAK "$1" 2> /dev/null
57+
fi
58+
fi
59+
}
60+
4861
# lettura parametri da riga comando
4962
for parm in "$@"
5063
do
@@ -53,10 +66,10 @@ for parm in "$@"
5366
then
5467
audioflag=true
5568
fi
56-
if [ "$parm" = "--google" ] then
69+
if [ "$parm" = "--google" ]; then
5770
audiogoogle=true
5871
fi
59-
if [ "$parm" = "--espeak" ] then
72+
if [ "$parm" = "--espeak" ]; then
6073
audiogoogle=false
6174
fi
6275

@@ -107,7 +120,6 @@ while [ "$nds" != 0 ]
107120
do
108121
# shellcheck disable=SC2019
109122
MANNAGGIA="Mannaggia $(curl -s "www.santiebeati.it/$(</dev/urandom tr -dc A-Z|head -c1)/"|grep tit|cut -d'>' -f 4-9|shuf -n1 |awk -F "$DELSTRING1" '{print$1$2}'|awk -F "$DELSTRING2" '{print$1}')"
110-
MANNAGGIAURL="http://translate.google.com/translate_tts?tl=it&q=$MANNAGGIA"
111123

112124
if [ "$wallflag" = true ]
113125
then
@@ -123,16 +135,7 @@ while [ "$nds" != 0 ]
123135
echo "$MANNAGGIA" > /dev/stdout
124136
fi
125137

126-
if [ "$audioflag" = true ]
127-
then
128-
if [ "$audiogoogle" = true ]
129-
then
130-
$PLAYER "$MANNAGGIAURL" 2>/dev/null
131-
else
132-
$ESPEAK "$MANNAGGIA" 2> /dev/null
133-
fi
134-
fi
135-
138+
vocalizza "$MANNAGGIA"
136139
sleep "$spm"
137140
nds=$((nds - 1))
138141
done

0 commit comments

Comments
 (0)