-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
setup.sh
executable file
·112 lines (95 loc) · 2.43 KB
/
setup.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/env bash
set -o errexit
if [[ $(whoami) != "root" ]]; then
echo "This script must be run as root!"
exit 1
fi
echo -n "Where should remote-faster-whisper be installed? > "
read dest_path
echo -n "Install as a service? [Y/n] > "
read service
case ${service} in
n|N|no|No|NO|nO)
service="false"
;;
*)
service="true"
;;
esac
if [[ ${service} == "true" ]]; then
echo -n "Which user should remote-faster-whisper run as? User must exist if specified! [dynamic user] > "
read username
if [[ -z ${username} ]]; then
user_entry="DynamicUser = yes"
else
user_entry="User = ${username}"
fi
fi
echo "Installing..."
if ! test -d ${dest_path}; then
mkdir -p ${dest_path}
fi
virtualenv --python=python3 ${dest_path}
${dest_path}/bin/pip install --requirement requirements.txt
cp remote_faster_whisper.py ${dest_path}/bin/remote_faster_whisper
cp config.yaml ${dest_path}/config.yaml
lib_path="$( dirname $( find ${dest_path}/lib -type f -name "libcudnn_ops*" | head -1 ) )"
if [[ ${service} == "true" ]]; then
cat <<EOF >/etc/systemd/system/remote-faster-whisper.service
[Unit]
Description = Remote Faster Whisper API daemon
After = network-online.target
[Service]
Type = simple
${user_entry}
WorkingDirectory = ${dest_path}
Restart = on-abort
Environment = LD_LIBRARY_PATH=${lib_path}:\$LD_LIBRARY_PATH
Environment = PYTHONUNBUFFERED=true
Environment = RFW_CONFIG_FILE=${dest_path}/config.yaml
ExecStart = ${dest_path}/bin/python ${dest_path}/bin/remote_faster_whisper
[Install]
WantedBy = multi-user.target
EOF
systemctl daemon-reload
fi
cat <<EOF >${dest_path}/config.yaml
---
daemon:
listen: 0.0.0.0
port: 9876
base_url: "/api/v0"
faster_whisper:
model_cache_dir: /tmp/whisper-cache
model: small
device: cuda
device_id: 1
compute_type: int8
beam_size: 5
translate: yes
language:
EOF
echo -n "Edit configuration file now? [Y/n] > "
read editconf
case ${editconf} in
n|N|no|No|NO|nO)
true
;;
*)
$EDITOR ${dest_path}/config.yaml
;;
esac
if [[ ${service} == "true" ]]; then
echo -n "Enable and start remote-faster-whisper.service now? [Y/n] > "
read startsvc
case ${startsvc} in
n|N|no|No|NO|nO)
true
;;
*)
systemctl enable --now remote-faster-whisper.service
sleep 3
systemctl status --no-pager remote-faster-whisper.service
;;
esac
fi