This repository has been archived on 2025-08-26. You can view files and clone it, but cannot push or open issues or pull requests.
Files
enginex-mr_series-sherpa-onnx/sherpa-onnx/java-api/src/com/k2fsa/sherpa/onnx/OnlineRecognizerConfig.java

107 lines
3.7 KiB
Java
Raw Normal View History

2024-04-24 18:41:48 +08:00
// Copyright 2022-2023 by zhaoming
// Copyright 2024 Xiaomi Corporation
2024-04-28 22:26:04 +08:00
2023-04-15 22:17:28 +08:00
package com.k2fsa.sherpa.onnx;
public class OnlineRecognizerConfig {
2024-02-26 13:49:37 +08:00
private final FeatureConfig featConfig;
private final OnlineModelConfig modelConfig;
private final OnlineLMConfig lmConfig;
2024-04-25 17:20:02 +08:00
private final OnlineCtcFstDecoderConfig ctcFstDecoderConfig;
2024-04-24 18:41:48 +08:00
private final EndpointConfig endpointConfig;
2024-02-26 13:49:37 +08:00
private final boolean enableEndpoint;
private final String decodingMethod;
private final int maxActivePaths;
private final String hotwordsFile;
private final float hotwordsScore;
2024-04-24 18:41:48 +08:00
private OnlineRecognizerConfig(Builder builder) {
this.featConfig = builder.featConfig;
this.modelConfig = builder.modelConfig;
this.lmConfig = builder.lmConfig;
2024-04-25 17:20:02 +08:00
this.ctcFstDecoderConfig = builder.ctcFstDecoderConfig;
2024-04-24 18:41:48 +08:00
this.endpointConfig = builder.endpointConfig;
this.enableEndpoint = builder.enableEndpoint;
this.decodingMethod = builder.decodingMethod;
this.maxActivePaths = builder.maxActivePaths;
this.hotwordsFile = builder.hotwordsFile;
this.hotwordsScore = builder.hotwordsScore;
2024-02-26 13:49:37 +08:00
}
2023-04-15 22:17:28 +08:00
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 OnlineModelConfig getModelConfig() {
return modelConfig;
}
2023-04-15 22:17:28 +08:00
2024-04-24 18:41:48 +08:00
public static class Builder {
private FeatureConfig featConfig = FeatureConfig.builder().build();
private OnlineModelConfig modelConfig = OnlineModelConfig.builder().build();
private OnlineLMConfig lmConfig = OnlineLMConfig.builder().build();
2024-04-25 17:20:02 +08:00
private OnlineCtcFstDecoderConfig ctcFstDecoderConfig = OnlineCtcFstDecoderConfig.builder().build();
2024-04-24 18:41:48 +08:00
private EndpointConfig endpointConfig = EndpointConfig.builder().build();
private boolean enableEndpoint = true;
private String decodingMethod = "greedy_search";
private int maxActivePaths = 4;
private String hotwordsFile = "";
private float hotwordsScore = 1.5f;
2023-04-15 22:17:28 +08:00
2024-04-24 18:41:48 +08:00
public OnlineRecognizerConfig build() {
return new OnlineRecognizerConfig(this);
}
2023-04-15 22:17:28 +08:00
2024-04-24 18:41:48 +08:00
public Builder setFeatureConfig(FeatureConfig featConfig) {
this.featConfig = featConfig;
return this;
}
public Builder setOnlineModelConfig(OnlineModelConfig modelConfig) {
this.modelConfig = modelConfig;
return this;
}
public Builder setOnlineLMConfig(OnlineLMConfig lmConfig) {
this.lmConfig = lmConfig;
return this;
}
2024-04-25 17:20:02 +08:00
public Builder setCtcFstDecoderConfig(OnlineCtcFstDecoderConfig ctcFstDecoderConfig) {
this.ctcFstDecoderConfig = ctcFstDecoderConfig;
return this;
}
2024-04-24 18:41:48 +08:00
public Builder setEndpointConfig(EndpointConfig endpointConfig) {
this.endpointConfig = endpointConfig;
return this;
}
public Builder setEnableEndpoint(boolean enableEndpoint) {
this.enableEndpoint = enableEndpoint;
return this;
}
public Builder setDecodingMethod(String decodingMethod) {
this.decodingMethod = decodingMethod;
return this;
}
public Builder setMaxActivePaths(int maxActivePaths) {
this.maxActivePaths = maxActivePaths;
return this;
}
public Builder setHotwordsFile(String hotwordsFile) {
this.hotwordsFile = hotwordsFile;
return this;
}
2023-04-15 22:17:28 +08:00
2024-04-24 18:41:48 +08:00
public Builder setHotwordsScore(float hotwordsScore) {
this.hotwordsScore = hotwordsScore;
return this;
}
2024-02-26 13:49:37 +08:00
}
2023-04-15 22:17:28 +08:00
}