Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
b508c4d0
D
DeepSpeech
项目概览
PaddlePaddle
/
DeepSpeech
大约 1 年 前同步成功
通知
206
Star
8425
Fork
1598
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
245
列表
看板
标记
里程碑
合并请求
3
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
DeepSpeech
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
245
Issue
245
列表
看板
标记
里程碑
合并请求
3
合并请求
3
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b508c4d0
编写于
2月 22, 2022
作者:
L
lym0302
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add readme, test=doc
上级
42cbe313
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
122 addition
and
12 deletion
+122
-12
paddlespeech/server/README.md
paddlespeech/server/README.md
+33
-0
paddlespeech/server/README_cn.md
paddlespeech/server/README_cn.md
+32
-0
paddlespeech/server/bin/paddlespeech_client.py
paddlespeech/server/bin/paddlespeech_client.py
+16
-10
paddlespeech/server/bin/paddlespeech_server.py
paddlespeech/server/bin/paddlespeech_server.py
+3
-2
paddlespeech/server/executor.py
paddlespeech/server/executor.py
+38
-0
未找到文件。
paddlespeech/server/README.md
0 → 100644
浏览文件 @
b508c4d0
# PaddleSpeech Server Command Line
(
[
简体中文
](
./README_cn.md
)
|English)
The simplest approach to use PaddleSpeech Server including server and client.
## PaddleSpeech Server
### Help
```
bash
paddlespeech_server
help
```
### Start the server
First set the service-related configuration parameters, similar to
`./conf/application.yaml`
,
Then start the service:
```
bash
paddlespeech_server start
--config_file
./conf/application.yaml
```
## PaddleSpeech Client
### Help
```
bash
paddlespeech_client
help
```
### Access speech recognition services
```
paddlespeech_client asr --server_ip 127.0.0.1 --port 8090 --input ./tests/16_audio.wav
```
### Access text to speech services
```
bash
paddlespeech_client tts
--server_ip
127.0.0.1
--port
8090
--input
"你好,欢迎使用百度飞桨深度学习框架!"
--output
output.wav
```
paddlespeech/server/README_cn.md
0 → 100644
浏览文件 @
b508c4d0
# PaddleSpeech Server 命令行工具
(简体中文|
[
English
](
./README.md
)
)
它提供了最简便的方式调用 PaddleSpeech 语音服务用一行命令就可以轻松启动服务和调用服务。
## 服务端命令行使用
### 帮助
```
bash
paddlespeech_server
help
```
### 启动服务
首先设置服务相关配置文件,类似于
`./conf/application.yaml`
,同时设置服务配置中的语音任务模型相关配置,类似于
`./conf/tts/tts.yaml`
。
然后启动服务:
```
bash
paddlespeech_server start
--config_file
./conf/application.yaml
```
## 客户端命令行使用
### 帮助
```
bash
paddlespeech_client
help
```
### 访问语音识别服务
```
paddlespeech_client asr --server_ip 127.0.0.1 --port 8090 --input input_16k.wav
```
### 访问语音合成服务
```
bash
paddlespeech_client tts
--server_ip
127.0.0.1
--port
8090
--input
"你好,欢迎使用百度飞桨深度学习框架!"
--output
output.wav
```
paddlespeech/server/bin/paddlespeech_client.py
浏览文件 @
b508c4d0
...
...
@@ -24,6 +24,7 @@ import numpy as np
import
requests
import
soundfile
from
..executor
import
BaseExecutor
from
..util
import
cli_client_register
from
paddlespeech.server.utils.audio_process
import
wav2pcm
from
paddlespeech.server.utils.util
import
wav2base64
...
...
@@ -33,7 +34,7 @@ __all__ = ['TTSClientExecutor', 'ASRClientExecutor']
@
cli_client_register
(
name
=
'paddlespeech_client.tts'
,
description
=
'visit tts service'
)
class
TTSClientExecutor
():
class
TTSClientExecutor
(
BaseExecutor
):
def
__init__
(
self
):
super
().
__init__
()
self
.
parser
=
argparse
.
ArgumentParser
()
...
...
@@ -42,7 +43,7 @@ class TTSClientExecutor():
self
.
parser
.
add_argument
(
'--port'
,
type
=
int
,
default
=
8090
,
help
=
'server port'
)
self
.
parser
.
add_argument
(
'--
tex
t'
,
'--
inpu
t'
,
type
=
str
,
default
=
"你好,欢迎使用语音合成服务"
,
help
=
'A sentence to be synthesized'
)
...
...
@@ -60,20 +61,20 @@ class TTSClientExecutor():
self
.
parser
.
add_argument
(
'--output'
,
type
=
str
,
default
=
"./out.wav"
,
default
=
"./out
put
.wav"
,
help
=
'Synthesized audio file'
)
# Request and response
def
tts_client
(
self
,
args
):
""" Request and response
Args:
tex
t: A sentence to be synthesized
inpu
t: A sentence to be synthesized
outfile: Synthetic audio file
"""
url
=
'http://'
+
args
.
server_ip
+
":"
+
str
(
args
.
port
)
+
'/paddlespeech/tts'
request
=
{
"text"
:
args
.
tex
t
,
"text"
:
args
.
inpu
t
,
"spk_id"
:
args
.
spk_id
,
"speed"
:
args
.
speed
,
"volume"
:
args
.
volume
,
...
...
@@ -119,7 +120,7 @@ class TTSClientExecutor():
@
cli_client_register
(
name
=
'paddlespeech_client.asr'
,
description
=
'visit asr service'
)
class
ASRClientExecutor
():
class
ASRClientExecutor
(
BaseExecutor
):
def
__init__
(
self
):
super
().
__init__
()
self
.
parser
=
argparse
.
ArgumentParser
()
...
...
@@ -128,29 +129,34 @@ class ASRClientExecutor():
self
.
parser
.
add_argument
(
'--port'
,
type
=
int
,
default
=
8090
,
help
=
'server port'
)
self
.
parser
.
add_argument
(
'--
audio_file
'
,
'--
input
'
,
type
=
str
,
default
=
"./paddlespeech/server/tests/16_audio.wav"
,
help
=
'Audio file to be recognized'
)
self
.
parser
.
add_argument
(
'--sample_rate'
,
type
=
int
,
default
=
16000
,
help
=
'audio sample rate'
)
self
.
parser
.
add_argument
(
'--lang'
,
type
=
str
,
default
=
"zh_cn"
,
help
=
'language'
)
self
.
parser
.
add_argument
(
'--audio_format'
,
type
=
str
,
default
=
"wav"
,
help
=
'audio format'
)
def
execute
(
self
,
argv
:
List
[
str
])
->
bool
:
args
=
self
.
parser
.
parse_args
(
argv
)
url
=
'http://'
+
args
.
server_ip
+
":"
+
str
(
args
.
port
)
+
'/paddlespeech/asr'
audio
=
wav2base64
(
args
.
audio_file
)
audio
=
wav2base64
(
args
.
input
)
data
=
{
"audio"
:
audio
,
"audio_format"
:
"wav"
,
"audio_format"
:
args
.
audio_format
,
"sample_rate"
:
args
.
sample_rate
,
"lang"
:
"zh_cn"
,
"lang"
:
args
.
lang
,
}
time_start
=
time
.
time
()
try
:
r
=
requests
.
post
(
url
=
url
,
data
=
json
.
dumps
(
data
))
# ending Timestamp
time_end
=
time
.
time
()
print
(
r
.
json
())
print
(
'time cost'
,
time_end
-
time_start
,
's'
)
except
:
print
(
"Failed to speech recognition."
)
paddlespeech/server/bin/paddlespeech_server.py
浏览文件 @
b508c4d0
...
...
@@ -17,6 +17,7 @@ from typing import List
import
uvicorn
from
fastapi
import
FastAPI
from
..executor
import
BaseExecutor
from
..util
import
cli_server_register
from
paddlespeech.server.engine.engine_factory
import
EngineFactory
from
paddlespeech.server.restful.api
import
setup_router
...
...
@@ -29,8 +30,8 @@ app = FastAPI(
@
cli_server_register
(
name
=
'paddlespeech_server.s
erver
'
,
description
=
'Start the service'
)
class
ServerExecutor
():
name
=
'paddlespeech_server.s
tart
'
,
description
=
'Start the service'
)
class
ServerExecutor
(
BaseExecutor
):
def
__init__
(
self
):
super
().
__init__
()
self
.
parser
=
argparse
.
ArgumentParser
()
...
...
paddlespeech/server/executor.py
0 → 100644
浏览文件 @
b508c4d0
# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import
argparse
from
abc
import
ABC
from
abc
import
abstractmethod
from
typing
import
List
class
BaseExecutor
(
ABC
):
"""
An abstract executor of paddlespeech server tasks.
"""
def
__init__
(
self
):
self
.
parser
=
argparse
.
ArgumentParser
()
@
abstractmethod
def
execute
(
self
,
argv
:
List
[
str
])
->
bool
:
"""
Command line entry. This method can only be accessed by a command line such as `paddlespeech asr`.
Args:
argv (List[str]): Arguments from command line.
Returns:
int: Result of the command execution. `True` for a success and `False` for a failure.
"""
pass
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录