From a05e753d11d9c36983ec4e58c421dbcf86d1dcd4 Mon Sep 17 00:00:00 2001 From: Xian Shi <40013335+R1ckShi@users.noreply.github.com> Date: 星期二, 17 十月 2023 16:47:27 +0800 Subject: [PATCH] Merge branch 'main' into dev_onnx --- funasr/runtime/docs/SDK_advanced_guide_offline_zh.md | 98 +++++++++++++++++++++++++----------------------- 1 files changed, 51 insertions(+), 47 deletions(-) diff --git a/funasr/runtime/docs/SDK_advanced_guide_offline_zh.md b/funasr/runtime/docs/SDK_advanced_guide_offline_zh.md index 6e93472..c631097 100644 --- a/funasr/runtime/docs/SDK_advanced_guide_offline_zh.md +++ b/funasr/runtime/docs/SDK_advanced_guide_offline_zh.md @@ -22,9 +22,12 @@ 閫氳繃涓嬭堪鍛戒护鎷夊彇骞跺惎鍔‵unASR runtime-SDK鐨刣ocker闀滃儚锛� ```shell -sudo docker pull registry.cn-hangzhou.aliyuncs.com/funasr_repo/funasr:funasr-runtime-sdk-cpu-0.2.1 +sudo docker pull \ + registry.cn-hangzhou.aliyuncs.com/funasr_repo/funasr:funasr-runtime-sdk-cpu-0.2.2 mkdir -p ./funasr-runtime-resources/models -sudo docker run -p 10095:10095 -it --privileged=true -v ./funasr-runtime-resources/models:/workspace/models registry.cn-hangzhou.aliyuncs.com/funasr_repo/funasr:funasr-runtime-sdk-cpu-0.2.1 +sudo docker run -p 10095:10095 -it --privileged=true \ + -v $PWD/funasr-runtime-resources/models:/workspace/models \ + registry.cn-hangzhou.aliyuncs.com/funasr_repo/funasr:funasr-runtime-sdk-cpu-0.2.2 ``` 濡傛灉鎮ㄦ病鏈夊畨瑁卍ocker锛屽彲鍙傝�僛Docker瀹夎](#Docker瀹夎) @@ -37,7 +40,8 @@ --download-model-dir /workspace/models \ --vad-dir damo/speech_fsmn_vad_zh-cn-16k-common-onnx \ --model-dir damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-onnx \ - --punc-dir damo/punc_ct-transformer_zh-cn-common-vocab272727-onnx > log.out 2>&1 & + --punc-dir damo/punc_ct-transformer_zh-cn-common-vocab272727-onnx \ + --itn-dir thuduj12/fst_itn_zh > log.out 2>&1 & # 濡傛灉鎮ㄦ兂鍏抽棴ssl锛屽鍔犲弬鏁帮細--certfile 0 # 濡傛灉鎮ㄦ兂浣跨敤鏃堕棿鎴虫垨鑰呯儹璇嶆ā鍨嬭繘琛岄儴缃诧紝璇疯缃�--model-dir涓哄搴旀ā鍨嬶細 @@ -45,7 +49,7 @@ # 鎴栬�� damo/speech_paraformer-large-contextual_asr_nat-zh-cn-16k-common-vocab8404-onnx锛堢儹璇嶏級 ``` -鏈嶅姟绔缁嗗弬鏁颁粙缁嶅彲鍙傝�僛鏈嶅姟绔弬鏁颁粙缁峕(#鏈嶅姟绔弬鏁颁粙缁�) +鏈嶅姟绔缁嗗弬鏁颁粙缁嶅彲鍙傝�僛鏈嶅姟绔敤娉曡瑙(#鏈嶅姟绔敤娉曡瑙�) ### 瀹㈡埛绔祴璇曚笌浣跨敤 涓嬭浇瀹㈡埛绔祴璇曞伐鍏风洰褰晄amples @@ -99,18 +103,21 @@ 鑻ユ兂鐩存帴杩愯client杩涜娴嬭瘯锛屽彲鍙傝�冨涓嬬畝鏄撹鏄庯紝浠ython鐗堟湰涓轰緥锛� ```shell -python3 wss_client_asr.py --host "127.0.0.1" --port 10095 --mode offline --audio_in "../audio/asr_example.wav" --output_dir "./results" +python3 funasr_wss_client.py --host "127.0.0.1" --port 10095 --mode offline \ + --audio_in "../audio/asr_example.wav" --output_dir "./results" ``` 鍛戒护鍙傛暟璇存槑锛� ```text ---host 涓篎unASR runtime-SDK鏈嶅姟閮ㄧ讲鏈哄櫒ip锛岄粯璁や负鏈満ip锛�127.0.0.1锛夛紝濡傛灉client涓庢湇鍔′笉鍦ㄥ悓涓�鍙版湇鍔″櫒锛岄渶瑕佹敼涓洪儴缃叉満鍣╥p +--host 涓篎unASR runtime-SDK鏈嶅姟閮ㄧ讲鏈哄櫒ip锛岄粯璁や负鏈満ip锛�127.0.0.1锛夛紝濡傛灉client涓庢湇鍔′笉鍦ㄥ悓涓�鍙版湇鍔″櫒锛� + 闇�瑕佹敼涓洪儴缃叉満鍣╥p --port 10095 閮ㄧ讲绔彛鍙� --mode offline琛ㄧず绂荤嚎鏂囦欢杞啓 --audio_in 闇�瑕佽繘琛岃浆鍐欑殑闊抽鏂囦欢锛屾敮鎸佹枃浠惰矾寰勶紝鏂囦欢鍒楄〃wav.scp --thread_num 璁剧疆骞跺彂鍙戦�佺嚎绋嬫暟锛岄粯璁や负1 --ssl 璁剧疆鏄惁寮�鍚痵sl璇佷功鏍¢獙锛岄粯璁�1寮�鍚紝璁剧疆涓�0鍏抽棴 ---hotword 濡傛灉妯″瀷涓虹儹璇嶆ā鍨嬶紝鍙互璁剧疆鐑瘝: *.txt(姣忚涓�涓儹璇�) 鎴栬�呯┖鏍煎垎闅旂殑鐑瘝瀛楃涓� (could be: 闃块噷宸村反 杈炬懇闄�) +--hotword 濡傛灉妯″瀷涓虹儹璇嶆ā鍨嬶紝鍙互璁剧疆鐑瘝: *.txt(姣忚涓�涓儹璇�) 鎴栬�呯┖鏍煎垎闅旂殑鐑瘝瀛楃涓�(闃块噷宸村反 杈炬懇闄�) +--use_itn 璁剧疆鏄惁浣跨敤itn锛岄粯璁�1寮�鍚紝璁剧疆涓�0鍏抽棴 ``` ### cpp-client @@ -122,10 +129,12 @@ 鍛戒护鍙傛暟璇存槑锛� ```text ---server-ip 涓篎unASR runtime-SDK鏈嶅姟閮ㄧ讲鏈哄櫒ip锛岄粯璁や负鏈満ip锛�127.0.0.1锛夛紝濡傛灉client涓庢湇鍔′笉鍦ㄥ悓涓�鍙版湇鍔″櫒锛岄渶瑕佹敼涓洪儴缃叉満鍣╥p +--server-ip 涓篎unASR runtime-SDK鏈嶅姟閮ㄧ讲鏈哄櫒ip锛岄粯璁や负鏈満ip锛�127.0.0.1锛夛紝濡傛灉client涓庢湇鍔′笉鍦ㄥ悓涓�鍙版湇鍔″櫒锛� + 闇�瑕佹敼涓洪儴缃叉満鍣╥p --port 10095 閮ㄧ讲绔彛鍙� --wav-path 闇�瑕佽繘琛岃浆鍐欑殑闊抽鏂囦欢锛屾敮鎸佹枃浠惰矾寰� ---hotword 濡傛灉妯″瀷涓虹儹璇嶆ā鍨嬶紝鍙互璁剧疆鐑瘝: *.txt(姣忚涓�涓儹璇�) 鎴栬�呯┖鏍煎垎闅旂殑鐑瘝瀛楃涓� (could be: 闃块噷宸村反 杈炬懇闄�) +--hotword 濡傛灉妯″瀷涓虹儹璇嶆ā鍨嬶紝鍙互璁剧疆鐑瘝: *.txt(姣忚涓�涓儹璇�) 鎴栬�呯┖鏍煎垎闅旂殑鐑瘝瀛楃涓� (闃块噷宸村反 杈炬懇闄�) +--use-itn 璁剧疆鏄惁浣跨敤itn锛岄粯璁�1寮�鍚紝璁剧疆涓�0鍏抽棴 ``` ### Html缃戦〉鐗� @@ -141,25 +150,24 @@ ``` 璇︾粏鍙互鍙傝�冩枃妗o紙[鐐瑰嚮姝ゅ](../java/readme.md)锛� +## 鏈嶅姟绔敤娉曡瑙o細 - -## 鏈嶅姟绔弬鏁颁粙缁嶏細 - -funasr-wss-server鏀寔浠嶮odelscope涓嬭浇妯″瀷锛岃缃ā鍨嬩笅杞藉湴鍧�锛�--download-model-dir锛岄粯璁や负/workspace/models锛夊強model ID锛�--model-dir銆�--vad-dir銆�--punc-dir锛�,绀轰緥濡備笅锛� +### 鍚姩FunASR鏈嶅姟 ```shell -cd /workspace/FunASR/funasr/runtime/websocket/build/bin -./funasr-wss-server \ +cd /workspace/FunASR/funasr/runtime +nohup bash run_server.sh \ --download-model-dir /workspace/models \ --model-dir damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-onnx \ --vad-dir damo/speech_fsmn_vad_zh-cn-16k-common-onnx \ --punc-dir damo/punc_ct-transformer_zh-cn-common-vocab272727-onnx \ + --itn-dir thuduj12/fst_itn_zh \ --decoder-thread-num 32 \ --io-thread-num 8 \ --port 10095 \ --certfile ../../../ssl_key/server.crt \ - --keyfile ../../../ssl_key/server.key + --keyfile ../../../ssl_key/server.key > log.out 2>&1 & ``` -鍛戒护鍙傛暟浠嬬粛锛� +**run_server.sh鍛戒护鍙傛暟浠嬬粛** ```text --download-model-dir 妯″瀷涓嬭浇鍦板潃锛岄�氳繃璁剧疆model ID浠嶮odelscope涓嬭浇妯″瀷 --model-dir modelscope model ID @@ -168,45 +176,41 @@ --vad-quant True涓洪噺鍖朧AD妯″瀷锛孎alse涓洪潪閲忓寲VAD妯″瀷锛岄粯璁ゆ槸True --punc-dir modelscope model ID --punc-quant True涓洪噺鍖朠UNC妯″瀷锛孎alse涓洪潪閲忓寲PUNC妯″瀷锛岄粯璁ゆ槸True +--itn-dir modelscope model ID --port 鏈嶅姟绔洃鍚殑绔彛鍙凤紝榛樿涓� 10095 --decoder-thread-num 鏈嶅姟绔惎鍔ㄧ殑鎺ㄧ悊绾跨▼鏁帮紝榛樿涓� 8 --io-thread-num 鏈嶅姟绔惎鍔ㄧ殑IO绾跨▼鏁帮紝榛樿涓� 1 ---certfile ssl鐨勮瘉涔︽枃浠讹紝榛樿涓猴細../../../ssl_key/server.crt锛屽鏋滈渶瑕佸叧闂璼sl锛屽弬鏁拌缃负鈥濃�� ---keyfile ssl鐨勫瘑閽ユ枃浠讹紝榛樿涓猴細../../../ssl_key/server.key锛屽鏋滈渶瑕佸叧闂璼sl锛屽弬鏁拌缃负鈥濃�� +--certfile ssl鐨勮瘉涔︽枃浠讹紝榛樿涓猴細../../../ssl_key/server.crt锛屽鏋滈渶瑕佸叧闂璼sl锛屽弬鏁拌缃负0 +--keyfile ssl鐨勫瘑閽ユ枃浠讹紝榛樿涓猴細../../../ssl_key/server.key ``` -funasr-wss-server鍚屾椂涔熸敮鎸佷粠鏈湴璺緞鍔犺浇妯″瀷锛堟湰鍦版ā鍨嬭祫婧愬噯澶囪瑙乕妯″瀷璧勬簮鍑嗗](#妯″瀷璧勬簮鍑嗗)锛夌ず渚嬪涓嬶細 -```shell -cd /workspace/FunASR/funasr/runtime/websocket/build/bin -./funasr-wss-server \ - --model-dir /workspace/models/damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-onnx \ - --vad-dir /workspace/models/damo/speech_fsmn_vad_zh-cn-16k-common-onnx \ - --punc-dir /workspace/models/damo/punc_ct-transformer_zh-cn-common-vocab272727-onnx \ - --decoder-thread-num 32 \ - --io-thread-num 8 \ - --port 10095 \ - --certfile ../../../ssl_key/server.crt \ - --keyfile ../../../ssl_key/server.key - ``` -鍛戒护鍙傛暟浠嬬粛锛� +### 鍏抽棴FunASR鏈嶅姟 ```text ---model-dir ASR妯″瀷璺緞锛岄粯璁や负锛�/workspace/models/asr ---quantize True涓洪噺鍖朅SR妯″瀷锛孎alse涓洪潪閲忓寲ASR妯″瀷锛岄粯璁ゆ槸True ---vad-dir VAD妯″瀷璺緞锛岄粯璁や负锛�/workspace/models/vad ---vad-quant True涓洪噺鍖朧AD妯″瀷锛孎alse涓洪潪閲忓寲VAD妯″瀷锛岄粯璁ゆ槸True ---punc-dir PUNC妯″瀷璺緞锛岄粯璁や负锛�/workspace/models/punc ---punc-quant True涓洪噺鍖朠UNC妯″瀷锛孎alse涓洪潪閲忓寲PUNC妯″瀷锛岄粯璁ゆ槸True ---port 鏈嶅姟绔洃鍚殑绔彛鍙凤紝榛樿涓� 10095 ---decoder-thread-num 鏈嶅姟绔惎鍔ㄧ殑鎺ㄧ悊绾跨▼鏁帮紝榛樿涓� 8 ---io-thread-num 鏈嶅姟绔惎鍔ㄧ殑IO绾跨▼鏁帮紝榛樿涓� 1 ---certfile ssl鐨勮瘉涔︽枃浠讹紝榛樿涓猴細../../../ssl_key/server.crt锛屽鏋滈渶瑕佸叧闂璼sl锛屽弬鏁拌缃负鈥濃�� ---keyfile ssl鐨勫瘑閽ユ枃浠讹紝榛樿涓猴細../../../ssl_key/server.key锛屽鏋滈渶瑕佸叧闂璼sl锛屽弬鏁拌缃负鈥濃�� +# 鏌ョ湅 funasr-wss-server 瀵瑰簲鐨凱ID +ps -x | grep funasr-wss-server +kill -9 PID +``` + +### 淇敼妯″瀷鍙婂叾浠栧弬鏁� +鏇挎崲姝e湪浣跨敤鐨勬ā鍨嬫垨鑰呭叾浠栧弬鏁帮紝闇�鍏堝叧闂璅unASR鏈嶅姟锛屼慨鏀归渶瑕佹浛鎹㈢殑鍙傛暟锛屽苟閲嶆柊鍚姩FunASR鏈嶅姟銆傚叾涓ā鍨嬮渶涓篗odelScope涓殑ASR/VAD/PUNC妯″瀷锛屾垨鑰呬粠ModelScope涓ā鍨媐inetune鍚庣殑妯″瀷銆� +```text +# 渚嬪鏇挎崲ASR妯″瀷涓� damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-onnx锛屽垯濡備笅璁剧疆鍙傛暟 --model-dir + --model-dir damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-onnx +# 璁剧疆绔彛鍙� --port + --port <port number> +# 璁剧疆鏈嶅姟绔惎鍔ㄧ殑鎺ㄧ悊绾跨▼鏁� --decoder-thread-num + --decoder-thread-num <decoder thread num> +# 璁剧疆鏈嶅姟绔惎鍔ㄧ殑IO绾跨▼鏁� --io-thread-num + --io-thread-num <io thread num> +# 鍏抽棴SSL璇佷功 + --certfile 0 ``` 鎵ц涓婅堪鎸囦护鍚庯紝鍚姩绂荤嚎鏂囦欢杞啓鏈嶅姟銆傚鏋滄ā鍨嬫寚瀹氫负ModelScope涓璵odel id锛屼細鑷姩浠嶮oldeScope涓笅杞藉涓嬫ā鍨嬶細 -[FSMN-VAD妯″瀷](https://www.modelscope.cn/models/damo/speech_fsmn_vad_zh-cn-16k-common-onnx/summary)锛� -[Paraformer-lagre妯″瀷](https://www.modelscope.cn/models/damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-onnx/summary) -[CT-Transformer鏍囩偣棰勬祴妯″瀷](https://www.modelscope.cn/models/damo/punc_ct-transformer_zh-cn-common-vocab272727-onnx/summary) +[FSMN-VAD妯″瀷](https://www.modelscope.cn/models/damo/speech_fsmn_vad_zh-cn-16k-common-onnx/summary), +[Paraformer-lagre妯″瀷](https://www.modelscope.cn/models/damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-onnx/summary), +[CT-Transformer鏍囩偣棰勬祴妯″瀷](https://www.modelscope.cn/models/damo/punc_ct-transformer_zh-cn-common-vocab272727-onnx/summary), +[鍩轰簬FST鐨勪腑鏂嘔TN](https://www.modelscope.cn/models/thuduj12/fst_itn_zh/summary) 濡傛灉锛屾偍甯屾湜閮ㄧ讲鎮╢inetune鍚庣殑妯″瀷锛堜緥濡�10epoch.pb锛夛紝闇�瑕佹墜鍔ㄥ皢妯″瀷閲嶅懡鍚嶄负model.pb锛屽苟灏嗗師modelscope涓ā鍨媘odel.pb鏇挎崲鎺夛紝灏嗚矾寰勬寚瀹氫负`model_dir`鍗冲彲銆� -- Gitblit v1.9.1