Skip to content

Commit 5b1a76c

Browse files
committed
0.20200523: fixed dev (stdin/stdout)
1 parent fca924e commit 5b1a76c

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

CHANGELOG

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
https://github.com/BASH-Auto-Tools/rhvoicebookreader
2+
3+
0.20200523
4+
5+
Fixed dev (stdin/stdout).
6+
17
0.20190922
28

39
Fixed pipe.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.20190922
1+
0.20200523

rhvoiceplay.sh

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,31 @@
33
#Depends: bash, sed, gzip, rhvoice, aplay | sox
44

55
sname="RHVoicePlay"
6-
sversion="0.20190921"
6+
sversion="0.20200523"
77

88
echo "$sname $sversion" >&2
99

1010
tnocomp=""
1111
tcomp="sed"
12-
[ ! "$(command -v $tcomp)" ] && tnocomp="$tnocomp $tcomp"
12+
[ ! "$(which $tcomp)" ] && tnocomp="$tnocomp $tcomp"
1313
tcomp="gzip"
14-
[ ! "$(command -v $tcomp)" ] && tnocomp="$tnocomp $tcomp"
14+
[ ! "$(which $tcomp)" ] && tnocomp="$tnocomp $tcomp"
1515
tcomp="RHVoice"
1616
tcompa="RHVoice-test"
17-
[ ! "$(command -v $tcomp)" -a ! "$(command -v $tcompa)" ] && tnocomp="$tnocomp $tcomp|$tcompa"
17+
[ ! "$(which $tcomp)" -a ! "$(which $tcompa)" ] && tnocomp="$tnocomp $tcomp|$tcompa"
1818
tcomp="aplay"
1919
tcompa="play"
20-
[ ! "$(command -v $tcomp)" -a ! "$(command -v $tcompa)" ] && tnocomp="$tnocomp $tcomp|$tcompa"
20+
[ ! "$(which $tcomp)" -a ! "$(which $tcompa)" ] && tnocomp="$tnocomp $tcomp|$tcompa"
2121
if [ "x$tnocomp" != "x" ]
2222
then
2323
echo "Not found:${tnocomp}!" >&2
2424
echo "" >&2
2525
exit 1
2626
fi
2727

28+
tstdout="/dev/stdout"
29+
tstdin="/dev/stdin"
30+
2831
tln=0
2932
tspeaker="elena"
3033
fhlp="false"
@@ -57,21 +60,21 @@ then
5760
fi
5861

5962
trhvoice="RHVoice"
60-
[ ! "$(command -v $trhvoice)" ] && trhvoice="RHVoice-test -p $tspeaker -o -"
61-
tplay="aplay"
62-
[ ! "$(command -v $tplay)" ] && tplay="play -q"
63+
[ ! "$(which $trhvoice)" ] && trhvoice="RHVoice-test -p $tspeaker -o $tstdout"
64+
tplay="aplay $tstdin"
65+
[ ! "$(which $tplay)" ] && tplay="play -q $tstdin"
6366

6467
if [ -f "$text" ]
6568
then
6669
textsize=$(gzip -dcf "$text" | sed -e 's/[\.\?\!\…] /&\n/g' | sed -e '/^$/d' | wc -l)
6770
echo "$text: $textsize" >&2
6871
tln=$(($tln*$textsize/1000))
6972
i=$tln
70-
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
73+
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
7174
elif [ "x$text" = "x-" ]
7275
then
73-
while read tline; do printf ": "; echo "$tline"; echo "$tline" | $trhvoice 2>/dev/null | $tplay - 2>/dev/null; done
76+
while read tline; do printf ": "; echo "$tline"; echo "$tline" | $trhvoice 2>/dev/null | $tplay 2>/dev/null; done
7477
else
7578
echo "$text"
76-
echo "$text" | $trhvoice 2>/dev/null | $tplay - 2>/dev/null
79+
echo "$text" | $trhvoice 2>/dev/null | $tplay 2>/dev/null
7780
fi

0 commit comments

Comments
 (0)