From c2e4e3c2e9be855277d9f4fa9cd0544892ff829a Mon Sep 17 00:00:00 2001 From: 游雁 <zhifu.gzf@alibaba-inc.com> Date: 星期三, 30 八月 2023 09:57:30 +0800 Subject: [PATCH] Merge branch 'main' of github.com:alibaba-damo-academy/FunASR add --- funasr/runtime/docs/SDK_tutorial_zh.md | 167 +++++++++++++++++++++++++++++++------------------------ 1 files changed, 94 insertions(+), 73 deletions(-) diff --git a/funasr/runtime/docs/SDK_tutorial_zh.md b/funasr/runtime/docs/SDK_tutorial_zh.md index 4842057..27ffbcd 100644 --- a/funasr/runtime/docs/SDK_tutorial_zh.md +++ b/funasr/runtime/docs/SDK_tutorial_zh.md @@ -1,7 +1,11 @@ -# FunASR绂荤嚎鏂囦欢杞啓鏈嶅姟渚挎嵎閮ㄧ讲鏁欑▼ +(绠�浣撲腑鏂噟[English](./SDK_tutorial.md)) +# Highlights +**FunASR绂荤嚎鏂囦欢杞啓鏈嶅姟宸插崌绾ц嚦2.0,闆嗘垚ffmpeg鏀寔澶氱闊宠棰戣緭鍏ャ�佹敮鎸佺儹璇嶆ā鍨嬨�佹敮鎸佹椂闂存埑妯″瀷锛屾杩庨儴缃蹭綋楠孾蹇�熶笂鎵媇(#蹇�熶笂鎵�)** + +# FunASR绂荤嚎鏂囦欢杞啓鏈嶅姟渚挎嵎閮ㄧ讲鏁欑▼ FunASR鎻愪緵鍙究鎹锋湰鍦版垨鑰呬簯绔湇鍔″櫒閮ㄧ讲鐨勭绾挎枃浠惰浆鍐欐湇鍔★紝鍐呮牳涓篎unASR宸插紑婧恟untime-SDK銆� -闆嗘垚浜嗚揪鎽╅櫌璇煶瀹為獙瀹ゅ湪Modelscope绀惧尯寮�婧愮殑璇煶绔偣妫�娴�(VAD)銆丳araformer-large璇煶璇嗗埆(ASR)銆佹爣鐐规仮澶�(PUNC) 绛夌浉鍏宠兘鍔涳紝鎷ユ湁瀹屾暣鐨勮闊宠瘑鍒摼璺紝鍙互灏嗗嚑鍗佷釜灏忔椂鐨勯煶棰戣瘑鍒垚甯︽爣鐐圭殑鏂囧瓧锛岃�屼笖鏀寔涓婄櫨璺苟鍙戝悓鏃惰繘琛岃瘑鍒�� +闆嗘垚浜嗚揪鎽╅櫌璇煶瀹為獙瀹ゅ湪Modelscope绀惧尯寮�婧愮殑璇煶绔偣妫�娴�(VAD)銆丳araformer-large璇煶璇嗗埆(ASR)銆佹爣鐐规仮澶�(PUNC) 绛夌浉鍏宠兘鍔涳紝鎷ユ湁瀹屾暣鐨勮闊宠瘑鍒摼璺紝鍙互灏嗗嚑鍗佷釜灏忔椂鐨勯煶棰戞垨瑙嗛璇嗗埆鎴愬甫鏍囩偣鐨勬枃瀛楋紝鑰屼笖鏀寔涓婄櫨璺姹傚悓鏃惰繘琛岃浆鍐欍�� ## 鏈嶅姟鍣ㄩ厤缃� @@ -10,27 +14,37 @@ - 閰嶇疆2: 锛圶86锛岃绠楀瀷锛夛紝16鏍竩CPU锛屽唴瀛�32G锛屽崟鏈哄彲浠ユ敮鎸佸ぇ绾�64璺殑璇锋眰 - 閰嶇疆3: 锛圶86锛岃绠楀瀷锛夛紝64鏍竩CPU锛屽唴瀛�128G锛屽崟鏈哄彲浠ユ敮鎸佸ぇ绾�200璺殑璇锋眰 -璇︾粏鎬ц兘娴嬭瘯鎶ュ憡锛歔鐐规閾炬帴](./benchmark_onnx_cpp.md) +璇︾粏鎬ц兘娴嬭瘯鎶ュ憡锛圼鐐瑰嚮姝ゅ](./benchmark_onnx_cpp.md)锛� -浜戞湇鍔″巶鍟嗭紝閽堝鏂扮敤鎴凤紝鏈�3涓湀鍏嶈垂璇曠敤娲诲姩锛岀敵璇锋暀绋嬶紙[鐐瑰嚮姝ゅ](./aliyun_server_tutorial.md)锛� +浜戞湇鍔″巶鍟嗭紝閽堝鏂扮敤鎴凤紝鏈�3涓湀鍏嶈垂璇曠敤娲诲姩锛岀敵璇锋暀绋嬶紙[鐐瑰嚮姝ゅ](https://github.com/alibaba-damo-academy/FunASR/blob/main/funasr/runtime/docs/aliyun_server_tutorial.md)锛� ## 蹇�熶笂鎵� ### 鏈嶅姟绔惎鍔� -閫氳繃浠ヤ笅鍛戒护杩愯涓�閿儴缃叉湇鍔★紝鎸夌収鎻愮ず閫愭瀹屾垚FunASR runtime-SDK鏈嶅姟鐨勯儴缃插拰杩愯銆傜洰鍓嶆殏鏃朵粎鏀寔Linux鐜锛屽叾浠栫幆澧冨弬鑰冩枃妗楂橀樁寮�鍙戞寚鍗梋(./SDK_advanced_guide_cn.md) + +`娉ㄦ剰`锛氫竴閿儴缃插伐鍏凤紝杩囩▼鍒嗕负锛氬畨瑁卍ocker銆佷笅杞絛ocker闀滃儚銆佸惎鍔ㄦ湇鍔°�傚鏋滅敤鎴峰笇鏈涚洿鎺ヤ粠FunASR docker闀滃儚鍚姩锛屽彲浠ュ弬鑰冨紑鍙戞寚鍗楋紙[鐐瑰嚮姝ゅ](./SDK_advanced_guide_offline_zh.md)锛� + +涓嬭浇閮ㄧ讲宸ュ叿`funasr-runtime-deploy-offline-cpu-zh.sh` ```shell -curl -O https://raw.githubusercontent.com/alibaba-damo-academy/FunASR/main/funasr/runtime/funasr-runtime-deploy.sh; sudo bash funasr-runtime-deploy.sh install -# 濡傞亣鍒扮綉缁滈棶棰橈紝涓浗澶ч檰鐢ㄦ埛锛屽彲浠ョ敤涓笅闈㈢殑鍛戒护锛� -# curl -O https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/shell/funasr-runtime-deploy.sh; sudo bash funasr-runtime-deploy.sh install +curl -O https://raw.githubusercontent.com/alibaba-damo-academy/FunASR/main/funasr/runtime/deploy_tools/funasr-runtime-deploy-offline-cpu-zh.sh; +# 濡傞亣鍒扮綉缁滈棶棰橈紝涓浗澶ч檰鐢ㄦ埛锛屽彲浠ヤ娇鐢ㄤ笅闈㈢殑鍛戒护锛� +# curl -O https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/shell/funasr-runtime-deploy-offline-cpu-zh.sh; ``` + +鎵ц閮ㄧ讲宸ュ叿锛屽湪鎻愮ず澶勮緭鍏ュ洖杞﹂敭鍗冲彲瀹屾垚鏈嶅姟绔畨瑁呬笌閮ㄧ讲銆傜洰鍓嶄究鎹烽儴缃插伐鍏锋殏鏃朵粎鏀寔Linux鐜锛屽叾浠栫幆澧冮儴缃插弬鑰冨紑鍙戞寚鍗楋紙[鐐瑰嚮姝ゅ](./SDK_advanced_guide_offline_zh.md)锛� +```shell +sudo bash funasr-runtime-deploy-offline-cpu-zh.sh install --workspace ./funasr-runtime-resources +``` +**娉細濡傛灉闇�瑕侀儴缃叉椂闂存埑妯″瀷鎴栬�呯儹璇嶆ā鍨嬶紝鍦ㄥ畨瑁呴儴缃叉楠�2鏃堕�夋嫨瀵瑰簲妯″瀷锛屽叾涓�1涓簆araformer-large妯″瀷锛�2涓簆araformer-large 鏃堕棿鎴虫ā鍨嬶紝3涓簆araformer-large 鐑瘝妯″瀷** ### 瀹㈡埛绔祴璇曚笌浣跨敤 -鎴戜滑浠ython璇█瀹㈡埛绔负渚嬶紝杩涜璇存槑锛屽叾浠栫増鏈鎴风璇峰弬鑰僛寮�鍙戞寚鍗梋() +杩愯涓婇潰瀹夎鎸囦护鍚庯紝浼氬湪/root/funasr-runtime-resources锛堥粯璁ゅ畨瑁呯洰褰曪級涓笅杞藉鎴风娴嬭瘯宸ュ叿鐩綍samples锛堟墜鍔ㄤ笅杞斤紝[鐐瑰嚮姝ゅ](https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/sample/funasr_samples.tar.gz)锛夛紝 +鎴戜滑浠ython璇█瀹㈡埛绔负渚嬶紝杩涜璇存槑锛屾敮鎸佸绉嶉煶棰戞牸寮忚緭鍏ワ紙.wav, .pcm, .mp3绛夛級锛屼篃鏀寔瑙嗛杈撳叆(.mp4绛�)锛屼互鍙婂鏂囦欢鍒楄〃wav.scp杈撳叆锛屽叾浠栫増鏈鎴风璇峰弬鑰冩枃妗o紙[鐐瑰嚮姝ゅ](#瀹㈡埛绔敤娉曡瑙�)锛� ```shell -python3 wss_client_asr.py --host "127.0.0.1" --port 10095 --mode offline --audio_in "../audio/asr_example.wav" --send_without_sleep --output_dir "./results" +python3 funasr_wss_client.py --host "127.0.0.1" --port 10095 --mode offline --audio_in "../audio/asr_example.wav" ``` ## 瀹㈡埛绔敤娉曡瑙� @@ -38,18 +52,18 @@ 鍦ㄦ湇鍔″櫒涓婂畬鎴怓unASR鏈嶅姟閮ㄧ讲浠ュ悗锛屽彲浠ラ�氳繃濡備笅鐨勬楠ゆ潵娴嬭瘯鍜屼娇鐢ㄧ绾挎枃浠惰浆鍐欐湇鍔°�� 鐩墠鍒嗗埆鏀寔浠ヤ笅鍑犵缂栫▼璇█瀹㈡埛绔� -- Python -- C++ -- Java -- html缃戦〉鐗堟湰 +- [Python](#python-client) +- [CPP](#cpp-client) +- [html](#html-client) +- [java](#java-client) -鎴戜滑浠ython璇█瀹㈡埛绔负渚嬶紝杩涜璇存槑锛屽叾浠栫増鏈鎴风璇峰弬鑰僛寮�鍙戞寚鍗梋() +鏇村鐗堟湰瀹㈡埛绔敮鎸佽鍙傝�僛websocket/grpc鍗忚](./websocket_protocol_zh.md) ### python-client 鑻ユ兂鐩存帴杩愯client杩涜娴嬭瘯锛屽彲鍙傝�冨涓嬬畝鏄撹鏄庯紝浠ython鐗堟湰涓轰緥锛� ```shell -python3 wss_client_asr.py --host "127.0.0.1" --port 10095 --mode offline --audio_in "../audio/asr_example.wav" --send_without_sleep --output_dir "./results" +python3 funasr_wss_client.py --host "127.0.0.1" --port 10095 --mode offline --audio_in "../audio/asr_example.wav" ``` 鍛戒护鍙傛暟璇存槑锛� @@ -58,33 +72,40 @@ --port 10095 閮ㄧ讲绔彛鍙� --mode offline琛ㄧず绂荤嚎鏂囦欢杞啓 --audio_in 闇�瑕佽繘琛岃浆鍐欑殑闊抽鏂囦欢锛屾敮鎸佹枃浠惰矾寰勶紝鏂囦欢鍒楄〃wav.scp ---output_dir 璇嗗埆缁撴灉淇濆瓨璺緞 +--thread_num 璁剧疆骞跺彂鍙戦�佺嚎绋嬫暟锛岄粯璁や负1 +--ssl 璁剧疆鏄惁寮�鍚痵sl璇佷功鏍¢獙锛岄粯璁�1寮�鍚紝璁剧疆涓�0鍏抽棴 +--hotword 濡傛灉妯″瀷涓虹儹璇嶆ā鍨嬶紝鍙互璁剧疆鐑瘝: *.txt(姣忚涓�涓儹璇�) 鎴栬�呯┖鏍煎垎闅旂殑鐑瘝瀛楃涓� (could be: 闃块噷宸村反 杈炬懇闄�) ``` -[//]: # (#### cpp-client) +### cpp-client +杩涘叆samples/cpp鐩綍鍚庯紝鍙互鐢╟pp杩涜娴嬭瘯锛屾寚浠ゅ涓嬶細 +```shell +./funasr-wss-client --server-ip 127.0.0.1 --port 10095 --wav-path ../audio/asr_example.wav +``` -[//]: # () -[//]: # (```shell) +鍛戒护鍙傛暟璇存槑锛� -[//]: # (export LD_LIBRARY_PATH=/root/funasr_samples/cpp/libs:$LD_LIBRARY_PATH) +```text +--server-ip 涓篎unASR runtime-SDK鏈嶅姟閮ㄧ讲鏈哄櫒ip锛岄粯璁や负鏈満ip锛�127.0.0.1锛夛紝濡傛灉client涓庢湇鍔′笉鍦ㄥ悓涓�鍙版湇鍔″櫒锛岄渶瑕佹敼涓洪儴缃叉満鍣╥p +--port 10095 閮ㄧ讲绔彛鍙� +--wav-path 闇�瑕佽繘琛岃浆鍐欑殑闊抽鏂囦欢锛屾敮鎸佹枃浠惰矾寰� +--thread_num 璁剧疆骞跺彂鍙戦�佺嚎绋嬫暟锛岄粯璁や负1 +--ssl 璁剧疆鏄惁寮�鍚痵sl璇佷功鏍¢獙锛岄粯璁�1寮�鍚紝璁剧疆涓�0鍏抽棴 +--hotword 濡傛灉妯″瀷涓虹儹璇嶆ā鍨嬶紝鍙互璁剧疆鐑瘝: *.txt(姣忚涓�涓儹璇�) 鎴栬�呯┖鏍煎垎闅旂殑鐑瘝瀛楃涓� (could be: 闃块噷宸村反 杈炬懇闄�) +``` -[//]: # (/root/funasr_samples/cpp/funasr-wss-client --server-ip 127.0.0.1 --port 10095 --wav-path /root/funasr_samples/audio/asr_example.wav) +### html-client -[//]: # (```) +鍦ㄦ祻瑙堝櫒涓墦寮� html/static/index.html锛屽嵆鍙嚭鐜板涓嬮〉闈紝鏀寔楹﹀厠椋庤緭鍏ヤ笌鏂囦欢涓婁紶锛岀洿鎺ヨ繘琛屼綋楠� -[//]: # () -[//]: # (鍛戒护鍙傛暟璇存槑锛�) +<img src="images/html.png" width="900"/> -[//]: # () -[//]: # (```text) +### java-client -[//]: # (--server-ip 涓篎unASR runtime-SDK鏈嶅姟閮ㄧ讲鏈哄櫒ip锛岄粯璁や负鏈満ip锛�127.0.0.1锛夛紝濡傛灉client涓庢湇鍔′笉鍦ㄥ悓涓�鍙版湇鍔″櫒锛岄渶瑕佹敼涓洪儴缃叉満鍣╥p) - -[//]: # (--port 10095 閮ㄧ讲绔彛鍙�) - -[//]: # (--wav-path 闇�瑕佽繘琛岃浆鍐欑殑闊抽鏂囦欢锛屾敮鎸佹枃浠惰矾寰�) - -[//]: # (```) +```shell +FunasrWsClient --host localhost --port 10095 --audio_in ./asr_example.wav --mode offline +``` +璇︾粏鍙互鍙傝�冩枃妗o紙[鐐瑰嚮姝ゅ](../java/readme.md)锛� ## 鏈嶅姟绔敤娉曡瑙� @@ -92,20 +113,27 @@ 涓�閿儴缃插悗鑻ュ嚭鐜伴噸鍚數鑴戠瓑鍏抽棴Docker鐨勫姩浣滐紝鍙�氳繃濡備笅鍛戒护鐩存帴鍚姩FunASR鏈嶅姟锛屽惎鍔ㄩ厤缃负涓婃涓�閿儴缃茬殑璁剧疆銆� ```shell -sudo bash funasr-runtime-deploy.sh start +sudo bash funasr-runtime-deploy-offline-cpu-zh.sh start ``` ### 鍏抽棴FunASR鏈嶅姟 ```shell -sudo bash funasr-runtime-deploy.sh stop +sudo bash funasr-runtime-deploy-offline-cpu-zh.sh stop +``` + +### 閲婃斁FunASR鏈嶅姟 + +閲婃斁宸茬粡閮ㄧ讲鐨凢unASR鏈嶅姟銆� +```shell +sudo bash funasr-runtime-deploy-offline-cpu-zh.sh remove ``` ### 閲嶅惎FunASR鏈嶅姟 鏍规嵁涓婃涓�閿儴缃茬殑璁剧疆閲嶅惎鍚姩FunASR鏈嶅姟銆� ```shell -sudo bash funasr-runtime-deploy.sh restart +sudo bash funasr-runtime-deploy-offline-cpu-zh.sh restart ``` ### 鏇挎崲妯″瀷骞堕噸鍚疐unASR鏈嶅姟 @@ -113,50 +141,43 @@ 鏇挎崲姝e湪浣跨敤鐨勬ā鍨嬶紝骞堕噸鏂板惎鍔‵unASR鏈嶅姟銆傛ā鍨嬮渶涓篗odelScope涓殑ASR/VAD/PUNC妯″瀷锛屾垨鑰呬粠ModelScope涓ā鍨媐inetune鍚庣殑妯″瀷銆� ```shell -sudo bash funasr-runtime-deploy.sh update model <model ID> +sudo bash funasr-runtime-deploy-offline-cpu-zh.sh update [--asr_model | --vad_model | --punc_model] <model_id or local model path> e.g -sudo bash funasr-runtime-deploy.sh update model damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch +sudo bash funasr-runtime-deploy-offline-cpu-zh.sh update --asr_model damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch +``` + +### 鏇存柊鍙傛暟骞堕噸鍚疐unASR鏈嶅姟 + +鏇存柊宸查厤缃弬鏁帮紝骞堕噸鏂板惎鍔‵unASR鏈嶅姟鐢熸晥銆傚彲鏇存柊鍙傛暟鍖呮嫭瀹夸富鏈哄拰Docker鐨勭鍙e彿锛屼互鍙婃帹鐞嗗拰IO鐨勭嚎绋嬫暟閲忋�� + +```shell +sudo bash funasr-runtime-deploy-offline-cpu-zh.sh update [--host_port | --docker_port] <port number> +sudo bash funasr-runtime-deploy-offline-cpu-zh.sh update [--decode_thread_num | --io_thread_num] <the number of threads> +sudo bash funasr-runtime-deploy-offline-cpu-zh.sh update [--workspace] <workspace in local> +sudo bash funasr-runtime-deploy-offline-cpu-zh.sh update [--ssl] <0: close SSL; 1: open SSL, default:1> + +e.g +sudo bash funasr-runtime-deploy-offline-cpu-zh.sh update --decode_thread_num 32 +sudo bash funasr-runtime-deploy-offline-cpu-zh.sh update --workspace /root/funasr-runtime-resources +``` + +### 鍏抽棴SSL璇佷功 + +```shell +sudo bash funasr-runtime-deploy-online-cpu-zh.sh update --ssl 0 ``` -## 鏈嶅姟绔惎鍔ㄨ繃绋嬮厤缃瑙� -##### 閫夋嫨FunASR Docker闀滃儚 -鎺ㄨ崘閫夋嫨latest浣跨敤鎴戜滑鐨勬渶鏂伴暅鍍忥紝涔熷彲閫夋嫨鍘嗗彶鐗堟湰銆� -```text -[1/9] - Please choose the Docker image. - 1) registry.cn-hangzhou.aliyuncs.com/funasr_repo/funasr:funasr-runtime-sdk-cpu-latest - 2) registry.cn-hangzhou.aliyuncs.com/funasr_repo/funasr:funasr-runtime-sdk-cpu-0.1.0 - Enter your choice: 1 - You have chosen the Docker image: registry.cn-hangzhou.aliyuncs.com/funasr_repo/funasr:funasr-runtime-sdk-cpu-latest -``` +## 鑱旂郴鎴戜滑 + +鍦ㄦ偍浣跨敤杩囩▼涓紝濡傛灉閬囧埌闂锛屾杩庡姞鍏ョ敤鎴风兢杩涜鍙嶉 -##### 璁剧疆瀹夸富鏈烘彁渚涚粰FunASR鐨勭鍙� -璁剧疆鎻愪緵缁橠ocker鐨勫涓绘満绔彛锛岄粯璁や负10095銆傝淇濊瘉姝ょ鍙e彲鐢ㄣ�� -```text -[4/9] - Please input the opened port in the host used for FunASR server. - Default: 10095 - Setting the opened host port [1-65535]: - The port of the host is 10095 - The port in Docker for FunASR server is 10095 -``` - - -##### 璁剧疆FunASR鏈嶅姟鐨勬帹鐞嗙嚎绋嬫暟 -璁剧疆FunASR鏈嶅姟鐨勬帹鐞嗙嚎绋嬫暟锛岄粯璁や负瀹夸富鏈烘牳鏁帮紝鍚屾椂鑷姩璁剧疆鏈嶅姟鐨処O绾跨▼鏁帮紝涓烘帹鐞嗙嚎绋嬫暟鐨勫洓鍒嗕箣涓�銆� -```text -[5/9] - Please input thread number for FunASR decoder. - Default: 1 - Setting the number of decoder thread: - - The number of decoder threads is 1 - The number of IO threads is 1 -``` +| 閽夐拤鐢ㄦ埛缇� | 寰俊 | +|:----------------------------------------------------------------------------:|:-----------------------------------------------------:| +| <div align="left"><img src="../../../docs/images/dingding.jpg" width="250"/> | <img src="../../../docs/images/wechat.png" width="232"/></div> | ## 瑙嗛demo -- Gitblit v1.9.1