From a22e5a859aec8e92ec5e5eb735ec094e6f883425 Mon Sep 17 00:00:00 2001 From: boyska Date: Sun, 9 Aug 2015 16:07:06 +0200 Subject: [PATCH 1/4] espeak support --- mannaggia.sh | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/mannaggia.sh b/mannaggia.sh index 83afd20..bf184cd 100755 --- a/mannaggia.sh +++ b/mannaggia.sh @@ -22,6 +22,7 @@ # --shutdown : se nds > 0 e si e` root al termine delle invocazioni spegne # --off : se si e` root invoca un solo santo e spegne (equivale a --nds 1 --shutdown) audioflag=false +audiogoogle=true spm=1 spmflag=false nds=-1 @@ -43,6 +44,23 @@ if [ $(uname) = "Darwin" ] shufCmd=shuf fi +espeak_best_voice() { + v=$(espeak --voices=it | tail -n +2 | awk '{ print $4 }' | grep -v mbrola | head -n1) + if [ -n "$v" ]; then + # shellcheck disable=SC2039 + echo "-v $v -k10 -g1 -p 30" + return + fi + v=$(espeak --voices=it | tail -n +2 | awk '{ print $4 }' | head -n1) + if [ -n "$v" ]; then + # shellcheck disable=SC2039 + echo "-v $v" + return + fi + echo " " +} +ESPEAK="espeak $(espeak_best_voice)" + # lettura parametri da riga comando for parm in "$@" do @@ -56,6 +74,12 @@ for parm in "$@" } audioflag=true fi + if [ "$parm" = "--google" ] then + audiogoogle=true + fi + if [ "$parm" = "--espeak" ] then + audiogoogle=false + fi # leggi dai parametri se c'e' da mandare i commenti su wall if [ "$parm" = "--wall" ] @@ -141,7 +165,12 @@ while [ "$nds" != 0 ] if [ "$audioflag" = true ] then - $PLAYER "$MANNAGGIAURL" 2>/dev/null + if [ "$audiogoogle" = true ] + then + $PLAYER "$MANNAGGIAURL" 2>/dev/null + else + $ESPEAK "$MANNAGGIA" 2> /dev/null + fi fi sleep "$spm" From bb165dc64348e0a19efefc3656cb9ff3a41cb7a5 Mon Sep 17 00:00:00 2001 From: boyska Date: Sun, 9 Aug 2015 16:11:15 +0200 Subject: [PATCH 2/4] audio part refactoring --- mannaggia.sh | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/mannaggia.sh b/mannaggia.sh index bf184cd..8f5b958 100755 --- a/mannaggia.sh +++ b/mannaggia.sh @@ -61,6 +61,20 @@ espeak_best_voice() { } ESPEAK="espeak $(espeak_best_voice)" +vocalizza() { + if [ "$audioflag" = true ] + then + if [ "$audiogoogle" = true ] + then + MANNAGGIAURL="http://www.ispeech.org/p/generic/getaudio?text=$1%2C&voice=euritalianmale&speed=0&action=convert" + + $PLAYER "$MANNAGGIAURL" 2>/dev/null + else + $ESPEAK "$1" 2> /dev/null + fi + fi +} + # lettura parametri da riga comando for parm in "$@" do @@ -74,10 +88,10 @@ for parm in "$@" } audioflag=true fi - if [ "$parm" = "--google" ] then + if [ "$parm" = "--google" ]; then audiogoogle=true fi - if [ "$parm" = "--espeak" ] then + if [ "$parm" = "--espeak" ]; then audiogoogle=false fi @@ -147,7 +161,6 @@ while [ "$nds" != 0 ] do # shellcheck disable=SC2019 MANNAGGIA="Mannaggia $(curl -s "www.santiebeati.it/$(' -f 4-9|$shufCmd -n1 |awk -F "$DELSTRING1" '{print$1$2}'|awk -F "$DELSTRING2" '{print$1}' | iconv -f ISO-8859-1)" - MANNAGGIAURL="http://www.ispeech.org/p/generic/getaudio?text=$MANNAGGIA%2C&voice=euritalianmale&speed=0&action=convert" if [ "$wallflag" = true ] then @@ -163,16 +176,7 @@ while [ "$nds" != 0 ] echo "$MANNAGGIA" > /dev/stdout fi - if [ "$audioflag" = true ] - then - if [ "$audiogoogle" = true ] - then - $PLAYER "$MANNAGGIAURL" 2>/dev/null - else - $ESPEAK "$MANNAGGIA" 2> /dev/null - fi - fi - + vocalizza "$MANNAGGIA" sleep "$spm" nds=$((nds - 1)) done From 228d5baba2e871215a80d44819bd3e9342801df7 Mon Sep 17 00:00:00 2001 From: boyska Date: Mon, 6 Feb 2017 13:05:52 +0100 Subject: [PATCH 3/4] fix whitespace --- mannaggia.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mannaggia.sh b/mannaggia.sh index 8f5b958..5345812 100755 --- a/mannaggia.sh +++ b/mannaggia.sh @@ -88,10 +88,10 @@ for parm in "$@" } audioflag=true fi - if [ "$parm" = "--google" ]; then + if [ "$parm" = "--google" ]; then audiogoogle=true fi - if [ "$parm" = "--espeak" ]; then + if [ "$parm" = "--espeak" ]; then audiogoogle=false fi From e57c5603ccfa1f9e725e4a4d6fb4f413b164aef2 Mon Sep 17 00:00:00 2001 From: boyska Date: Mon, 6 Feb 2017 13:31:39 +0100 Subject: [PATCH 4/4] More backends, better espeak support --- mannaggia.sh | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/mannaggia.sh b/mannaggia.sh index 5345812..e5b55e5 100755 --- a/mannaggia.sh +++ b/mannaggia.sh @@ -21,8 +21,7 @@ # --nds : numero di santi da invocare (di default continua all'infinito) # --shutdown : se nds > 0 e si e` root al termine delle invocazioni spegne # --off : se si e` root invoca un solo santo e spegne (equivale a --nds 1 --shutdown) -audioflag=false -audiogoogle=true +audiosrc=espeak spm=1 spmflag=false nds=-1 @@ -64,13 +63,22 @@ ESPEAK="espeak $(espeak_best_voice)" vocalizza() { if [ "$audioflag" = true ] then - if [ "$audiogoogle" = true ] + if [ "$audiosrc" = espeak ] then - MANNAGGIAURL="http://www.ispeech.org/p/generic/getaudio?text=$1%2C&voice=euritalianmale&speed=0&action=convert" + tmpwav=$(mktemp mannaggia-XXXXXXXX.wav) + trap 'rm -f "$tmpwav"' EXIT + $ESPEAK "$1" --stdout > "$tmpwav" 2> /dev/null + $PLAYER "$tmpwav" + rm -f "$tmpwav" + else + if [ "$audiosrc" = ispeech ] + then + MANNAGGIAURL="http://www.ispeech.org/p/generic/getaudio?text=$1%2C&voice=euritalianmale&speed=0&action=convert" + else + MANNAGGIAURL="http://translate.google.com/translate_tts?tl=it&q=$1" + fi $PLAYER "$MANNAGGIAURL" 2>/dev/null - else - $ESPEAK "$1" 2> /dev/null fi fi } @@ -89,10 +97,13 @@ for parm in "$@" audioflag=true fi if [ "$parm" = "--google" ]; then - audiogoogle=true + audiosrc=google fi if [ "$parm" = "--espeak" ]; then - audiogoogle=false + audiosrc=espeak + fi + if [ "$parm" = "--ispeech" ]; then + audiosrc=ispeech fi # leggi dai parametri se c'e' da mandare i commenti su wall