Xian Shi
2023-08-10 e2b3edec45fe1bfd76493acc366df971e89e7ae2
funasr/runtime/docs/SDK_tutorial_online_zh.md
@@ -1,9 +1,9 @@
(简体中文|[English](./SDK_tutorial_online.md))
# FunASR实时语音转写便捷部署教程
# FunASR实时语音听写便捷部署教程
FunASR提供可便捷本地或者云端服务器部署的实时语音转写服务,内核为FunASR已开源runtime-SDK。
集成了达摩院语音实验室在Modelscope社区开源的语音端点检测(VAD)、Paraformer-large非流式语音识别(ASR)、Paraformer-large流式语音识别(ASR)、标点恢复(PUNC) 等相关能力。软件包既可以实时地进行语音转文字,而且能够在说话句尾用高精度的转写文字修正输出,输出文字带有标点,支持高并发多路请求
FunASR提供可便捷本地或者云端服务器部署的实时语音听写服务,内核为FunASR已开源的runtime-SDK。
FunASR集成了达摩院语音实验室在Modelscope社区开源的语音端点检测(VAD)、Paraformer-large非流式语音识别(ASR)、Paraformer-large流式语音识别(ASR)、标点预测(PUNC) 等相关能力。软件包既可以实时地进行语音转文字,而且能够在说话句尾用高精度的转写文字修正输出,输出文字带有标点,支持高并发多路请求
## 服务器配置
@@ -46,16 +46,16 @@
## 客户端用法详解
在服务器上完成FunASR服务部署以后,可以通过如下的步骤来测试和使用实时语音转写服务。
在服务器上完成FunASR服务部署以后,可以通过如下的步骤来测试和使用实时语音听写服务。
目前分别支持以下几种编程语言客户端
- [Python](#python-client)
- [CPP](#cpp-client)
- [html](#html-client)
- [java](#java-client)
- [c#](#c#)
- [c\#](#c\#)
更多版本客户端支持请参考[开发指南](./SDK_advanced_guide_offline_zh.md)
更多版本客户端支持请参考[websocket/grpc协议](./websocket_protocol_zh.md)
### python-client
若想直接运行client进行测试,可参考如下简易说明,以python版本为例:
@@ -68,8 +68,8 @@
```text
--host 为FunASR runtime-SDK服务部署机器ip,默认为本机ip(127.0.0.1),如果client与服务不在同一台服务器,需要改为部署机器ip
--port 10095 部署端口号
--mode:`offline`,表示推理模式为一句话识别;`online`,表示推理模式为实时语音识别;`2pass`:表示为实时语音识别,并且说话句尾采用离线模型进行纠错。
--chunk_size:表示流式模型latency配置,`[5,10,5]`,表示当前音频为600ms,并且回看300ms,又看300ms。
--mode:`offline`表示推理模式为一句话识别;`online`表示推理模式为实时语音识别;`2pass`表示为实时语音识别,并且说话句尾采用离线模型进行纠错。
--chunk_size:表示流式模型latency配置`[5,10,5]`,表示当前音频解码片段为600ms,并且回看300ms,右看300ms。
--audio_in 需要进行转写的音频文件,支持文件路径,文件列表wav.scp
--thread_num 设置并发发送线程数,默认为1
--ssl 设置是否开启ssl证书校验,默认1开启,设置为0关闭
@@ -78,7 +78,7 @@
### cpp-client
进入samples/cpp目录后,可以用cpp进行测试,指令如下:
```shell
./funasr-wss-client --server-ip 127.0.0.1 --port 10095 --mode 2pass
./funasr-wss-client-2pass --server-ip 127.0.0.1 --port 10095 --mode 2pass
```
命令参数说明:
@@ -86,11 +86,11 @@
```text
--server-ip 为FunASR runtime-SDK服务部署机器ip,默认为本机ip(127.0.0.1),如果client与服务不在同一台服务器,需要改为部署机器ip
--port 10095 部署端口号
--mode:`offline`,表示推理模式为一句话识别;`online`,表示推理模式为实时语音识别;`2pass`:表示为实时语音识别,并且说话句尾采用离线模型进行纠错。
--chunk_size:表示流式模型latency配置,`[5,10,5]`,表示当前音频为600ms,并且回看300ms,又看300ms。
--mode:`offline`表示推理模式为一句话识别;`online`表示推理模式为实时语音识别;`2pass`表示为实时语音识别,并且说话句尾采用离线模型进行纠错。
--chunk-size:表示流式模型latency配置`[5,10,5]`,表示当前音频解码片段为600ms,并且回看300ms,右看300ms。
--wav-path 需要进行转写的音频文件,支持文件路径
--thread_num 设置并发发送线程数,默认为1
--ssl 设置是否开启ssl证书校验,默认1开启,设置为0关闭
--thread-num 设置并发发送线程数,默认为1
--is-ssl 设置是否开启ssl证书校验,默认1开启,设置为0关闭
```
### html-client
@@ -112,27 +112,29 @@
一键部署后若出现重启电脑等关闭Docker的动作,可通过如下命令直接启动FunASR服务,启动配置为上次一键部署的设置。
```shell
sudo bash funasr-runtime-deploy-offline-cpu-zh.sh start
sudo bash funasr-runtime-deploy-online-cpu-zh.sh start
```
### 关闭FunASR服务
```shell
sudo bash funasr-runtime-deploy-offline-cpu-zh.sh stop
sudo bash funasr-runtime-deploy-online-cpu-zh.sh stop
```
### 释放FunASR服务
释放已经部署的FunASR服务。
```shell
sudo bash funasr-runtime-deploy-offline-cpu-zh.sh remove
sudo bash funasr-runtime-deploy-online-cpu-zh.sh remove
```
### 重启FunASR服务
根据上次一键部署的设置重启启动FunASR服务。
```shell
sudo bash funasr-runtime-deploy-offline-cpu-zh.sh restart
sudo bash funasr-runtime-deploy-online-cpu-zh.sh restart
```
### 替换模型并重启FunASR服务
@@ -140,10 +142,10 @@
替换正在使用的模型,并重新启动FunASR服务。模型需为ModelScope中的ASR/VAD/PUNC模型,或者从ModelScope中模型finetune后的模型。
```shell
sudo bash funasr-runtime-deploy-offline-cpu-zh.sh update [--asr_model | --vad_model | --punc_model] <model_id or local model path>
sudo bash funasr-runtime-deploy-online-cpu-zh.sh update [--asr_model | --vad_model | --punc_model] <model_id or local model path>
e.g
sudo bash funasr-runtime-deploy-offline-cpu-zh.sh update --asr_model damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch
sudo bash funasr-runtime-deploy-online-cpu-zh.sh update --asr_model damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch
```
### 更新参数并重启FunASR服务
@@ -151,48 +153,20 @@
更新已配置参数,并重新启动FunASR服务生效。可更新参数包括宿主机和Docker的端口号,以及推理和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>
sudo bash funasr-runtime-deploy-online-cpu-zh.sh update [--host_port | --docker_port] <port number>
sudo bash funasr-runtime-deploy-online-cpu-zh.sh update [--decode_thread_num | --io_thread_num] <the number of threads>
sudo bash funasr-runtime-deploy-online-cpu-zh.sh update [--workspace] <workspace in local>
sudo bash funasr-runtime-deploy-online-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
sudo bash funasr-runtime-deploy-online-cpu-zh.sh update --decode_thread_num 32
sudo bash funasr-runtime-deploy-online-cpu-zh.sh update --workspace ./funasr-runtime-resources
```
### 关闭SSL证书
## 服务端启动过程配置详解
### 选择FunASR Docker镜像
推荐选择1)使用我们的最新发布版镜像,也可选择历史版本。
```text
[1/5]
  Getting the list of docker images, please wait a few seconds.
    [DONE]
  Please choose the Docker image.
    1) registry.cn-hangzhou.aliyuncs.com/funasr_repo/funasr:funasr-runtime-sdk-cpu-0.1.0
  Enter your choice, default(1):
  You have chosen the Docker image: registry.cn-hangzhou.aliyuncs.com/funasr_repo/funasr:funasr-runtime-sdk-cpu-0.1.0
```
### 设置宿主机提供给FunASR的端口
设置提供给Docker的宿主机端口,默认为10095。请保证此端口可用。
```text
[2/5]
  Please input the opened port in the host used for FunASR server.
  Setting the opened host port [1-65535], default(10095):
  The port of the host is 10095
  The port in Docker for FunASR server is 10095
```
### 设置SSL
默认开启SSL校验,如果需要关闭,可以在启动时设置
```shell
sudo bash funasr-runtime-deploy-offline-cpu-zh.sh --ssl 0
sudo bash funasr-runtime-deploy-online-cpu-zh.sh update --ssl 0
```
## 联系我们