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-06-12 10:49:37 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2024-06-12 10:49:37 +0800
Commit
208da78343838b754ec26dc117ddf6f0b8d1b3d7
208da783
1 parent
aac86847
Limit the maximum segment length for VAD. (#990)
隐藏空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
33 行增加
和
0 行删除
sherpa-onnx/csrc/silero-vad-model.cc
sherpa-onnx/csrc/silero-vad-model.h
sherpa-onnx/csrc/vad-model.h
sherpa-onnx/csrc/voice-activity-detector.cc
sherpa-onnx/csrc/silero-vad-model.cc
查看文件 @
208da78
...
...
@@ -190,6 +190,14 @@ class SileroVadModel::Impl {
int32_t
MinSpeechDurationSamples
()
const
{
return
min_speech_samples_
;
}
void
SetMinSilenceDuration
(
float
s
)
{
min_silence_samples_
=
sample_rate_
*
s
;
}
void
SetThreshold
(
float
threshold
)
{
config_
.
silero_vad
.
threshold
=
threshold
;
}
private
:
void
Init
(
void
*
model_data
,
size_t
model_data_length
)
{
sess_
=
std
::
make_unique
<
Ort
::
Session
>
(
env_
,
model_data
,
model_data_length
,
...
...
@@ -306,4 +314,12 @@ int32_t SileroVadModel::MinSpeechDurationSamples() const {
return
impl_
->
MinSpeechDurationSamples
();
}
void
SileroVadModel
::
SetMinSilenceDuration
(
float
s
)
{
impl_
->
SetMinSilenceDuration
(
s
);
}
void
SileroVadModel
::
SetThreshold
(
float
threshold
)
{
impl_
->
SetThreshold
(
threshold
);
}
}
// namespace sherpa_onnx
...
...
sherpa-onnx/csrc/silero-vad-model.h
查看文件 @
208da78
...
...
@@ -42,6 +42,9 @@ class SileroVadModel : public VadModel {
int32_t
MinSilenceDurationSamples
()
const
override
;
int32_t
MinSpeechDurationSamples
()
const
override
;
void
SetMinSilenceDuration
(
float
s
)
override
;
void
SetThreshold
(
float
threshold
)
override
;
private
:
class
Impl
;
std
::
unique_ptr
<
Impl
>
impl_
;
...
...
sherpa-onnx/csrc/vad-model.h
查看文件 @
208da78
...
...
@@ -42,6 +42,8 @@ class VadModel {
virtual
int32_t
MinSilenceDurationSamples
()
const
=
0
;
virtual
int32_t
MinSpeechDurationSamples
()
const
=
0
;
virtual
void
SetMinSilenceDuration
(
float
s
)
=
0
;
virtual
void
SetThreshold
(
float
threshold
)
=
0
;
};
}
// namespace sherpa_onnx
...
...
sherpa-onnx/csrc/voice-activity-detector.cc
查看文件 @
208da78
...
...
@@ -29,6 +29,14 @@ class VoiceActivityDetector::Impl {
#endif
void
AcceptWaveform
(
const
float
*
samples
,
int32_t
n
)
{
if
(
buffer_
.
Size
()
>
max_utterance_length_
)
{
model_
->
SetMinSilenceDuration
(
new_min_silence_duration_s_
);
model_
->
SetThreshold
(
new_threshold_
);
}
else
{
model_
->
SetMinSilenceDuration
(
config_
.
silero_vad
.
min_silence_duration
);
model_
->
SetThreshold
(
config_
.
silero_vad
.
threshold
);
}
int32_t
window_size
=
model_
->
WindowSize
();
// note n is usually window_size and there is no need to use
...
...
@@ -114,6 +122,10 @@ class VoiceActivityDetector::Impl {
CircularBuffer
buffer_
;
std
::
vector
<
float
>
last_
;
int
max_utterance_length_
=
16000
*
20
;
// in samples
float
new_min_silence_duration_s_
=
0.1
;
float
new_threshold_
=
1.10
;
int32_t
start_
=
-
1
;
};
...
...
请
注册
或
登录
后发表评论