Skip to content

Commit

Permalink
Fix Java API examples (#883)
Browse files Browse the repository at this point in the history
  • Loading branch information
csukuangfj authored May 16, 2024
1 parent d274569 commit a421f8c
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions sherpa-onnx/java-api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ java_files += FeatureConfig.java
java_files += OnlineLMConfig.java
java_files += OnlineParaformerModelConfig.java
java_files += OnlineZipformer2CtcModelConfig.java
java_files += OnlineNeMoCtcModelConfig.java
java_files += OnlineTransducerModelConfig.java
java_files += OnlineModelConfig.java
java_files += OnlineCtcFstDecoderConfig.java
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class OnlineModelConfig {
private final OnlineTransducerModelConfig transducer;
private final OnlineParaformerModelConfig paraformer;
private final OnlineZipformer2CtcModelConfig zipformer2Ctc;
private final OnlineNeMoCtcModelConfig neMoCtc;
private final String tokens;
private final int numThreads;
private final boolean debug;
Expand All @@ -17,6 +18,7 @@ private OnlineModelConfig(Builder builder) {
this.transducer = builder.transducer;
this.paraformer = builder.paraformer;
this.zipformer2Ctc = builder.zipformer2Ctc;
this.neMoCtc = builder.neMoCtc;
this.tokens = builder.tokens;
this.numThreads = builder.numThreads;
this.debug = builder.debug;
Expand All @@ -40,6 +42,10 @@ public OnlineZipformer2CtcModelConfig getZipformer2Ctc() {
return zipformer2Ctc;
}

public OnlineNeMoCtcModelConfig getNeMoCtc() {
return neMoCtc;
}

public String getTokens() {
return tokens;
}
Expand All @@ -64,6 +70,7 @@ public static class Builder {
private OnlineParaformerModelConfig paraformer = OnlineParaformerModelConfig.builder().build();
private OnlineTransducerModelConfig transducer = OnlineTransducerModelConfig.builder().build();
private OnlineZipformer2CtcModelConfig zipformer2Ctc = OnlineZipformer2CtcModelConfig.builder().build();
private OnlineNeMoCtcModelConfig neMoCtc = OnlineNeMoCtcModelConfig.builder().build();
private String tokens = "";
private int numThreads = 1;
private boolean debug = true;
Expand All @@ -89,6 +96,11 @@ public Builder setZipformer2Ctc(OnlineZipformer2CtcModelConfig zipformer2Ctc) {
return this;
}

public Builder setNeMoCtc(OnlineNeMoCtcModelConfig neMoCtc) {
this.neMoCtc = neMoCtc;
return this;
}

public Builder setTokens(String tokens) {
this.tokens = tokens;
return this;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2024 Xiaomi Corporation
package com.k2fsa.sherpa.onnx;

public class OnlineNeMoCtcModelConfig {
private final String model;

private OnlineNeMoCtcModelConfig(Builder builder) {
this.model = builder.model;
}

public static Builder builder() {
return new Builder();
}

public String getModel() {
return model;
}

public static class Builder {
private String model = "";

public OnlineNeMoCtcModelConfig build() {
return new OnlineNeMoCtcModelConfig(this);
}

public Builder setModel(String model) {
this.model = model;
return this;
}
}

}

0 comments on commit a421f8c

Please sign in to comment.