-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathrx2.sh
More file actions
executable file
·51 lines (45 loc) · 1.17 KB
/
rx2.sh
File metadata and controls
executable file
·51 lines (45 loc) · 1.17 KB
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
46
47
48
49
50
51
#!/bin/bash -x
#
# Wrapper around rx2.py
OPUS=build/src
PATH=${PATH}:${OPUS}
features_out=features_out_rx2.f32
if [ $# -lt 4 ]; then
echo "usage (write output to file):"
echo " ./rx2.sh model model_sync rx.iqf32 out.wav [optional rx.py args]"
echo "usage (play output with aplay):"
echo " ./rx2.sh model model_sync rx.iqf32 - [optional rx.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
if [ ! -f $3 ]; then
echo "can't find $3"
exit 1
fi
model=$1
model_sync=$2
input_iqf32=$3
output_speech=$4
# eat first 4 args before passing rest to inference.py in $@
shift; shift; shift; shift
python3 ./rx2.py ${model} ${model_sync} ${input_iqf32} ${features_out} "$@"
if [ $? -ne 0 ]; then
exit 1
fi
if [ $output_speech == "-" ]; then
tmp=$(mktemp)
lpcnet_demo -fargan-synthesis ${features_out} ${tmp}
aplay $tmp -r 16000 -f S16_LE
elif [ $output_speech != "/dev/null" ]; then
tmp=$(mktemp)
# fprint POP to stderr if we get any big pops
lpcnet_demo -fargan-synthesis --pop ${features_out} ${tmp}
sox -t .s16 -r 16000 -c 1 ${tmp} ${output_speech}
fi