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-13 19:08:46 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2024-04-13 19:08:46 +0800
Commit
983df28a83baba538e69f44acf8acdfd9342a574
983df28a
1 parent
b6ad0436
Fix a punctuation bug (#764)
显示空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
10 行增加
和
14 行删除
CMakeLists.txt
sherpa-onnx/csrc/offline-punctuation-ct-transformer-impl.h
CMakeLists.txt
查看文件 @
983df28
cmake_minimum_required
(
VERSION 3.13 FATAL_ERROR
)
project
(
sherpa-onnx
)
set
(
SHERPA_ONNX_VERSION
"1.9.1
8
"
)
set
(
SHERPA_ONNX_VERSION
"1.9.1
9
"
)
# Disable warning about
#
...
...
sherpa-onnx/csrc/offline-punctuation-ct-transformer-impl.h
查看文件 @
983df28
...
...
@@ -98,7 +98,7 @@ class OfflinePunctuationCtTransformerImpl : public OfflinePunctuationImpl {
int32_t
dot_index
=
-
1
;
int32_t
comma_index
=
-
1
;
for
(
int32_t
m
=
this_punctuations
.
size
()
-
1
;
m
>=
1
;
--
m
)
{
for
(
int32_t
m
=
this_punctuations
.
size
()
-
2
;
m
>=
1
;
--
m
)
{
int32_t
punct_id
=
this_punctuations
[
m
];
if
(
punct_id
==
meta_data
.
dot_id
||
punct_id
==
meta_data
.
quest_id
)
{
...
...
@@ -126,27 +126,20 @@ class OfflinePunctuationCtTransformerImpl : public OfflinePunctuationImpl {
}
}
else
{
last
=
this_start
+
dot_index
+
1
;
}
if
(
dot_index
!=
1
)
{
punctuations
.
insert
(
punctuations
.
end
(),
this_punctuations
.
begin
(),
this_punctuations
.
begin
()
+
(
dot_index
+
1
));
}
}
// for (int32_t i = 0; i != num_segments; ++i)
if
(
punctuations
.
size
()
!=
token_ids
.
size
()
&&
punctuations
.
size
()
+
1
==
token_ids
.
size
())
{
punctuations
.
push_back
(
meta_data
.
dot_id
);
}
if
(
punctuations
.
size
()
!=
token_ids
.
size
())
{
SHERPA_ONNX_LOGE
(
"%s, %d, %d. Some unexpected things happened"
,
text
.
c_str
(),
static_cast
<
int32_t
>
(
punctuations
.
size
()),
static_cast
<
int32_t
>
(
token_ids
.
size
()));
return
text
;
}
std
::
string
ans
;
for
(
int32_t
i
=
0
;
i
!=
static_cast
<
int32_t
>
(
punctuations
.
size
());
++
i
)
{
if
(
i
>
tokens
.
size
())
{
break
;
}
const
std
::
string
&
w
=
tokens
[
i
];
if
(
i
>
0
&&
!
(
ans
.
back
()
&
0x80
)
&&
!
(
w
[
0
]
&
0x80
))
{
ans
.
push_back
(
' '
);
...
...
@@ -156,6 +149,9 @@ class OfflinePunctuationCtTransformerImpl : public OfflinePunctuationImpl {
ans
.
append
(
meta_data
.
id2punct
[
punctuations
[
i
]]);
}
}
if
(
ans
.
back
()
!=
meta_data
.
dot_id
&&
ans
.
back
()
!=
meta_data
.
quest_id
)
{
ans
.
push_back
(
meta_data
.
dot_id
);
}
return
ans
;
}
...
...
请
注册
或
登录
后发表评论