FunASR/runtime/python/http
Yabin Li 702ec03ad8
Dev new (#1065)
* add hotword for deploy_tools

* Support wfst decoder and contextual biasing (#1039)

* Support wfst decoder and contextual biasing

* Turn on fstbin compilation

---------

Co-authored-by: gongbo.gb <gongbo.gb@alibaba-inc.com>

* mv funasr/runtime runtime

* Fix crash caused by OOV in hotwords list

* funasr infer

* funasr infer

* funasr infer

* funasr infer

* funasr infer

* fix some bugs about fst hotword; support wfst for websocket server and clients; mv runtime out of funasr; modify relative docs

* del onnxruntime/include/gflags

* update tensor.h

* update run_server.sh

* update deploy tools

* update deploy tools

* update websocket-server

* update funasr-wss-server

* Remove self loop propagation

* Update websocket_protocol_zh.md

* Update websocket_protocol_zh.md

* update hotword protocol

* author zhaomingwork: change hotwords for h5 and java

* update hotword protocol

* catch exception for json_fst_hws

* update hotword on message

* update onnx benchmark for ngram&hotword

* update docs

* update funasr-wss-serve

* add NONE for LM_DIR

* update docs

* update run_server.sh

* add whats-new

* modify whats-new

* update whats-new

* update whats-new

* Support decoder option for beam searching

* update benchmark_onnx_cpp

* Support decoder option for websocket

* fix bug of CompileHotwordEmbedding

* update html client

* update docs

---------

Co-authored-by: gongbo.gb <35997837+aibulamusi@users.noreply.github.com>
Co-authored-by: gongbo.gb <gongbo.gb@alibaba-inc.com>
Co-authored-by: 游雁 <zhifu.gzf@alibaba-inc.com>
2023-11-07 18:34:29 +08:00
..
asr_nginx.conf Dev new (#1065) 2023-11-07 18:34:29 +08:00
client.py Dev new (#1065) 2023-11-07 18:34:29 +08:00
README.md Dev new (#1065) 2023-11-07 18:34:29 +08:00
requirements.txt Dev new (#1065) 2023-11-07 18:34:29 +08:00
server.py Dev new (#1065) 2023-11-07 18:34:29 +08:00
start_server.sh Dev new (#1065) 2023-11-07 18:34:29 +08:00

Service with http-python

Server

  1. Install requirements
cd funasr/runtime/python/http
pip install -r requirements.txt
  1. Start server
python server.py --port 8000

More parameters:

python server.py \
--host [host ip] \
--port [server port] \
--asr_model [asr model_name] \
--vad_model [vad model_name] \
--punc_model [punc model_name] \
--ngpu [0 or 1] \
--ncpu [1 or 4] \
--hotword_path [path of hot word txt] \
--certfile [path of certfile for ssl] \
--keyfile [path of keyfile for ssl] \
--temp_dir [upload file temp dir] 

Client

# get test audio file
wget https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/asr_example_zh.wav
python client.py --host=127.0.0.1 --port=8000 --audio_path=asr_example_zh.wav

More parameters:

python server.py \
--host [sever ip] \
--port [sever port] \
--add_pun [add pun to result] \
--audio_path [use audio path] 

支持多进程

方法是启动多个server.py然后通过Nginx的负载均衡分发请求达到支持多用户同时连效果处理方式如下默认您已经安装了Nginx没安装的请参考官方安装教程

配置Nginx。

sudo cp -f asr_nginx.conf /etc/nginx/nginx.conf
sudo service nginx reload

然后使用脚本启动多个服务,每个服务的端口号不一样。

sudo chmod +x start_server.sh
./start_server.sh

说明: 默认是3个进程如果需要修改首先修改start_server.sh的最后那部分,可以添加启动数量。然后修改asr_nginx.conf配置文件的upstream backend部分,增加新启动的服务,可以使其他服务器的服务。