|
|
|
@ -110,21 +110,22 @@ wget -c https://paddlespeech.bj.bcebos.com/PaddleAudio/zh.wav https://paddlespee
|
|
|
|
|
- Python API
|
|
|
|
|
```python
|
|
|
|
|
from paddlespeech.server.bin.paddlespeech_client import ASRClientExecutor
|
|
|
|
|
import json
|
|
|
|
|
|
|
|
|
|
asrclient_executor = ASRClientExecutor()
|
|
|
|
|
asrclient_executor(
|
|
|
|
|
res = asrclient_executor(
|
|
|
|
|
input="./zh.wav",
|
|
|
|
|
server_ip="127.0.0.1",
|
|
|
|
|
port=8090,
|
|
|
|
|
sample_rate=16000,
|
|
|
|
|
lang="zh_cn",
|
|
|
|
|
audio_format="wav")
|
|
|
|
|
print(res.json())
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Output:
|
|
|
|
|
```bash
|
|
|
|
|
{'success': True, 'code': 200, 'message': {'description': 'success'}, 'result': {'transcription': '我认为跑步最重要的就是给我带来了身体健康'}}
|
|
|
|
|
time cost 0.604353 s.
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### 5. TTS Client Usage
|
|
|
|
@ -146,7 +147,7 @@ wget -c https://paddlespeech.bj.bcebos.com/PaddleAudio/zh.wav https://paddlespee
|
|
|
|
|
- `speed`: Audio speed, the value should be set between 0 and 3. Default: 1.0
|
|
|
|
|
- `volume`: Audio volume, the value should be set between 0 and 3. Default: 1.0
|
|
|
|
|
- `sample_rate`: Sampling rate, choice: [0, 8000, 16000], the default is the same as the model. Default: 0
|
|
|
|
|
- `output`: Output wave filepath. Default: `output.wav`.
|
|
|
|
|
- `output`: Output wave filepath. Default: None, which means not to save the audio to the local.
|
|
|
|
|
|
|
|
|
|
Output:
|
|
|
|
|
```bash
|
|
|
|
@ -160,9 +161,10 @@ wget -c https://paddlespeech.bj.bcebos.com/PaddleAudio/zh.wav https://paddlespee
|
|
|
|
|
- Python API
|
|
|
|
|
```python
|
|
|
|
|
from paddlespeech.server.bin.paddlespeech_client import TTSClientExecutor
|
|
|
|
|
import json
|
|
|
|
|
|
|
|
|
|
ttsclient_executor = TTSClientExecutor()
|
|
|
|
|
ttsclient_executor(
|
|
|
|
|
res = ttsclient_executor(
|
|
|
|
|
input="您好,欢迎使用百度飞桨语音合成服务。",
|
|
|
|
|
server_ip="127.0.0.1",
|
|
|
|
|
port=8090,
|
|
|
|
@ -171,6 +173,11 @@ wget -c https://paddlespeech.bj.bcebos.com/PaddleAudio/zh.wav https://paddlespee
|
|
|
|
|
volume=1.0,
|
|
|
|
|
sample_rate=0,
|
|
|
|
|
output="./output.wav")
|
|
|
|
|
|
|
|
|
|
response_dict = res.json()
|
|
|
|
|
print(response_dict["message"])
|
|
|
|
|
print("Save synthesized audio successfully on %s." % (response_dict['result']['save_path']))
|
|
|
|
|
print("Audio duration: %f s." %(response_dict['result']['duration']))
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Output:
|
|
|
|
@ -178,7 +185,6 @@ wget -c https://paddlespeech.bj.bcebos.com/PaddleAudio/zh.wav https://paddlespee
|
|
|
|
|
{'description': 'success.'}
|
|
|
|
|
Save synthesized audio successfully on ./output.wav.
|
|
|
|
|
Audio duration: 3.612500 s.
|
|
|
|
|
Response time: 0.388317 s.
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
@ -211,20 +217,20 @@ wget -c https://paddlespeech.bj.bcebos.com/PaddleAudio/zh.wav https://paddlespee
|
|
|
|
|
- Python API
|
|
|
|
|
```python
|
|
|
|
|
from paddlespeech.server.bin.paddlespeech_client import CLSClientExecutor
|
|
|
|
|
import json
|
|
|
|
|
|
|
|
|
|
clsclient_executor = CLSClientExecutor()
|
|
|
|
|
clsclient_executor(
|
|
|
|
|
res = clsclient_executor(
|
|
|
|
|
input="./zh.wav",
|
|
|
|
|
server_ip="127.0.0.1",
|
|
|
|
|
port=8090,
|
|
|
|
|
topk=1)
|
|
|
|
|
|
|
|
|
|
print(res.jaon())
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Output:
|
|
|
|
|
```bash
|
|
|
|
|
{'success': True, 'code': 200, 'message': {'description': 'success'}, 'result': {'topk': 1, 'results': [{'class_name': 'Speech', 'prob': 0.9027184844017029}]}}
|
|
|
|
|
Response time 0.150897 s.
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|