Skip to content

Commit

Permalink
0.20200523: fixed dev (stdin/stdout)
Browse files Browse the repository at this point in the history
  • Loading branch information
zvezdochiot committed May 23, 2020
1 parent fca924e commit 5b1a76c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
https://github.com/BASH-Auto-Tools/rhvoicebookreader

0.20200523

Fixed dev (stdin/stdout).

0.20190922

Fixed pipe.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.20190922
0.20200523
25 changes: 14 additions & 11 deletions rhvoiceplay.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,31 @@
#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
echo "" >&2
exit 1
fi

tstdout="/dev/stdout"
tstdin="/dev/stdin"

tln=0
tspeaker="elena"
fhlp="false"
Expand Down Expand Up @@ -57,21 +60,21 @@ 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
textsize=$(gzip -dcf "$text" | sed -e 's/[\.\?\!\…] /&\n/g' | sed -e '/^$/d' | wc -l)
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

0 comments on commit 5b1a76c

Please sign in to comment.