Skip to content

Commit

Permalink
Added proper validation for speechDurationMs and speechDurationMs
Browse files Browse the repository at this point in the history
  • Loading branch information
gkonovalov committed Dec 23, 2023
1 parent 71ac722 commit f6d9459
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions silero/src/main/java/com/konovalov/vad/silero/VadSilero.kt
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,8 @@ class VadSilero(
*/
var speechDurationMs: Int = speechDurationMs
set(speechDurationMs) {
require(speechDurationMs >= 0) {
"The parameter 'speechDurationMs' cannot be smaller than zero!"
require(speechDurationMs in 0..300000) {
"The parameter 'speechDurationMs' should be >= 0ms and <= 300000ms!"
}

field = speechDurationMs
Expand All @@ -399,8 +399,8 @@ class VadSilero(
*/
var silenceDurationMs: Int = silenceDurationMs
set(silenceDurationMs) {
require(silenceDurationMs >= 0) {
"The parameter 'silenceDurationMs' cannot be smaller than zero!"
require(silenceDurationMs in 0..300000) {
"The parameter 'silenceDurationMs' should be >= 0ms and <= 300000ms!"
}

field = silenceDurationMs
Expand Down
8 changes: 4 additions & 4 deletions webrtc/src/main/java/com/konovalov/vad/webrtc/VadWebRTC.kt
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ class VadWebRTC(
*/
var speechDurationMs: Int = speechDurationMs
set(speechDurationMs) {
require(speechDurationMs >= 0) {
"The parameter 'speechDurationMs' cannot be smaller than zero!"
require(speechDurationMs in 0..300000) {
"The parameter 'speechDurationMs' should be >= 0ms and <= 300000ms!"
}

field = speechDurationMs
Expand All @@ -314,8 +314,8 @@ class VadWebRTC(
*/
var silenceDurationMs: Int = silenceDurationMs
set(silenceDurationMs) {
require(silenceDurationMs >= 0) {
"The parameter 'silenceDurationMs' cannot be smaller than zero!"
require(silenceDurationMs in 0..300000) {
"The parameter 'silenceDurationMs' should be >= 0ms and <= 300000ms!"
}

field = silenceDurationMs
Expand Down
8 changes: 4 additions & 4 deletions yamnet/src/main/java/com/konovalov/vad/yamnet/VadYamnet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,8 @@ class VadYamnet(
*/
var speechDurationMs: Int = speechDurationMs
set(speechDurationMs) {
require(speechDurationMs >= 0) {
"The parameter 'speechDurationMs' cannot be smaller than zero!"
require(speechDurationMs in 0..300000) {
"The parameter 'speechDurationMs' should be >= 0ms and <= 300000ms!"
}

field = speechDurationMs
Expand All @@ -393,8 +393,8 @@ class VadYamnet(
*/
var silenceDurationMs: Int = silenceDurationMs
set(silenceDurationMs) {
require(silenceDurationMs >= 0) {
"The parameter 'silenceDurationMs' cannot be smaller than zero!"
require(silenceDurationMs in 0..300000) {
"The parameter 'silenceDurationMs' should be >= 0ms and <= 300000ms!"
}

field = silenceDurationMs
Expand Down

0 comments on commit f6d9459

Please sign in to comment.