Add VAD demo for Java API (#928)

This commit is contained in:
Fangjun Kuang
2024-05-28 14:59:47 +08:00
committed by GitHub
parent b1c7d04ce2
commit bcaa6df389
14 changed files with 604 additions and 0 deletions

View File

@@ -0,0 +1,81 @@
// Copyright 2024 Xiaomi Corporation
package com.k2fsa.sherpa.onnx;
public class SileroVadModelConfig {
private final String model;
private final float threshold;
private final float minSilenceDuration;
private final float minSpeechDuration;
private final int windowSize;
private SileroVadModelConfig(Builder builder) {
this.model = builder.model;
this.threshold = builder.threshold;
this.minSilenceDuration = builder.minSilenceDuration;
this.minSpeechDuration = builder.minSpeechDuration;
this.windowSize = builder.windowSize;
}
public static Builder builder() {
return new Builder();
}
public String getModel() {
return model;
}
public float getThreshold() {
return threshold;
}
public float getMinSilenceDuration() {
return minSilenceDuration;
}
public float getMinSpeechDuration() {
return minSpeechDuration;
}
public int getWindowSize() {
return windowSize;
}
public static class Builder {
private String model = "";
private float threshold = 0.5f;
private float minSilenceDuration = 0.25f;
private float minSpeechDuration = 0.5f;
private int windowSize = 512;
public SileroVadModelConfig build() {
return new SileroVadModelConfig(this);
}
public Builder setModel(String model) {
this.model = model;
return this;
}
public Builder setThreshold(float threshold) {
this.threshold = threshold;
return this;
}
public Builder setMinSilenceDuration(float minSilenceDuration) {
this.minSilenceDuration = minSilenceDuration;
return this;
}
public Builder setMinSpeechDuration(float minSpeechDuration) {
this.minSpeechDuration = minSpeechDuration;
return this;
}
public Builder setWindowSize(int windowSize) {
this.windowSize = windowSize;
return this;
}
}
}