Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
xuning
/
sherpaonnx
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Askars Salimbajevs
2025-04-02 18:33:47 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2025-04-02 23:33:47 +0800
Commit
18a6ed5ddc2af20f31a6d18ca266a90ac9582e0c
18a6ed5d
1 parent
da4aad11
Preserve more context after endpointing in transducer (#2061)
隐藏空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
10 行增加
和
6 行删除
sherpa-onnx/csrc/online-recognizer-transducer-impl.h
sherpa-onnx/csrc/online-recognizer-transducer-impl.h
查看文件 @
18a6ed5
...
...
@@ -388,16 +388,20 @@ class OnlineRecognizerTransducerImpl : public OnlineRecognizerImpl {
auto
r
=
decoder_
->
GetEmptyResult
();
auto
last_result
=
s
->
GetResult
();
// if last result is not empty, then
//
preserve last tokens
as the context for next result
//
truncate all last hyps and save
as the context for next result
if
(
static_cast
<
int32_t
>
(
last_result
.
tokens
.
size
())
>
context_size
)
{
std
::
vector
<
int64_t
>
context
(
last_result
.
tokens
.
end
()
-
context_size
,
last_result
.
tokens
.
end
());
for
(
const
auto
&
it
:
last_result
.
hyps
)
{
auto
h
=
it
.
second
;
r
.
hyps
.
Add
({
std
::
vector
<
int64_t
>
(
h
.
ys
.
end
()
-
context_size
,
h
.
ys
.
end
()),
h
.
log_prob
});
}
Hypotheses
context_hyp
({{
context
,
0
}});
r
.
hyps
=
std
::
move
(
context_hyp
);
r
.
tokens
=
std
::
move
(
context
);
r
.
tokens
=
std
::
vector
<
int64_t
>
(
last_result
.
tokens
.
end
()
-
context_size
,
last_result
.
tokens
.
end
());
}
// but reset all contextual biasing graph states to root
if
(
config_
.
decoding_method
==
"modified_beam_search"
&&
nullptr
!=
s
->
GetContextGraph
())
{
for
(
auto
it
=
r
.
hyps
.
begin
();
it
!=
r
.
hyps
.
end
();
++
it
)
{
...
...
请
注册
或
登录
后发表评论