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
Peilo
2025-08-11 14:56:33 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2025-08-11 14:56:33 +0800
Commit
1cca41b62e2ef0e34d0b606f691aa8e60881eba5
1cca41b6
1 parent
0bbcfe9f
Fix ASR for UE (#2483)
隐藏空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
46 行增加
和
0 行删除
sherpa-onnx/c-api/cxx-api.cc
sherpa-onnx/c-api/cxx-api.h
sherpa-onnx/c-api/cxx-api.cc
查看文件 @
1cca41b
...
...
@@ -361,6 +361,35 @@ OfflineRecognizerResult OfflineRecognizer::GetResult(
return
ans
;
}
std
::
shared_ptr
<
OfflineRecognizerResult
>
OfflineRecognizer
::
GetResultPtr
(
const
OfflineStream
*
s
)
const
{
auto
r
=
SherpaOnnxGetOfflineStreamResult
(
s
->
Get
());
OfflineRecognizerResult
*
ans
=
new
OfflineRecognizerResult
;
if
(
r
)
{
ans
->
text
=
r
->
text
;
if
(
r
->
timestamps
)
{
ans
->
timestamps
.
resize
(
r
->
count
);
std
::
copy
(
r
->
timestamps
,
r
->
timestamps
+
r
->
count
,
ans
->
timestamps
.
data
());
}
ans
->
tokens
.
resize
(
r
->
count
);
for
(
int32_t
i
=
0
;
i
!=
r
->
count
;
++
i
)
{
ans
->
tokens
[
i
]
=
r
->
tokens_arr
[
i
];
}
ans
->
json
=
r
->
json
;
ans
->
lang
=
r
->
lang
?
r
->
lang
:
""
;
ans
->
emotion
=
r
->
emotion
?
r
->
emotion
:
""
;
ans
->
event
=
r
->
event
?
r
->
event
:
""
;
}
SherpaOnnxDestroyOfflineRecognizerResult
(
r
);
return
std
::
shared_ptr
<
OfflineRecognizerResult
>
(
ans
);
}
OfflineTts
OfflineTts
::
Create
(
const
OfflineTtsConfig
&
config
)
{
struct
SherpaOnnxOfflineTtsConfig
c
;
memset
(
&
c
,
0
,
sizeof
(
c
));
...
...
@@ -565,6 +594,7 @@ KeywordResult KeywordSpotter::GetResult(const OnlineStream *s) const {
return
ans
;
}
void
KeywordSpotter
::
Reset
(
const
OnlineStream
*
s
)
const
{
SherpaOnnxResetKeywordStream
(
p_
,
s
->
Get
());
}
...
...
@@ -723,6 +753,18 @@ SpeechSegment VoiceActivityDetector::Front() const {
return
segment
;
}
std
::
shared_ptr
<
SpeechSegment
>
VoiceActivityDetector
::
FrontPtr
()
const
{
auto
f
=
SherpaOnnxVoiceActivityDetectorFront
(
p_
);
SpeechSegment
*
segment
=
new
SpeechSegment
;
segment
->
start
=
f
->
start
;
segment
->
samples
=
std
::
vector
<
float
>
{
f
->
samples
,
f
->
samples
+
f
->
n
};
SherpaOnnxDestroySpeechSegment
(
f
);
return
std
::
shared_ptr
<
SpeechSegment
>
(
segment
);
}
void
VoiceActivityDetector
::
Reset
()
const
{
SherpaOnnxVoiceActivityDetectorReset
(
p_
);
}
...
...
sherpa-onnx/c-api/cxx-api.h
查看文件 @
1cca41b
...
...
@@ -349,6 +349,8 @@ class SHERPA_ONNX_API OfflineRecognizer
OfflineRecognizerResult
GetResult
(
const
OfflineStream
*
s
)
const
;
std
::
shared_ptr
<
OfflineRecognizerResult
>
GetResultPtr
(
const
OfflineStream
*
s
)
const
;
void
SetConfig
(
const
OfflineRecognizerConfig
&
config
)
const
;
private
:
...
...
@@ -634,6 +636,8 @@ class SHERPA_ONNX_API VoiceActivityDetector
SpeechSegment
Front
()
const
;
std
::
shared_ptr
<
SpeechSegment
>
FrontPtr
()
const
;
void
Reset
()
const
;
void
Flush
()
const
;
...
...
请
注册
或
登录
后发表评论