Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
6b2dd168
D
DeepSpeech
项目概览
PaddlePaddle
/
DeepSpeech
1 年多 前同步成功
通知
207
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看板
提交
6b2dd168
编写于
2月 24, 2022
作者:
L
lym0302
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update server cli, test=doc
上级
fe350ddd
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
115 addition
and
77 deletion
+115
-77
demos/speech_server/conf/application.yaml
demos/speech_server/conf/application.yaml
+12
-4
demos/speech_server/conf/asr/asr.yaml
demos/speech_server/conf/asr/asr.yaml
+4
-3
demos/speech_server/conf/asr/asr_pd.yaml
demos/speech_server/conf/asr/asr_pd.yaml
+25
-0
demos/speech_server/conf/tts/tts.yaml
demos/speech_server/conf/tts/tts.yaml
+1
-1
demos/speech_server/conf/tts/tts_pd.yaml
demos/speech_server/conf/tts/tts_pd.yaml
+10
-11
paddlespeech/server/bin/paddlespeech_server.py
paddlespeech/server/bin/paddlespeech_server.py
+5
-8
paddlespeech/server/conf/application.yaml
paddlespeech/server/conf/application.yaml
+9
-4
paddlespeech/server/conf/asr/asr.yaml
paddlespeech/server/conf/asr/asr.yaml
+1
-0
paddlespeech/server/conf/asr/asr_pd.yaml
paddlespeech/server/conf/asr/asr_pd.yaml
+1
-1
paddlespeech/server/conf/tts/tts.yaml
paddlespeech/server/conf/tts/tts.yaml
+1
-1
paddlespeech/server/conf/tts/tts_pd.yaml
paddlespeech/server/conf/tts/tts_pd.yaml
+12
-13
paddlespeech/server/engine/asr/python/asr_engine.py
paddlespeech/server/engine/asr/python/asr_engine.py
+1
-11
paddlespeech/server/engine/tts/paddleinference/tts_engine.py
paddlespeech/server/engine/tts/paddleinference/tts_engine.py
+0
-1
paddlespeech/server/restful/tts_api.py
paddlespeech/server/restful/tts_api.py
+30
-17
paddlespeech/server/utils/paddle_predictor.py
paddlespeech/server/utils/paddle_predictor.py
+3
-2
未找到文件。
demos/speech_server/conf/application.yaml
浏览文件 @
6b2dd168
...
...
@@ -9,9 +9,17 @@ port: 8090
##################################################################
# CONFIG FILE #
##################################################################
# add engine type (Options: asr, tts) and config file here.
# The engine_type of speech task needs to keep the same type as the config file of speech task.
# E.g: The engine_type of asr is 'python', the engine_backend of asr is 'XX/asr.yaml'
# E.g: The engine_type of asr is 'inference', the engine_backend of asr is 'XX/asr_pd.yaml'
#
# add engine type (Options: python, inference)
engine_type
:
asr
:
'
inference'
tts
:
'
inference'
# add engine backend type (Options: asr, tts) and config file here.
# Adding a speech task to engine_backend means starting the service.
engine_backend
:
asr
:
'
conf/asr/asr.yaml'
tts
:
'
conf/tts/tts.yaml'
asr
:
'
conf/asr/asr_pd.yaml'
tts
:
'
conf/tts/tts_pd.yaml'
demos/speech_server/conf/asr/asr.yaml
浏览文件 @
6b2dd168
model
:
'
conformer_wenetspeech'
lang
:
'
zh'
sample_rate
:
16000
cfg_path
:
ckpt_path
:
cfg_path
:
# [optional]
ckpt_path
:
# [optional]
decode_method
:
'
attention_rescoring'
force_yes
:
False
force_yes
:
True
device
:
'
gpu:3'
# set 'gpu:id' or 'cpu'
demos/speech_server/conf/asr/asr_pd.yaml
0 → 100644
浏览文件 @
6b2dd168
# This is the parameter configuration file for ASR server.
# These are the static models that support paddle inference.
##################################################################
# ACOUSTIC MODEL SETTING #
# am choices=['deepspeech2offline_aishell'] TODO
##################################################################
model_type
:
'
deepspeech2offline_aishell'
am_model
:
# the pdmodel file of am static model [optional]
am_params
:
# the pdiparams file of am static model [optional]
lang
:
'
zh'
sample_rate
:
16000
cfg_path
:
decode_method
:
force_yes
:
True
am_predictor_conf
:
device
:
'
gpu:3'
# set 'gpu:id' or 'cpu'
enable_mkldnn
:
True
switch_ir_optim
:
True
##################################################################
# OTHERS #
##################################################################
demos/speech_server/conf/tts/tts.yaml
浏览文件 @
6b2dd168
...
...
@@ -29,4 +29,4 @@ voc_stat:
# OTHERS #
##################################################################
lang
:
'
zh'
device
:
'
gpu:
2
'
device
:
'
gpu:
3'
# set 'gpu:id' or 'cpu
'
demos/speech_server/conf/tts/tts_pd.yaml
浏览文件 @
6b2dd168
...
...
@@ -6,8 +6,8 @@
# am choices=['speedyspeech_csmsc', 'fastspeech2_csmsc']
##################################################################
am
:
'
fastspeech2_csmsc'
am_model
:
# the pdmodel file of
am static model
am_params
:
# the pdiparams file of
am static model
am_model
:
# the pdmodel file of
your am static model (XX.pdmodel)
am_params
:
# the pdiparams file of
your am static model (XX.pdipparams)
am_sample_rate
:
24000
phones_dict
:
tones_dict
:
...
...
@@ -15,9 +15,9 @@ speaker_dict:
spk_id
:
0
am_predictor_conf
:
use_gpu
:
True
enable_mkldnn
:
Tru
e
switch_ir_optim
:
Tru
e
device
:
'
gpu:3'
# set 'gpu:id' or 'cpu'
enable_mkldnn
:
Fals
e
switch_ir_optim
:
Fals
e
##################################################################
...
...
@@ -25,17 +25,16 @@ am_predictor_conf:
# voc choices=['pwgan_csmsc', 'mb_melgan_csmsc','hifigan_csmsc']
##################################################################
voc
:
'
pwgan_csmsc'
voc_model
:
# the pdmodel file of
vocoder static model
voc_params
:
# the pdiparams file of
vocoder static model
voc_model
:
# the pdmodel file of
your vocoder static model (XX.pdmodel)
voc_params
:
# the pdiparams file of
your vocoder static model (XX.pdipparams)
voc_sample_rate
:
24000
voc_predictor_conf
:
use_gpu
:
True
enable_mkldnn
:
Tru
e
switch_ir_optim
:
Tru
e
device
:
'
gpu:3'
# set 'gpu:id' or 'cpu'
enable_mkldnn
:
Fals
e
switch_ir_optim
:
Fals
e
##################################################################
# OTHERS #
##################################################################
lang
:
'
zh'
device
:
paddle.get_device()
paddlespeech/server/bin/paddlespeech_server.py
浏览文件 @
6b2dd168
...
...
@@ -20,7 +20,7 @@ from fastapi import FastAPI
from
..executor
import
BaseExecutor
from
..util
import
cli_server_register
from
..util
import
stats_wrapper
from
paddlespeech.server.engine.engine_
factory
import
EngineFactory
from
paddlespeech.server.engine.engine_
pool
import
init_engine_pool
from
paddlespeech.server.restful.api
import
setup_router
from
paddlespeech.server.utils.config
import
get_config
...
...
@@ -51,8 +51,10 @@ class ServerExecutor(BaseExecutor):
def
init
(
self
,
config
)
->
bool
:
"""system initialization
Args:
config (CfgNode): config object
Returns:
bool:
"""
...
...
@@ -61,13 +63,8 @@ class ServerExecutor(BaseExecutor):
api_router
=
setup_router
(
api_list
)
app
.
include_router
(
api_router
)
# init engine
engine_pool
=
[]
for
engine
in
config
.
engine_backend
:
engine_pool
.
append
(
EngineFactory
.
get_engine
(
engine_name
=
engine
))
if
not
engine_pool
[
-
1
].
init
(
config_file
=
config
.
engine_backend
[
engine
]):
return
False
if
not
init_engine_pool
(
config
):
return
False
return
True
...
...
paddlespeech/server/conf/application.yaml
浏览文件 @
6b2dd168
...
...
@@ -9,12 +9,17 @@ port: 8090
##################################################################
# CONFIG FILE #
##################################################################
# The engine_type of speech task needs to keep the same type as the config file of speech task.
# E.g: The engine_type of asr is 'python', the engine_backend of asr is 'XX/asr.yaml'
# E.g: The engine_type of asr is 'inference', the engine_backend of asr is 'XX/asr_pd.yaml'
#
# add engine type (Options: python, inference)
engine_type
:
asr
:
'
inference
'
# tts: 'inference
'
asr
:
'
python
'
tts
:
'
python
'
# add engine backend type (Options: asr, tts) and config file here.
# Adding a speech task to engine_backend means starting the service.
engine_backend
:
asr
:
'
conf/asr/asr
_pd
.yaml'
#tts: 'conf/tts/tts_pd
.yaml'
asr
:
'
conf/asr/asr.yaml'
tts
:
'
conf/tts/tts
.yaml'
paddlespeech/server/conf/asr/asr.yaml
浏览文件 @
6b2dd168
...
...
@@ -5,3 +5,4 @@ cfg_path: # [optional]
ckpt_path
:
# [optional]
decode_method
:
'
attention_rescoring'
force_yes
:
True
device
:
'
gpu:3'
# set 'gpu:id' or 'cpu'
paddlespeech/server/conf/asr/asr_pd.yaml
浏览文件 @
6b2dd168
...
...
@@ -15,7 +15,7 @@ decode_method:
force_yes
:
True
am_predictor_conf
:
use_gpu
:
True
device
:
'
gpu:3'
# set 'gpu:id' or 'cpu'
enable_mkldnn
:
True
switch_ir_optim
:
True
...
...
paddlespeech/server/conf/tts/tts.yaml
浏览文件 @
6b2dd168
...
...
@@ -29,4 +29,4 @@ voc_stat:
# OTHERS #
##################################################################
lang
:
'
zh'
device
:
paddle.get_device()
\ No newline at end of file
device
:
'
gpu:3'
# set 'gpu:id' or 'cpu'
paddlespeech/server/conf/tts/tts_pd.yaml
浏览文件 @
6b2dd168
...
...
@@ -6,18 +6,18 @@
# am choices=['speedyspeech_csmsc', 'fastspeech2_csmsc']
##################################################################
am
:
'
fastspeech2_csmsc'
am_model
:
# the pdmodel file of
am static model
am_params
:
# the pdiparams file of
am static model
am_sample_rate
:
24000
am_model
:
# the pdmodel file of
your am static model (XX.pdmodel)
am_params
:
# the pdiparams file of
your am static model (XX.pdipparams)
am_sample_rate
:
24000
# must match the model
phones_dict
:
tones_dict
:
speaker_dict
:
spk_id
:
0
am_predictor_conf
:
use_gpu
:
True
enable_mkldnn
:
Tru
e
switch_ir_optim
:
Tru
e
device
:
'
gpu:3'
# set 'gpu:id' or 'cpu'
enable_mkldnn
:
Fals
e
switch_ir_optim
:
Fals
e
##################################################################
...
...
@@ -25,17 +25,16 @@ am_predictor_conf:
# voc choices=['pwgan_csmsc', 'mb_melgan_csmsc','hifigan_csmsc']
##################################################################
voc
:
'
pwgan_csmsc'
voc_model
:
# the pdmodel file of
vocoder static model
voc_params
:
# the pdiparams file of
vocoder static model
voc_sample_rate
:
24000
voc_model
:
# the pdmodel file of
your vocoder static model (XX.pdmodel)
voc_params
:
# the pdiparams file of
your vocoder static model (XX.pdipparams)
voc_sample_rate
:
24000
#must match the model
voc_predictor_conf
:
use_gpu
:
True
enable_mkldnn
:
True
switch_ir_optim
:
Tru
e
device
:
'
gpu:3'
# set 'gpu:id' or 'cpu'
enable_mkldnn
:
False
switch_ir_optim
:
Fals
e
##################################################################
# OTHERS #
##################################################################
lang
:
'
zh'
device
:
paddle.get_device()
paddlespeech/server/engine/asr/python/asr_engine.py
浏览文件 @
6b2dd168
...
...
@@ -12,21 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import
io
import
os
from
typing
import
List
from
typing
import
Optional
from
typing
import
Union
import
librosa
import
paddle
import
soundfile
from
paddlespeech.cli.asr.infer
import
ASRExecutor
from
paddlespeech.cli.log
import
logger
from
paddlespeech.s2t.frontend.featurizer.text_featurizer
import
TextFeaturizer
from
paddlespeech.s2t.transform.transformation
import
Transformation
from
paddlespeech.s2t.utils.dynamic_import
import
dynamic_import
from
paddlespeech.s2t.utils.utility
import
UpdateConfig
from
paddlespeech.server.engine.base_engine
import
BaseEngine
from
paddlespeech.server.utils.config
import
get_config
...
...
@@ -63,7 +53,7 @@ class ASREngine(BaseEngine):
self
.
executor
=
ASRServerExecutor
()
self
.
config
=
get_config
(
config_file
)
paddle
.
set_device
(
paddle
.
get_device
()
)
paddle
.
set_device
(
self
.
config
.
device
)
self
.
executor
.
_init_from_path
(
self
.
config
.
model
,
self
.
config
.
lang
,
self
.
config
.
sample_rate
,
self
.
config
.
cfg_path
,
self
.
config
.
decode_method
,
...
...
paddlespeech/server/engine/tts/paddleinference/tts_engine.py
浏览文件 @
6b2dd168
...
...
@@ -344,7 +344,6 @@ class TTSEngine(BaseEngine):
try
:
self
.
config
=
get_config
(
config_file
)
self
.
executor
.
_init_from_path
(
am
=
self
.
config
.
am
,
am_model
=
self
.
config
.
am_model
,
...
...
paddlespeech/server/restful/tts_api.py
浏览文件 @
6b2dd168
...
...
@@ -16,7 +16,7 @@ from typing import Union
from
fastapi
import
APIRouter
from
paddlespeech.server.engine.
tts.paddleinference.tts_engine
import
TTSEngine
from
paddlespeech.server.engine.
engine_pool
import
get_engine_pool
from
paddlespeech.server.restful.request
import
TTSRequest
from
paddlespeech.server.restful.response
import
ErrorResponse
from
paddlespeech.server.restful.response
import
TTSResponse
...
...
@@ -60,28 +60,41 @@ def tts(request_body: TTSRequest):
Returns:
json: [description]
"""
# json to dict
item_dict
=
request_body
.
dict
()
sentence
=
item_dict
[
'text'
]
spk_id
=
item_dict
[
'spk_id'
]
speed
=
item_dict
[
'speed'
]
volume
=
item_dict
[
'volume'
]
sample_rate
=
item_dict
[
'sample_rate'
]
save_path
=
item_dict
[
'save_path'
]
# get params
text
=
request_body
.
text
spk_id
=
request_body
.
spk_id
speed
=
request_body
.
speed
volume
=
request_body
.
volume
sample_rate
=
request_body
.
sample_rate
save_path
=
request_body
.
save_path
# Check parameters
if
speed
<=
0
or
speed
>
3
or
volume
<=
0
or
volume
>
3
or
\
sample_rate
not
in
[
0
,
16000
,
8000
]
or
\
(
save_path
is
not
None
and
not
save_path
.
endswith
(
"pcm"
)
and
not
save_path
.
endswith
(
"wav"
)):
return
failed_response
(
ErrorCode
.
SERVER_PARAM_ERR
)
# single
tts_engine
=
TTSEngine
()
if
speed
<=
0
or
speed
>
3
:
return
failed_response
(
ErrorCode
.
SERVER_PARAM_ERR
,
"invalid speed value, the value should be between 0 and 3."
)
if
volume
<=
0
or
volume
>
3
:
return
failed_response
(
ErrorCode
.
SERVER_PARAM_ERR
,
"invalid volume value, the value should be between 0 and 3."
)
if
sample_rate
not
in
[
0
,
16000
,
8000
]:
return
failed_response
(
ErrorCode
.
SERVER_PARAM_ERR
,
"invalid sample_rate value, the choice of value is 0, 8000, 16000."
)
if
save_path
is
not
None
and
not
save_path
.
endswith
(
"pcm"
)
and
not
save_path
.
endswith
(
"wav"
):
return
failed_response
(
ErrorCode
.
SERVER_PARAM_ERR
,
"invalid save_path, saved audio formats support pcm and wav"
)
# run
try
:
# get single engine from engine pool
engine_pool
=
get_engine_pool
()
tts_engine
=
engine_pool
[
'tts'
]
lang
,
target_sample_rate
,
wav_base64
=
tts_engine
.
run
(
sentence
,
spk_id
,
speed
,
volume
,
sample_rate
,
save_path
)
text
,
spk_id
,
speed
,
volume
,
sample_rate
,
save_path
)
response
=
{
"success"
:
True
,
...
...
paddlespeech/server/utils/paddle_predictor.py
浏览文件 @
6b2dd168
...
...
@@ -41,8 +41,9 @@ def init_predictor(model_dir: Optional[os.PathLike]=None,
config
=
Config
(
model_file
,
params_file
)
config
.
enable_memory_optim
()
if
predictor_conf
[
"use_gpu"
]:
config
.
enable_use_gpu
(
1000
,
0
)
if
"gpu"
in
predictor_conf
[
"device"
]:
gpu_id
=
predictor_conf
[
"device"
].
split
(
":"
)[
-
1
]
config
.
enable_use_gpu
(
1000
,
int
(
gpu_id
))
if
predictor_conf
[
"enable_mkldnn"
]:
config
.
enable_mkldnn
()
if
predictor_conf
[
"switch_ir_optim"
]:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录