From 5b1a76c9449c1885c793c7f1f816c99db0d155ae Mon Sep 17 00:00:00 2001 From: zvezdochiot Date: Sun, 24 May 2020 00:08:39 +0300 Subject: [PATCH] 0.20200523: fixed dev (stdin/stdout) --- CHANGELOG | 6 ++++++ VERSION | 2 +- rhvoiceplay.sh | 25 ++++++++++++++----------- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ae37935..8ca68b2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,9 @@ +https://github.com/BASH-Auto-Tools/rhvoicebookreader + +0.20200523 + + Fixed dev (stdin/stdout). + 0.20190922 Fixed pipe. diff --git a/VERSION b/VERSION index e011426..7882814 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.20190922 +0.20200523 diff --git a/rhvoiceplay.sh b/rhvoiceplay.sh index d3f701e..4cb2ae3 100755 --- a/rhvoiceplay.sh +++ b/rhvoiceplay.sh @@ -3,21 +3,21 @@ #Depends: bash, sed, gzip, rhvoice, aplay | sox sname="RHVoicePlay" -sversion="0.20190921" +sversion="0.20200523" echo "$sname $sversion" >&2 tnocomp="" tcomp="sed" -[ ! "$(command -v $tcomp)" ] && tnocomp="$tnocomp $tcomp" +[ ! "$(which $tcomp)" ] && tnocomp="$tnocomp $tcomp" tcomp="gzip" -[ ! "$(command -v $tcomp)" ] && tnocomp="$tnocomp $tcomp" +[ ! "$(which $tcomp)" ] && tnocomp="$tnocomp $tcomp" tcomp="RHVoice" tcompa="RHVoice-test" -[ ! "$(command -v $tcomp)" -a ! "$(command -v $tcompa)" ] && tnocomp="$tnocomp $tcomp|$tcompa" +[ ! "$(which $tcomp)" -a ! "$(which $tcompa)" ] && tnocomp="$tnocomp $tcomp|$tcompa" tcomp="aplay" tcompa="play" -[ ! "$(command -v $tcomp)" -a ! "$(command -v $tcompa)" ] && tnocomp="$tnocomp $tcomp|$tcompa" +[ ! "$(which $tcomp)" -a ! "$(which $tcompa)" ] && tnocomp="$tnocomp $tcomp|$tcompa" if [ "x$tnocomp" != "x" ] then echo "Not found:${tnocomp}!" >&2 @@ -25,6 +25,9 @@ then exit 1 fi +tstdout="/dev/stdout" +tstdin="/dev/stdin" + tln=0 tspeaker="elena" fhlp="false" @@ -57,9 +60,9 @@ then fi trhvoice="RHVoice" -[ ! "$(command -v $trhvoice)" ] && trhvoice="RHVoice-test -p $tspeaker -o -" -tplay="aplay" -[ ! "$(command -v $tplay)" ] && tplay="play -q" +[ ! "$(which $trhvoice)" ] && trhvoice="RHVoice-test -p $tspeaker -o $tstdout" +tplay="aplay $tstdin" +[ ! "$(which $tplay)" ] && tplay="play -q $tstdin" if [ -f "$text" ] then @@ -67,11 +70,11 @@ then echo "$text: $textsize" >&2 tln=$(($tln*$textsize/1000)) i=$tln - gzip -dcf "$text" | sed -e 's/[\.\?\!\…] /&\n/g' | sed -e '/^$/d' | sed -e "1,${tln}d" | while read tline; do p=$((10000*$i/$textsize)); p1=$(($p/10)); p2=$(($p-$p1*10)); printf "%03d.%01d: " $p1 $p2; echo "$tline"; echo "$tline" | $trhvoice 2>/dev/null | $tplay - 2>/dev/null; i=$(($i+1)); done + gzip -dcf "$text" | sed -e 's/[\.\?\!\…] /&\n/g' | sed -e '/^$/d' | sed -e "1,${tln}d" | while read tline; do p=$((10000*$i/$textsize)); p1=$(($p/10)); p2=$(($p-$p1*10)); printf "%03d.%01d: " $p1 $p2; echo "$tline"; echo "$tline" | $trhvoice 2>/dev/null | $tplay 2>/dev/null; i=$(($i+1)); done elif [ "x$text" = "x-" ] then - while read tline; do printf ": "; echo "$tline"; echo "$tline" | $trhvoice 2>/dev/null | $tplay - 2>/dev/null; done + while read tline; do printf ": "; echo "$tline"; echo "$tline" | $trhvoice 2>/dev/null | $tplay 2>/dev/null; done else echo "$text" - echo "$text" | $trhvoice 2>/dev/null | $tplay - 2>/dev/null + echo "$text" | $trhvoice 2>/dev/null | $tplay 2>/dev/null fi