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
張小凡
2024-11-05 20:34:12 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2024-11-05 20:34:12 +0800
Commit
86b1856c207761d999228c2f14f013908b5047c9
86b1856c
1 parent
4eeb336f
Reduce vad-sense-voice example code. (#1510)
隐藏空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
11 行增加
和
35 行删除
c-api-examples/vad-sense-voice-c-api.c
c-api-examples/vad-sense-voice-c-api.c
查看文件 @
86b1856
...
...
@@ -99,11 +99,16 @@ int32_t main() {
int32_t
window_size
=
vadConfig
.
silero_vad
.
window_size
;
int32_t
i
=
0
;
while
(
i
+
window_size
<
wave
->
num_samples
)
{
SherpaOnnxVoiceActivityDetectorAcceptWaveform
(
vad
,
wave
->
samples
+
i
,
window_size
);
i
+=
window_size
;
int
is_eof
=
0
;
while
(
!
is_eof
)
{
if
(
i
+
window_size
<
wave
->
num_samples
)
{
SherpaOnnxVoiceActivityDetectorAcceptWaveform
(
vad
,
wave
->
samples
+
i
,
window_size
);
}
else
{
SherpaOnnxVoiceActivityDetectorFlush
(
vad
);
is_eof
=
1
;
}
while
(
!
SherpaOnnxVoiceActivityDetectorEmpty
(
vad
))
{
const
SherpaOnnxSpeechSegment
*
segment
=
...
...
@@ -132,36 +137,7 @@ int32_t main() {
SherpaOnnxDestroySpeechSegment
(
segment
);
SherpaOnnxVoiceActivityDetectorPop
(
vad
);
}
}
SherpaOnnxVoiceActivityDetectorFlush
(
vad
);
while
(
!
SherpaOnnxVoiceActivityDetectorEmpty
(
vad
))
{
const
SherpaOnnxSpeechSegment
*
segment
=
SherpaOnnxVoiceActivityDetectorFront
(
vad
);
const
SherpaOnnxOfflineStream
*
stream
=
SherpaOnnxCreateOfflineStream
(
recognizer
);
SherpaOnnxAcceptWaveformOffline
(
stream
,
wave
->
sample_rate
,
segment
->
samples
,
segment
->
n
);
SherpaOnnxDecodeOfflineStream
(
recognizer
,
stream
);
const
SherpaOnnxOfflineRecognizerResult
*
result
=
SherpaOnnxGetOfflineStreamResult
(
stream
);
float
start
=
segment
->
start
/
16000
.
0
f
;
float
duration
=
segment
->
n
/
16000
.
0
f
;
float
stop
=
start
+
duration
;
fprintf
(
stderr
,
"%.3f -- %.3f: %s
\n
"
,
start
,
stop
,
result
->
text
);
SherpaOnnxDestroyOfflineRecognizerResult
(
result
);
SherpaOnnxDestroyOfflineStream
(
stream
);
SherpaOnnxDestroySpeechSegment
(
segment
);
SherpaOnnxVoiceActivityDetectorPop
(
vad
);
i
+=
window_size
;
}
SherpaOnnxDestroyOfflineRecognizer
(
recognizer
);
...
...
请
注册
或
登录
后发表评论