forked from zifeng-radxa/whisper-TPU_py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen_onnx.sh
executable file
·63 lines (53 loc) · 1.22 KB
/
gen_onnx.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
# Default values for parameters
model="small"
beam_size=5
padding_size=448
use_kvcache=false
python setup.py install
work_dir="tmp"
if [ ! -d "$work_dir" ]; then
mkdir "$work_dir"
echo "[Cmd] mkdir $work_dir"
fi
pushd "$work_dir"
# Parse command line arguments
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
--model)
model="$2"
shift 2
;;
--beam_size)
beam_size="$2"
shift 2
;;
--padding_size)
padding_size="$2"
shift 2
;;
--use_kvcache)
use_kvcache=true
shift
;;
*)
# Unknown option
echo "Unknown option: $1"
exit 1
;;
esac
done
onnx_export_cmd="bmwhisper ../test/demo.wav --model $model --beam_size $beam_size --padding_size $padding_size --export_onnx"
echo "Generating onnx models ..."
if [ "$use_kvcache" = true ]; then
onnx_export_cmd="$onnx_export_cmd --use_kvcache"
fi
echo "[Cmd] Running command: $onnx_export_cmd"
eval "$onnx_export_cmd"
if [ ! -d "onnx_model" ]; then
mkdir "onnx_model"
echo "[Cmd] mkdir onnx_model"
fi
mv *.onnx *.npz onnx_model
popd