Add Java API for spoken language identification with whisper multilingual models (#817)

This commit is contained in:
Fangjun Kuang
2024-04-26 19:05:39 +08:00
committed by GitHub
parent f2d074aea9
commit db25986240
12 changed files with 406 additions and 11 deletions

View File

@@ -0,0 +1,56 @@
// Copyright 2024 Xiaomi Corporation
package com.k2fsa.sherpa.onnx;
public class SpokenLanguageIdentificationConfig {
private final SpokenLanguageIdentificationWhisperConfig whisper;
private final int numThreads;
private final boolean debug;
private final String provider;
private SpokenLanguageIdentificationConfig(Builder builder) {
this.whisper = builder.whisper;
this.numThreads = builder.numThreads;
this.debug = builder.debug;
this.provider = builder.provider;
}
public static Builder builder() {
return new Builder();
}
public SpokenLanguageIdentificationWhisperConfig getWhisper() {
return whisper;
}
public static class Builder {
private SpokenLanguageIdentificationWhisperConfig whisper = SpokenLanguageIdentificationWhisperConfig.builder().build();
private int numThreads = 1;
private boolean debug = true;
private String provider = "cpu";
public SpokenLanguageIdentificationConfig build() {
return new SpokenLanguageIdentificationConfig(this);
}
public Builder setWhisper(SpokenLanguageIdentificationWhisperConfig whisper) {
this.whisper = whisper;
return this;
}
public Builder setNumThreads(int numThreads) {
this.numThreads = numThreads;
return this;
}
public Builder setDebug(boolean debug) {
this.debug = debug;
return this;
}
public Builder setProvider(String provider) {
this.provider = provider;
return this;
}
}
}