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
Fangjun Kuang
2024-04-22 15:10:39 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2024-04-22 15:10:39 +0800
Commit
494cb5c7330bc6dbf87fe62955cea88a14c05ea1
494cb5c7
1 parent
9a68b92c
Fix the last character not being recognized for streaming paraformer models. (#799)
隐藏空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
27 行增加
和
0 行删除
sherpa-onnx/csrc/sherpa-onnx-alsa.cc
sherpa-onnx/csrc/sherpa-onnx-microphone.cc
sherpa-onnx/csrc/sherpa-onnx-alsa.cc
查看文件 @
494cb5c
...
...
@@ -113,6 +113,20 @@ as the device_name.
bool
is_endpoint
=
recognizer
.
IsEndpoint
(
stream
.
get
());
if
(
is_endpoint
&&
!
config
.
model_config
.
paraformer
.
encoder
.
empty
())
{
// For streaming paraformer models, since it has a large right chunk size
// we need to pad it on endpointing so that the last character
// can be recognized
std
::
vector
<
float
>
tail_paddings
(
static_cast
<
int
>
(
1.0
*
expected_sample_rate
));
stream
->
AcceptWaveform
(
expected_sample_rate
,
tail_paddings
.
data
(),
tail_paddings
.
size
());
while
(
recognizer
.
IsReady
(
stream
.
get
()))
{
recognizer
.
DecodeStream
(
stream
.
get
());
}
text
=
recognizer
.
GetResult
(
stream
.
get
()).
text
;
}
if
(
!
text
.
empty
()
&&
last_text
!=
text
)
{
last_text
=
text
;
...
...
sherpa-onnx/csrc/sherpa-onnx-microphone.cc
查看文件 @
494cb5c
...
...
@@ -157,6 +157,19 @@ for a list of pre-trained models to download.
auto
text
=
recognizer
.
GetResult
(
s
.
get
()).
text
;
bool
is_endpoint
=
recognizer
.
IsEndpoint
(
s
.
get
());
if
(
is_endpoint
&&
!
config
.
model_config
.
paraformer
.
encoder
.
empty
())
{
// For streaming paraformer models, since it has a large right chunk size
// we need to pad it on endpointing so that the last character
// can be recognized
std
::
vector
<
float
>
tail_paddings
(
static_cast
<
int
>
(
1.0
*
mic_sample_rate
));
s
->
AcceptWaveform
(
mic_sample_rate
,
tail_paddings
.
data
(),
tail_paddings
.
size
());
while
(
recognizer
.
IsReady
(
s
.
get
()))
{
recognizer
.
DecodeStream
(
s
.
get
());
}
text
=
recognizer
.
GetResult
(
s
.
get
()).
text
;
}
if
(
!
text
.
empty
()
&&
last_text
!=
text
)
{
last_text
=
text
;
...
...
请
注册
或
登录
后发表评论