bugfix
This commit is contained in:
parent
113ee59c30
commit
af4a0810ff
10
app/fastwhisper.py
Normal file
10
app/fastwhisper.py
Normal file
@ -0,0 +1,10 @@
|
||||
from fastwhisper.init import load_fastwhisper
|
||||
from ahserver.webapp import webapp
|
||||
|
||||
def init():
|
||||
load_fastwhisper()
|
||||
|
||||
if __name__ == '__main__':
|
||||
webapp(init)
|
||||
|
||||
|
||||
59
build.sh
Normal file
59
build.sh
Normal file
@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bash
|
||||
# clone from git@git.opencomputing.cn/yumoqing/fastwhisper
|
||||
# git clone https://git.opencomputing.cn/yumoqing/fastwhisper
|
||||
cdir=$(pwd)
|
||||
uname=$(id -un)
|
||||
gname=$(id -gn)
|
||||
sudo apt install redis-server
|
||||
python3 -m venv py3
|
||||
source py3/bin/activate
|
||||
pip install -r requirements.txt
|
||||
mkdir pkgs
|
||||
cd pkgs
|
||||
for m in apppublic sqlor ahserver longtasks
|
||||
do
|
||||
echo "install $m module..."
|
||||
cd $cdir/pkgs
|
||||
git clone https://git.opencomputing.cn/yumoqing/$m
|
||||
cd $m
|
||||
$cdir/py3/bin/pip install .
|
||||
done
|
||||
cd $cdir/fw
|
||||
pip install .
|
||||
mkdir $cdir/logs
|
||||
cd $cdir
|
||||
touch $cdir/logs/fastwhisper.log
|
||||
cat > $cdir/fastwhisper.service <<EOF
|
||||
[Unit]
|
||||
Wants=systemd-networkd.service
|
||||
|
||||
[Service]
|
||||
User=$uname
|
||||
Group=$gname
|
||||
Type=forking
|
||||
WorkingDirectory=$cdir
|
||||
ExecStart=$cdir/start.sh
|
||||
ExecStop=$cdir/stop.sh
|
||||
StandardOutput=append:$cdir/logs/fastwhisper.log
|
||||
StandardError=append:$cdir/logs/fastwhisper.log
|
||||
SyslogIdentifier=fastwhisper
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
cat > $cdir/start.sh <<EOF
|
||||
#!/usr/bin/bash
|
||||
cd $cdir
|
||||
$cdir/py3/bin/python $cdir/app/fastwhisper.py -p 9180 -w $cdir &
|
||||
exit 0
|
||||
EOF
|
||||
cat > $cdir/stop.sh <<EOF
|
||||
PID=\$(lsof -t -i:9180)
|
||||
kill -9 \$PID
|
||||
EOF
|
||||
chmod +x $cdir/start.sh stop.sh
|
||||
sudo mkdir /var/log/fastwhisper
|
||||
sudo cp fastwhisper.service /etc/systemd/system
|
||||
sudo systemctl enable fastwhisper
|
||||
sudo systemctl restart fastwhisper
|
||||
|
||||
42
conf/config.json
Normal file
42
conf/config.json
Normal file
@ -0,0 +1,42 @@
|
||||
{
|
||||
"filesroot":"$[workdir]$/files",
|
||||
"logger":{
|
||||
"name":"fastwhisper",
|
||||
"levelname":"info",
|
||||
"logfile":"$[workdir]$/logs/fastwhisper.log"
|
||||
},
|
||||
"website":{
|
||||
"paths":[
|
||||
["$[workdir]$/wwwroot",""]
|
||||
],
|
||||
"client_max_size":10000,
|
||||
"host":"0.0.0.0",
|
||||
"port":9925,
|
||||
"coding":"utf-8",
|
||||
"indexes":[
|
||||
"index.html",
|
||||
"index.dspy"
|
||||
"index.ui"
|
||||
],
|
||||
"startswiths":[
|
||||
{
|
||||
"leading":"/idfile",
|
||||
"registerfunction":"idfile"
|
||||
},{
|
||||
"leading": "/v1/transcribe",
|
||||
"registerfunction": "transcribe"
|
||||
},{
|
||||
"leading": "/v1/status",
|
||||
"registerfunction": "get_status"
|
||||
}
|
||||
],
|
||||
"processors":[
|
||||
[".tmpl","tmpl"],
|
||||
[".app","app"],
|
||||
[".ui","bui"],
|
||||
[".dspy","dspy"]
|
||||
],
|
||||
"session_max_time":3000,
|
||||
"session_issue_time":2500,
|
||||
}
|
||||
}
|
||||
0
files/README.md
Normal file
0
files/README.md
Normal file
0
fw/__init__.py
Normal file
0
fw/__init__.py
Normal file
2
fw/fw.py
2
fw/fw.py
@ -14,7 +14,7 @@ class MyLongTask(LongTasks):
|
||||
model = WhisperModel(model_size, device="cuda", compute_type="float16")
|
||||
self.models.append(model)
|
||||
|
||||
def process_task(self, payload:dict, workerid:int=None):
|
||||
async def process_task(self, payload:dict, workerid:int=None):
|
||||
if workerid is None:
|
||||
return {
|
||||
"task_status": "error",
|
||||
|
||||
11
fw/init.py
Normal file
11
fw/init.py
Normal file
@ -0,0 +1,11 @@
|
||||
from fastwhisper.fw import MyLongTask
|
||||
from ahserver.serverenv import ServerEnv
|
||||
from appPublic.jsonConfig import getConfig
|
||||
from appPublic.worker import schedule_once
|
||||
|
||||
def load_fastwhisper()
|
||||
config = getConfig()
|
||||
env = ServerEnv()
|
||||
engine = MyLongTask(config.redis_url, 'fastwhisper')
|
||||
schedule_once(1, engine.run)
|
||||
env.fastwhisper = engine
|
||||
0
logs/README.md
Normal file
0
logs/README.md
Normal file
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@ -0,0 +1 @@
|
||||
faster-whisper
|
||||
0
wwwroot/README.md
Normal file
0
wwwroot/README.md
Normal file
Loading…
x
Reference in New Issue
Block a user