modify server demo, test=doc

pull/1554/head
lym0302 3 years ago
parent 89bc3ba4fa
commit 5187df847f

@ -182,6 +182,52 @@ wget -c https://paddlespeech.bj.bcebos.com/PaddleAudio/zh.wav https://paddlespee
``` ```
### 6. CLS Client Usage
**Note:** The response time will be slightly longer when using the client for the first time
- Command Line (Recommended)
```
paddlespeech_client cls --server_ip 127.0.0.1 --port 8090 --input ./zh.wav
```
Usage:
```bash
paddlespeech_client cls --help
```
Arguments:
- `server_ip`: server ip. Default: 127.0.0.1
- `port`: server port. Default: 8090
- `input`(required): Audio file to be classified.
- `topk`: topk scores of classification result.
Output:
```bash
[2022-03-09 20:44:39,974] [ INFO] - {'success': True, 'code': 200, 'message': {'description': 'success'}, 'result': {'topk': 1, 'results': [{'class_name': 'Speech', 'prob': 0.9027184844017029}]}}
[2022-03-09 20:44:39,975] [ INFO] - Response time 0.104360 s.
```
- Python API
```python
from paddlespeech.server.bin.paddlespeech_client import CLSClientExecutor
clsclient_executor = CLSClientExecutor()
clsclient_executor(
input="./zh.wav",
server_ip="127.0.0.1",
port=8090,
topk=1)
```
Output:
```bash
{'success': True, 'code': 200, 'message': {'description': 'success'}, 'result': {'topk': 1, 'results': [{'class_name': 'Speech', 'prob': 0.9027184844017029}]}}
Response time 0.150897 s.
```
## Models supported by the service ## Models supported by the service
### ASR model ### ASR model
@ -189,3 +235,6 @@ Get all models supported by the ASR service via `paddlespeech_server stats --tas
### TTS model ### TTS model
Get all models supported by the TTS service via `paddlespeech_server stats --task tts`, where static models can be used for paddle inference inference. Get all models supported by the TTS service via `paddlespeech_server stats --task tts`, where static models can be used for paddle inference inference.
### CLS model
Get all models supported by the CLS service via `paddlespeech_server stats --task cls`, where static models can be used for paddle inference inference.

@ -80,7 +80,7 @@ wget -c https://paddlespeech.bj.bcebos.com/PaddleAudio/zh.wav https://paddlespee
``` ```
### 4. ASR客户端使用方法 ### 4. ASR 客户端使用方法
**注意:** 初次使用客户端时响应时间会略长 **注意:** 初次使用客户端时响应时间会略长
- 命令行 (推荐使用) - 命令行 (推荐使用)
``` ```
@ -129,7 +129,7 @@ wget -c https://paddlespeech.bj.bcebos.com/PaddleAudio/zh.wav https://paddlespee
``` ```
### 5. TTS客户端使用方法 ### 5. TTS 客户端使用方法
**注意:** 初次使用客户端时响应时间会略长 **注意:** 初次使用客户端时响应时间会略长
- 命令行 (推荐使用) - 命令行 (推荐使用)
@ -185,9 +185,59 @@ wget -c https://paddlespeech.bj.bcebos.com/PaddleAudio/zh.wav https://paddlespee
``` ```
### 5. CLS 客户端使用方法
**注意:** 初次使用客户端时响应时间会略长
- 命令行 (推荐使用)
```
paddlespeech_client cls --server_ip 127.0.0.1 --port 8090 --input ./zh.wav
```
使用帮助:
```bash
paddlespeech_client cls --help
```
参数:
- `server_ip`: 服务端ip地址默认: 127.0.0.1。
- `port`: 服务端口,默认: 8090。
- `input`(必须输入): 用于分类的音频文件。
- `topk`: 分类结果的topk。
输出:
```bash
[2022-03-09 20:44:39,974] [ INFO] - {'success': True, 'code': 200, 'message': {'description': 'success'}, 'result': {'topk': 1, 'results': [{'class_name': 'Speech', 'prob': 0.9027184844017029}]}}
[2022-03-09 20:44:39,975] [ INFO] - Response time 0.104360 s.
```
- Python API
```python
from paddlespeech.server.bin.paddlespeech_client import CLSClientExecutor
clsclient_executor = CLSClientExecutor()
clsclient_executor(
input="./zh.wav",
server_ip="127.0.0.1",
port=8090,
topk=1)
```
输出:
```bash
{'success': True, 'code': 200, 'message': {'description': 'success'}, 'result': {'topk': 1, 'results': [{'class_name': 'Speech', 'prob': 0.9027184844017029}]}}
Response time 0.150897 s.
```
## 服务支持的模型 ## 服务支持的模型
### ASR支持的模型 ### ASR支持的模型
通过 `paddlespeech_server stats --task asr` 获取ASR服务支持的所有模型其中静态模型可用于 paddle inference 推理。 通过 `paddlespeech_server stats --task asr` 获取ASR服务支持的所有模型其中静态模型可用于 paddle inference 推理。
### TTS支持的模型 ### TTS支持的模型
通过 `paddlespeech_server stats --task tts` 获取TTS服务支持的所有模型其中静态模型可用于 paddle inference 推理。 通过 `paddlespeech_server stats --task tts` 获取TTS服务支持的所有模型其中静态模型可用于 paddle inference 推理。
### CLS支持的模型
通过 `paddlespeech_server stats --task cls` 获取CLS服务支持的所有模型其中静态模型可用于 paddle inference 推理。

@ -103,13 +103,14 @@ class ServerStatsExecutor():
'--task', '--task',
type=str, type=str,
default=None, default=None,
choices=['asr', 'tts'], choices=['asr', 'tts', 'cls'],
help='Choose speech task.', help='Choose speech task.',
required=True) required=True)
self.task_choices = ['asr', 'tts'] self.task_choices = ['asr', 'tts', 'cls']
self.model_name_format = { self.model_name_format = {
'asr': 'Model-Language-Sample Rate', 'asr': 'Model-Language-Sample Rate',
'tts': 'Model-Language' 'tts': 'Model-Language',
'cls': 'Model-Sample Rate'
} }
def show_support_models(self, pretrained_models: dict): def show_support_models(self, pretrained_models: dict):
@ -174,53 +175,24 @@ class ServerStatsExecutor():
) )
return False return False
@stats_wrapper elif self.task == 'cls':
def __call__(
self,
task: str=None, ):
"""
Python API to call an executor.
"""
self.task = task
if self.task not in self.task_choices:
print("Please input correct speech task, choices = ['asr', 'tts']")
elif self.task == 'asr':
try: try:
from paddlespeech.cli.asr.infer import pretrained_models from paddlespeech.cli.cls.infer import pretrained_models
print( logger.info(
"Here is the table of ASR pretrained models supported in the service." "Here is the table of CLS pretrained models supported in the service."
)
self.show_support_models(pretrained_models)
# show ASR static pretrained model
from paddlespeech.server.engine.asr.paddleinference.asr_engine import pretrained_models
print(
"Here is the table of ASR static pretrained models supported in the service."
)
self.show_support_models(pretrained_models)
except BaseException:
print(
"Failed to get the table of ASR pretrained models supported in the service."
)
elif self.task == 'tts':
try:
from paddlespeech.cli.tts.infer import pretrained_models
print(
"Here is the table of TTS pretrained models supported in the service."
) )
self.show_support_models(pretrained_models) self.show_support_models(pretrained_models)
# show TTS static pretrained model # show CLS static pretrained model
from paddlespeech.server.engine.tts.paddleinference.tts_engine import pretrained_models from paddlespeech.server.engine.cls.paddleinference.cls_engine import pretrained_models
print( logger.info(
"Here is the table of TTS static pretrained models supported in the service." "Here is the table of CLS static pretrained models supported in the service."
) )
self.show_support_models(pretrained_models) self.show_support_models(pretrained_models)
return True
except BaseException: except BaseException:
print( logger.error(
"Failed to get the table of TTS pretrained models supported in the service." "Failed to get the table of CLS pretrained models supported in the service."
) )
return False

Loading…
Cancel
Save