-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathstateful_decoder.sh
executable file
·45 lines (39 loc) · 1.19 KB
/
stateful_decoder.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
#
# Some automation around stateful_decoder.sh to help with testing
OPUS=build/src
PATH=${PATH}:${OPUS}
if [ $# -lt 3 ]; then
echo "usage (write output to file):"
echo " ./stateful_decoder.sh model in.s16 out.wav [optional stateful_decoder.py args]"
echo "usage (play output with aplay):"
echo " ./stateful_decoder.sh model in.s16 - [optional stateful_decoder.py args]"
exit 1
fi
if [ ! -f $1 ]; then
echo "can't find $1"
exit 1
fi
if [ ! -f $2 ]; then
echo "can't find $2"
exit 1
fi
model=$1
input_speech=$2
output_speech=$3
features_in=features_in.f32
features_out=features_out.f32
rm -f $features_in $features_out
# eat first 3 args before passing rest to stateful_decoder.py in $@
shift; shift; shift
lpcnet_demo -features ${input_speech} ${features_in}
python3 stateful_decoder.py ${model} ${features_in} ${features_out} "$@"
if [ $output_speech == "-" ]; then
tmp=$(mktemp)
lpcnet_demo -fargan-synthesis ${features_out} ${tmp}
aplay $tmp -r 16000 -f S16_LE 2>/dev/null
elif [ $output_speech != "/dev/null" ]; then
tmp=$(mktemp)
lpcnet_demo -fargan-synthesis ${features_out} ${tmp}
sox -t .s16 -r 16000 -c 1 ${tmp} ${output_speech}
fi