Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
babac27a
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看板
提交
babac27a
编写于
4月 19, 2022
作者:
X
xiongxinlei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix ds2 online edge bug, test=doc
上级
dcab04a7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
14 addition
and
8 deletion
+14
-8
paddlespeech/cli/asr/pretrained_models.py
paddlespeech/cli/asr/pretrained_models.py
+2
-0
paddlespeech/server/engine/asr/online/asr_engine.py
paddlespeech/server/engine/asr/online/asr_engine.py
+12
-8
未找到文件。
paddlespeech/cli/asr/pretrained_models.py
浏览文件 @
babac27a
...
@@ -88,6 +88,8 @@ model_alias = {
...
@@ -88,6 +88,8 @@ model_alias = {
"paddlespeech.s2t.models.ds2_online:DeepSpeech2ModelOnline"
,
"paddlespeech.s2t.models.ds2_online:DeepSpeech2ModelOnline"
,
"conformer"
:
"conformer"
:
"paddlespeech.s2t.models.u2:U2Model"
,
"paddlespeech.s2t.models.u2:U2Model"
,
"conformer_online"
:
"paddlespeech.s2t.models.u2:U2Model"
,
"transformer"
:
"transformer"
:
"paddlespeech.s2t.models.u2:U2Model"
,
"paddlespeech.s2t.models.u2:U2Model"
,
"wenetspeech"
:
"wenetspeech"
:
...
...
paddlespeech/server/engine/asr/online/asr_engine.py
浏览文件 @
babac27a
...
@@ -130,9 +130,10 @@ class PaddleASRConnectionHanddler:
...
@@ -130,9 +130,10 @@ class PaddleASRConnectionHanddler:
cfg
.
num_proc_bsearch
)
cfg
.
num_proc_bsearch
)
# frame window samples length and frame shift samples length
# frame window samples length and frame shift samples length
self
.
win_length
=
int
(
self
.
model_config
.
window_ms
*
self
.
win_length
=
int
(
self
.
model_config
.
window_ms
/
1000
*
self
.
sample_rate
)
self
.
sample_rate
)
self
.
n_shift
=
int
(
self
.
model_config
.
stride_ms
*
self
.
sample_rate
)
self
.
n_shift
=
int
(
self
.
model_config
.
stride_ms
/
1000
*
self
.
sample_rate
)
elif
"conformer"
in
self
.
model_type
or
"transformer"
in
self
.
model_type
:
elif
"conformer"
in
self
.
model_type
or
"transformer"
in
self
.
model_type
:
# acoustic model
# acoustic model
...
@@ -158,6 +159,11 @@ class PaddleASRConnectionHanddler:
...
@@ -158,6 +159,11 @@ class PaddleASRConnectionHanddler:
samples
=
np
.
frombuffer
(
samples
,
dtype
=
np
.
int16
)
samples
=
np
.
frombuffer
(
samples
,
dtype
=
np
.
int16
)
assert
samples
.
ndim
==
1
assert
samples
.
ndim
==
1
# pcm16 -> pcm 32
# pcm2float will change the orignal samples,
# so we shoule do pcm2float before concatenate
samples
=
pcm2float
(
samples
)
if
self
.
remained_wav
is
None
:
if
self
.
remained_wav
is
None
:
self
.
remained_wav
=
samples
self
.
remained_wav
=
samples
else
:
else
:
...
@@ -167,11 +173,9 @@ class PaddleASRConnectionHanddler:
...
@@ -167,11 +173,9 @@ class PaddleASRConnectionHanddler:
f
"The connection remain the audio samples:
{
self
.
remained_wav
.
shape
}
"
f
"The connection remain the audio samples:
{
self
.
remained_wav
.
shape
}
"
)
)
# pcm16 -> pcm 32
samples
=
pcm2float
(
self
.
remained_wav
)
# read audio
# read audio
speech_segment
=
SpeechSegment
.
from_pcm
(
speech_segment
=
SpeechSegment
.
from_pcm
(
s
amples
,
self
.
sample_rate
,
transcript
=
" "
)
s
elf
.
remained_wav
,
self
.
sample_rate
,
transcript
=
" "
)
# audio augment
# audio augment
self
.
collate_fn_test
.
augmentation
.
transform_audio
(
speech_segment
)
self
.
collate_fn_test
.
augmentation
.
transform_audio
(
speech_segment
)
...
@@ -474,6 +478,7 @@ class PaddleASRConnectionHanddler:
...
@@ -474,6 +478,7 @@ class PaddleASRConnectionHanddler:
self
.
hyps
=
self
.
searcher
.
get_one_best_hyps
()
self
.
hyps
=
self
.
searcher
.
get_one_best_hyps
()
assert
self
.
cached_feat
.
shape
[
0
]
==
1
assert
self
.
cached_feat
.
shape
[
0
]
==
1
assert
end
>=
cached_feature_num
assert
end
>=
cached_feature_num
self
.
cached_feat
=
self
.
cached_feat
[
0
,
end
-
self
.
cached_feat
=
self
.
cached_feat
[
0
,
end
-
cached_feature_num
:,
:].
unsqueeze
(
0
)
cached_feature_num
:,
:].
unsqueeze
(
0
)
assert
len
(
assert
len
(
...
@@ -515,7 +520,6 @@ class PaddleASRConnectionHanddler:
...
@@ -515,7 +520,6 @@ class PaddleASRConnectionHanddler:
return
return
# assert len(hyps) == beam_size
# assert len(hyps) == beam_size
paddle
.
save
(
self
.
encoder_out
,
"encoder.out"
)
hyp_list
=
[]
hyp_list
=
[]
for
hyp
in
hyps
:
for
hyp
in
hyps
:
hyp_content
=
hyp
[
0
]
hyp_content
=
hyp
[
0
]
...
@@ -815,7 +819,7 @@ class ASRServerExecutor(ASRExecutor):
...
@@ -815,7 +819,7 @@ class ASRServerExecutor(ASRExecutor):
def
advanced_decoding
(
self
,
xs
:
paddle
.
Tensor
,
x_chunk_lens
):
def
advanced_decoding
(
self
,
xs
:
paddle
.
Tensor
,
x_chunk_lens
):
logger
.
info
(
"start to decode with advanced_decoding method"
)
logger
.
info
(
"start to decode with advanced_decoding method"
)
encoder_out
,
encoder_mask
=
self
.
decode
_forward
(
xs
)
encoder_out
,
encoder_mask
=
self
.
encoder
_forward
(
xs
)
ctc_probs
=
self
.
model
.
ctc
.
log_softmax
(
ctc_probs
=
self
.
model
.
ctc
.
log_softmax
(
encoder_out
)
# (1, maxlen, vocab_size)
encoder_out
)
# (1, maxlen, vocab_size)
ctc_probs
=
ctc_probs
.
squeeze
(
0
)
ctc_probs
=
ctc_probs
.
squeeze
(
0
)
...
@@ -827,7 +831,7 @@ class ASRServerExecutor(ASRExecutor):
...
@@ -827,7 +831,7 @@ class ASRServerExecutor(ASRExecutor):
if
"attention_rescoring"
in
self
.
config
.
decode
.
decoding_method
:
if
"attention_rescoring"
in
self
.
config
.
decode
.
decoding_method
:
self
.
rescoring
(
encoder_out
,
xs
.
place
)
self
.
rescoring
(
encoder_out
,
xs
.
place
)
def
decode
_forward
(
self
,
xs
):
def
encoder
_forward
(
self
,
xs
):
logger
.
info
(
"get the model out from the feat"
)
logger
.
info
(
"get the model out from the feat"
)
cfg
=
self
.
config
.
decode
cfg
=
self
.
config
.
decode
decoding_chunk_size
=
cfg
.
decoding_chunk_size
decoding_chunk_size
=
cfg
.
decoding_chunk_size
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录