Support specifying max speech duration for VAD. (#1348)
This commit is contained in:
@@ -28,6 +28,12 @@ void SileroVadModelConfig::Register(ParseOptions *po) {
|
||||
"In seconds. In the end of each silence chunk wait for "
|
||||
"--silero-vad-min-speech-duration seconds before separating it");
|
||||
|
||||
po->Register(
|
||||
"silero-vad-max-speech-duration", &max_speech_duration,
|
||||
"In seconds. If a speech segment is longer than this value, then we "
|
||||
"increase the threshold to 0.9. After finishing detecting the segment, "
|
||||
"the threshold value is reset to its original value.");
|
||||
|
||||
po->Register(
|
||||
"silero-vad-window-size", &window_size,
|
||||
"In samples. Audio chunks of --silero-vad-window-size samples are fed "
|
||||
@@ -63,6 +69,33 @@ bool SileroVadModelConfig::Validate() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (min_silence_duration <= 0) {
|
||||
SHERPA_ONNX_LOGE(
|
||||
"Please use a larger value for --silero-vad-min-silence-duration. "
|
||||
"Given: "
|
||||
"%f",
|
||||
min_silence_duration);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (min_speech_duration <= 0) {
|
||||
SHERPA_ONNX_LOGE(
|
||||
"Please use a larger value for --silero-vad-min-speech-duration. "
|
||||
"Given: "
|
||||
"%f",
|
||||
min_speech_duration);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (max_speech_duration <= 0) {
|
||||
SHERPA_ONNX_LOGE(
|
||||
"Please use a larger value for --silero-vad-max-speech-duration. "
|
||||
"Given: "
|
||||
"%f",
|
||||
max_speech_duration);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -74,6 +107,7 @@ std::string SileroVadModelConfig::ToString() const {
|
||||
os << "threshold=" << threshold << ", ";
|
||||
os << "min_silence_duration=" << min_silence_duration << ", ";
|
||||
os << "min_speech_duration=" << min_speech_duration << ", ";
|
||||
os << "max_speech_duration=" << max_speech_duration << ", ";
|
||||
os << "window_size=" << window_size << ")";
|
||||
|
||||
return os.str();
|
||||
|
||||
Reference in New Issue
Block a user