Skip to content

Commit

Permalink
Expose 'language' 'task' 'tailPaddings' in OfflineWhisperModelConfig (#…
Browse files Browse the repository at this point in the history
…643)

Co-authored-by: Gary <[email protected]>
  • Loading branch information
GaryLaurenceauAva and GaryLaurenceau authored Mar 8, 2024
1 parent 4b708e0 commit ac43c2d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ data class OfflineParaformerModelConfig(
data class OfflineWhisperModelConfig(
var encoder: String = "",
var decoder: String = "",
var language: String = "en", // Used with multilingual model
var task: String = "transcribe", // transcribe or translate
var tailPaddings: Int = 1000, // Padding added at the end of the samples
)

data class OfflineModelConfig(
Expand Down
16 changes: 16 additions & 0 deletions sherpa-onnx/jni/jni.cc
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,22 @@ static OfflineRecognizerConfig GetOfflineConfig(JNIEnv *env, jobject config) {
ans.model_config.whisper.decoder = p;
env->ReleaseStringUTFChars(s, p);

fid = env->GetFieldID(whisper_config_cls, "language", "Ljava/lang/String;");
s = (jstring)env->GetObjectField(whisper_config, fid);
p = env->GetStringUTFChars(s, nullptr);
ans.model_config.whisper.language = p;
env->ReleaseStringUTFChars(s, p);

fid = env->GetFieldID(whisper_config_cls, "task", "Ljava/lang/String;");
s = (jstring)env->GetObjectField(whisper_config, fid);
p = env->GetStringUTFChars(s, nullptr);
ans.model_config.whisper.task = p;
env->ReleaseStringUTFChars(s, p);

fid = env->GetFieldID(whisper_config_cls, "tailPaddings", "I");
ans.model_config.whisper.tail_paddings = env->GetIntField(whisper_config,
fid);

return ans;
}

Expand Down

0 comments on commit ac43c2d

Please sign in to comment.