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
2023-04-04 16:44:37 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2023-04-04 16:44:37 +0800
Commit
283e41c55757a47e73fac903ab9fa4e1f5a6d687
283e41c5
1 parent
726680c5
Fix displaying English words for paraformer models. (#114)
隐藏空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
44 行增加
和
4 行删除
sherpa-onnx/csrc/offline-recognizer-paraformer-impl.h
sherpa-onnx/csrc/offline-recognizer-paraformer-impl.h
查看文件 @
283e41c
...
...
@@ -28,11 +28,51 @@ static OfflineRecognitionResult Convert(
r
.
tokens
.
reserve
(
src
.
tokens
.
size
());
std
::
string
text
;
for
(
auto
i
:
src
.
tokens
)
{
auto
sym
=
sym_table
[
i
];
text
.
append
(
sym
);
r
.
tokens
.
push_back
(
std
::
move
(
sym
));
// When the current token ends with "@@" we set mergeable to true
bool
mergeable
=
false
;
for
(
int32_t
i
=
0
;
i
!=
src
.
tokens
.
size
();
++
i
)
{
auto
sym
=
sym_table
[
src
.
tokens
[
i
]];
r
.
tokens
.
push_back
(
sym
);
if
((
sym
.
back
()
!=
'@'
)
||
(
sym
.
size
()
>
2
&&
sym
[
sym
.
size
()
-
2
]
!=
'@'
))
{
// sym does not end with "@@"
const
uint8_t
*
p
=
reinterpret_cast
<
const
uint8_t
*>
(
sym
.
c_str
());
if
(
p
[
0
]
<
0x80
)
{
// an ascii
if
(
mergeable
)
{
mergeable
=
false
;
text
.
append
(
sym
);
}
else
{
text
.
append
(
" "
);
text
.
append
(
sym
);
}
}
else
{
// not an ascii
mergeable
=
false
;
if
(
i
>
0
)
{
const
uint8_t
*
p
=
reinterpret_cast
<
const
uint8_t
*>
(
sym_table
[
src
.
tokens
[
i
-
1
]].
c_str
());
if
(
p
[
0
]
<
0x80
)
{
// put a space between ascii and non-ascii
text
.
append
(
" "
);
}
}
text
.
append
(
sym
);
}
}
else
{
// this sym ends with @@
sym
=
std
::
string
(
sym
.
data
(),
sym
.
size
()
-
2
);
if
(
mergeable
)
{
text
.
append
(
sym
);
}
else
{
text
.
append
(
" "
);
text
.
append
(
sym
);
mergeable
=
true
;
}
}
}
r
.
text
=
std
::
move
(
text
);
...
...
请
注册
或
登录
后发表评论