Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
10e825d9
D
DeepSpeech
项目概览
PaddlePaddle
/
DeepSpeech
大约 2 年 前同步成功
通知
210
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看板
提交
10e825d9
编写于
4月 18, 2022
作者:
X
xiongxinlei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
check chunk window process, test=doc
上级
d2640c14
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
30 addition
and
19 deletion
+30
-19
paddlespeech/server/engine/asr/online/asr_engine.py
paddlespeech/server/engine/asr/online/asr_engine.py
+30
-19
未找到文件。
paddlespeech/server/engine/asr/online/asr_engine.py
浏览文件 @
10e825d9
...
@@ -145,6 +145,8 @@ class PaddleASRConnectionHanddler:
...
@@ -145,6 +145,8 @@ class PaddleASRConnectionHanddler:
if
self
.
cached_feat
is
None
:
if
self
.
cached_feat
is
None
:
self
.
cached_feat
=
x_chunk
self
.
cached_feat
=
x_chunk
else
:
else
:
assert
(
len
(
x_chunk
.
shape
)
==
3
)
assert
(
len
(
self
.
cached_feat
.
shape
)
==
3
)
self
.
cached_feat
=
paddle
.
concat
([
self
.
cached_feat
,
x_chunk
],
axis
=
1
)
self
.
cached_feat
=
paddle
.
concat
([
self
.
cached_feat
,
x_chunk
],
axis
=
1
)
num_frames
=
x_chunk
.
shape
[
1
]
num_frames
=
x_chunk
.
shape
[
1
]
...
@@ -170,6 +172,7 @@ class PaddleASRConnectionHanddler:
...
@@ -170,6 +172,7 @@ class PaddleASRConnectionHanddler:
self
.
num_samples
=
0
self
.
num_samples
=
0
self
.
num_frames
=
0
self
.
num_frames
=
0
self
.
chunk_num
=
0
self
.
global_frame_offset
=
0
self
.
global_frame_offset
=
0
self
.
result
=
[]
self
.
result
=
[]
...
@@ -210,23 +213,24 @@ class PaddleASRConnectionHanddler:
...
@@ -210,23 +213,24 @@ class PaddleASRConnectionHanddler:
if
num_frames
<
decoding_window
and
not
is_finished
:
if
num_frames
<
decoding_window
and
not
is_finished
:
return
None
,
None
return
None
,
None
#
logger.info("start to do model forward")
logger
.
info
(
"start to do model forward"
)
#
required_cache_size = decoding_chunk_size * num_decoding_left_chunks
required_cache_size
=
decoding_chunk_size
*
num_decoding_left_chunks
#
outputs = []
outputs
=
[]
#
#
num_frames - context + 1 ensure that current frame can get context window
# num_frames - context + 1 ensure that current frame can get context window
#
if is_finished:
if
is_finished
:
#
# if get the finished chunk, we need process the last context
# if get the finished chunk, we need process the last context
#
left_frames = context
left_frames
=
context
#
else:
else
:
#
# we only process decoding_window frames for one chunk
# we only process decoding_window frames for one chunk
#
left_frames = decoding_window
left_frames
=
decoding_window
# logger.info(f"")
# logger.info(f"")
# end = None
end
=
None
# for cur in range(0, num_frames - left_frames + 1, stride):
for
cur
in
range
(
0
,
num_frames
-
left_frames
+
1
,
stride
):
# end = min(cur + decoding_window, num_frames)
end
=
min
(
cur
+
decoding_window
,
num_frames
)
# print(f"cur: {cur}, end: {end}")
print
(
f
"cur chunk:
{
self
.
chunk_num
}
, cur:
{
cur
}
, end:
{
end
}
"
)
self
.
chunk_num
+=
1
# chunk_xs = self.cached_feat[:, cur:end, :]
# chunk_xs = self.cached_feat[:, cur:end, :]
# (y, self.subsampling_cache, self.elayers_output_cache,
# (y, self.subsampling_cache, self.elayers_output_cache,
# self.conformer_cnn_cache) = self.model.encoder.forward_chunk(
# self.conformer_cnn_cache) = self.model.encoder.forward_chunk(
...
@@ -236,7 +240,14 @@ class PaddleASRConnectionHanddler:
...
@@ -236,7 +240,14 @@ class PaddleASRConnectionHanddler:
# outputs.append(y)
# outputs.append(y)
# update the offset
# update the offset
# self.offset += y.shape[1]
# self.offset += y.shape[1]
# self.cached_feat = self.cached_feat[end:]
# remove the processed feat
if
end
==
num_frames
:
self
.
cached_feat
=
None
else
:
assert
self
.
cached_feat
.
shape
[
0
]
==
1
self
.
cached_feat
=
self
.
cached_feat
[
0
,
end
:,:].
unsqueeze
(
0
)
assert
len
(
self
.
cached_feat
.
shape
)
==
3
,
f
"current cache feat shape is:
{
self
.
cached_feat
.
shape
}
"
# ys = paddle.cat(outputs, 1)
# ys = paddle.cat(outputs, 1)
# masks = paddle.ones([1, ys.shape[1]], dtype=paddle.bool)
# masks = paddle.ones([1, ys.shape[1]], dtype=paddle.bool)
# masks = masks.unsqueeze(1)
# masks = masks.unsqueeze(1)
...
@@ -309,9 +320,9 @@ class ASRServerExecutor(ASRExecutor):
...
@@ -309,9 +320,9 @@ class ASRServerExecutor(ASRExecutor):
logger
.
info
(
f
"Load the pretrained model, tag =
{
tag
}
"
)
logger
.
info
(
f
"Load the pretrained model, tag =
{
tag
}
"
)
res_path
=
self
.
_get_pretrained_path
(
tag
)
# wenetspeech_zh
res_path
=
self
.
_get_pretrained_path
(
tag
)
# wenetspeech_zh
self
.
res_path
=
res_path
self
.
res_path
=
res_path
#
self.cfg_path = "/home/users/xiongxinlei/task/paddlespeech-develop/PaddleSpeech/examples/aishell/asr1/model.yaml"
self
.
cfg_path
=
"/home/users/xiongxinlei/task/paddlespeech-develop/PaddleSpeech/examples/aishell/asr1/model.yaml"
self
.
cfg_path
=
os
.
path
.
join
(
res_path
,
#
self.cfg_path = os.path.join(res_path,
pretrained_models
[
tag
][
'cfg_path'
])
#
pretrained_models[tag]['cfg_path'])
self
.
am_model
=
os
.
path
.
join
(
res_path
,
self
.
am_model
=
os
.
path
.
join
(
res_path
,
pretrained_models
[
tag
][
'model'
])
pretrained_models
[
tag
][
'model'
])
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录