2024-04-24 18:41:48 +08:00
|
|
|
// Copyright 2022-2023 by zhaoming
|
|
|
|
|
// Copyright 2024 Xiaomi Corporation
|
2023-04-15 22:17:28 +08:00
|
|
|
|
|
|
|
|
package com.k2fsa.sherpa.onnx;
|
|
|
|
|
|
|
|
|
|
public class FeatureConfig {
|
2024-02-26 13:49:37 +08:00
|
|
|
private final int sampleRate;
|
|
|
|
|
private final int featureDim;
|
2025-05-14 18:38:25 +03:00
|
|
|
private final float dither;
|
2023-04-15 22:17:28 +08:00
|
|
|
|
2024-04-24 18:41:48 +08:00
|
|
|
private FeatureConfig(Builder builder) {
|
|
|
|
|
this.sampleRate = builder.sampleRate;
|
|
|
|
|
this.featureDim = builder.featureDim;
|
2025-05-14 18:38:25 +03:00
|
|
|
this.dither = builder.dither;
|
2024-04-24 18:41:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static Builder builder() {
|
|
|
|
|
return new Builder();
|
2024-02-26 13:49:37 +08:00
|
|
|
}
|
2023-04-15 22:17:28 +08:00
|
|
|
|
2024-02-26 13:49:37 +08:00
|
|
|
public int getSampleRate() {
|
|
|
|
|
return sampleRate;
|
|
|
|
|
}
|
2023-04-15 22:17:28 +08:00
|
|
|
|
2024-02-26 13:49:37 +08:00
|
|
|
public int getFeatureDim() {
|
|
|
|
|
return featureDim;
|
|
|
|
|
}
|
2024-04-24 18:41:48 +08:00
|
|
|
|
2025-05-14 18:38:25 +03:00
|
|
|
public float getDither() {
|
|
|
|
|
return dither;
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-24 18:41:48 +08:00
|
|
|
public static class Builder {
|
|
|
|
|
private int sampleRate = 16000;
|
|
|
|
|
private int featureDim = 80;
|
2025-05-14 18:38:25 +03:00
|
|
|
private float dither = 0.0f;
|
2024-04-24 18:41:48 +08:00
|
|
|
|
|
|
|
|
public FeatureConfig build() {
|
|
|
|
|
return new FeatureConfig(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Builder setSampleRate(int sampleRate) {
|
|
|
|
|
this.sampleRate = sampleRate;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Builder setFeatureDim(int featureDim) {
|
|
|
|
|
this.featureDim = featureDim;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
2025-05-14 18:38:25 +03:00
|
|
|
public Builder setDither(float dither) {
|
|
|
|
|
this.dither = dither;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
2024-04-24 18:41:48 +08:00
|
|
|
}
|
2023-04-15 22:17:28 +08:00
|
|
|
}
|