Expose dither for JNI (#2215)
This commit is contained in:
@@ -6,10 +6,12 @@ package com.k2fsa.sherpa.onnx;
|
||||
public class FeatureConfig {
|
||||
private final int sampleRate;
|
||||
private final int featureDim;
|
||||
private final float dither;
|
||||
|
||||
private FeatureConfig(Builder builder) {
|
||||
this.sampleRate = builder.sampleRate;
|
||||
this.featureDim = builder.featureDim;
|
||||
this.dither = builder.dither;
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
@@ -24,9 +26,14 @@ public class FeatureConfig {
|
||||
return featureDim;
|
||||
}
|
||||
|
||||
public float getDither() {
|
||||
return dither;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private int sampleRate = 16000;
|
||||
private int featureDim = 80;
|
||||
private float dither = 0.0f;
|
||||
|
||||
public FeatureConfig build() {
|
||||
return new FeatureConfig(this);
|
||||
@@ -41,5 +48,9 @@ public class FeatureConfig {
|
||||
this.featureDim = featureDim;
|
||||
return this;
|
||||
}
|
||||
public Builder setDither(float dither) {
|
||||
this.dither = dither;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,9 @@ static KeywordSpotterConfig GetKwsConfig(JNIEnv *env, jobject config) {
|
||||
fid = env->GetFieldID(feat_config_cls, "featureDim", "I");
|
||||
ans.feat_config.feature_dim = env->GetIntField(feat_config, fid);
|
||||
|
||||
fid = env->GetFieldID(feat_config_cls, "dither", "F");
|
||||
ans.feat_config.dither = env->GetFloatField(feat_config, fid);
|
||||
|
||||
//---------- model config ----------
|
||||
fid = env->GetFieldID(cls, "modelConfig",
|
||||
"Lcom/k2fsa/sherpa/onnx/OnlineModelConfig;");
|
||||
|
||||
@@ -62,6 +62,9 @@ static OfflineRecognizerConfig GetOfflineConfig(JNIEnv *env, jobject config) {
|
||||
fid = env->GetFieldID(feat_config_cls, "featureDim", "I");
|
||||
ans.feat_config.feature_dim = env->GetIntField(feat_config, fid);
|
||||
|
||||
fid = env->GetFieldID(feat_config_cls, "dither", "F");
|
||||
ans.feat_config.dither = env->GetFloatField(feat_config, fid);
|
||||
|
||||
//---------- model config ----------
|
||||
fid = env->GetFieldID(cls, "modelConfig",
|
||||
"Lcom/k2fsa/sherpa/onnx/OfflineModelConfig;");
|
||||
|
||||
@@ -65,6 +65,9 @@ static OnlineRecognizerConfig GetConfig(JNIEnv *env, jobject config) {
|
||||
fid = env->GetFieldID(feat_config_cls, "featureDim", "I");
|
||||
ans.feat_config.feature_dim = env->GetIntField(feat_config, fid);
|
||||
|
||||
fid = env->GetFieldID(feat_config_cls, "dither", "F");
|
||||
ans.feat_config.dither = env->GetFloatField(feat_config, fid);
|
||||
|
||||
//---------- enable endpoint ----------
|
||||
fid = env->GetFieldID(cls, "enableEndpoint", "Z");
|
||||
ans.enable_endpoint = env->GetBooleanField(config, fid);
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.k2fsa.sherpa.onnx
|
||||
data class FeatureConfig(
|
||||
var sampleRate: Int = 16000,
|
||||
var featureDim: Int = 80,
|
||||
var dither: Float = 0.0f
|
||||
)
|
||||
|
||||
fun getFeatureConfig(sampleRate: Int, featureDim: Int): FeatureConfig {
|
||||
|
||||
Reference in New Issue
Block a user