Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
6f7917b7
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6f7917b7
编写于
5月 25, 2022
作者:
H
Hui Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix streaming asr
上级
f07f57a3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
12 addition
and
43 deletion
+12
-43
demos/streaming_asr_server/conf/ws_conformer_application.yaml
...s/streaming_asr_server/conf/ws_conformer_application.yaml
+1
-1
demos/streaming_asr_server/conf/ws_ds2_application.yaml
demos/streaming_asr_server/conf/ws_ds2_application.yaml
+0
-0
paddlespeech/server/engine/asr/online/asr_engine.py
paddlespeech/server/engine/asr/online/asr_engine.py
+11
-42
未找到文件。
demos/streaming_asr_server/conf/ws_conformer_application.yaml
浏览文件 @
6f7917b7
...
...
@@ -4,7 +4,7 @@
# SERVER SETTING #
#################################################################################
host
:
0.0.0.0
port
:
809
0
port
:
809
1
# The task format in the engin_list is: <speech task>_<engine type>
# task choices = ['asr_online']
...
...
demos/streaming_asr_server/conf/ws_application.yaml
→
demos/streaming_asr_server/conf/ws_
ds2_
application.yaml
浏览文件 @
6f7917b7
文件已移动
paddlespeech/server/engine/asr/online/asr_engine.py
浏览文件 @
6f7917b7
...
...
@@ -53,7 +53,7 @@ class PaddleASRConnectionHanddler:
logger
.
info
(
"create an paddle asr connection handler to process the websocket connection"
)
self
.
config
=
asr_engine
.
config
self
.
config
=
asr_engine
.
config
# server config
self
.
model_config
=
asr_engine
.
executor
.
config
self
.
asr_engine
=
asr_engine
...
...
@@ -249,10 +249,13 @@ class PaddleASRConnectionHanddler:
def
reset
(
self
):
if
"deepspeech2"
in
self
.
model_type
:
# for deepspeech2
self
.
chunk_state_h_box
=
copy
.
deepcopy
(
self
.
asr_engine
.
executor
.
chunk_state_h_box
)
self
.
chunk_state_c_box
=
copy
.
deepcopy
(
self
.
asr_engine
.
executor
.
chunk_state_c_box
)
# init state
self
.
chunk_state_h_box
=
np
.
zeros
(
(
self
.
model_config
.
num_rnn_layers
,
1
,
self
.
model_config
.
rnn_layer_size
),
dtype
=
float32
)
self
.
chunk_state_c_box
=
np
.
zeros
(
(
self
.
model_config
.
num_rnn_layers
,
1
,
self
.
model_config
.
rnn_layer_size
),
dtype
=
float32
)
self
.
decoder
.
reset_decoder
(
batch_size
=
1
)
self
.
device
=
None
...
...
@@ -803,36 +806,6 @@ class ASRServerExecutor(ASRExecutor):
model_file
=
self
.
am_model
,
params_file
=
self
.
am_params
,
predictor_conf
=
self
.
am_predictor_conf
)
# decoder
logger
.
info
(
"ASR engine start to create the ctc decoder instance"
)
self
.
decoder
=
CTCDecoder
(
odim
=
self
.
config
.
output_dim
,
# <blank> is in vocab
enc_n_units
=
self
.
config
.
rnn_layer_size
*
2
,
blank_id
=
self
.
config
.
blank_id
,
dropout_rate
=
0.0
,
reduction
=
True
,
# sum
batch_average
=
True
,
# sum / batch_size
grad_norm_type
=
self
.
config
.
get
(
'ctc_grad_norm_type'
,
None
))
# init decoder
logger
.
info
(
"ASR engine start to init the ctc decoder"
)
cfg
=
self
.
config
.
decode
decode_batch_size
=
1
# for online
self
.
decoder
.
init_decoder
(
decode_batch_size
,
self
.
text_feature
.
vocab_list
,
cfg
.
decoding_method
,
cfg
.
lang_model_path
,
cfg
.
alpha
,
cfg
.
beta
,
cfg
.
beam_size
,
cfg
.
cutoff_prob
,
cfg
.
cutoff_top_n
,
cfg
.
num_proc_bsearch
)
# init state box
self
.
chunk_state_h_box
=
np
.
zeros
(
(
self
.
config
.
num_rnn_layers
,
1
,
self
.
config
.
rnn_layer_size
),
dtype
=
float32
)
self
.
chunk_state_c_box
=
np
.
zeros
(
(
self
.
config
.
num_rnn_layers
,
1
,
self
.
config
.
rnn_layer_size
),
dtype
=
float32
)
elif
"conformer"
in
model_type
or
"transformer"
in
model_type
:
model_name
=
model_type
[:
model_type
.
rindex
(
'_'
)]
# model_type: {model_name}_{dataset}
...
...
@@ -847,15 +820,11 @@ class ASRServerExecutor(ASRExecutor):
model_dict
=
paddle
.
load
(
self
.
am_model
)
self
.
model
.
set_state_dict
(
model_dict
)
logger
.
info
(
"create the transformer like model success"
)
# update the ctc decoding
self
.
searcher
=
CTCPrefixBeamSearch
(
self
.
config
.
decode
)
self
.
transformer_decode_reset
()
else
:
raise
ValueError
(
f
"Not support:
{
model_type
}
"
)
return
True
class
ASREngine
(
BaseEngine
):
"""ASR server resource
...
...
@@ -881,8 +850,8 @@ class ASREngine(BaseEngine):
self
.
executor
=
ASRServerExecutor
()
try
:
default_dev
=
paddle
.
get_device
(
)
paddle
.
set_device
(
self
.
config
.
get
(
"device"
,
default_dev
)
)
self
.
device
=
self
.
config
.
get
(
"device"
,
paddle
.
get_device
()
)
paddle
.
set_device
(
self
.
device
)
except
BaseException
as
e
:
logger
.
error
(
f
"Set device failed, please check if device '
{
self
.
device
}
' is already used and the parameter 'device' in the yaml file"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录