/
infer.sh
executable file
·49 lines (38 loc) · 1.25 KB
/
infer.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
46
47
48
49
#!/bin/bash
wavFile=$1
if ! [ -f $wavFile ] || [[ -z "${wavFile// }" ]]; then
echo "must pass a .wav file to infer on as first argument..."
exit 1
fi
# -----------------------------
checkpointsDir="/var/tmp/pls/checkpoints/"
if [ -z "$(ls -A ${checkpointsDir})" ]; then
echo "There are no models. Please run ./train.sh first before you infer!"
exit 1
fi
shopt -s nullglob
checkpointFiles=(${checkpointsDir}*)
checkpointFiles=("${checkpointFiles[@]##*/}") # remove path
checkpointFiles=( $( for i in ${checkpointFiles[@]} ; do echo $i ; done | grep meta ) )
checkpointFiles=("${checkpointFiles[@]%.meta}") # remove meta
for i in "${!checkpointFiles[@]}"; do
printf "%s\t%s\n" "$i" "${checkpointFiles[$i]}"
done
echo "which index did you want as your model?"
while true; do
read number
if ! [[ $number =~ ^[0-9]+$ ]] ; then
echo "please enter a valid selection..."
continue
fi
if (( ${#checkpointFiles[number]} == 0 )) ; then
echo "please enter a valid selection..."
continue
fi
echo "You chose ${checkpointFiles[number]}"
break
done
model=${checkpointsDir}${checkpointFiles[number]}
# -----------------------------
echo "infer using modal..."
python ./scripts/infer.py $wavFile $model