diff --git a/android/SherpaOnnx2Pass/app/src/main/java/com/k2fsa/sherpa/onnx/SherpaOnnx.kt b/android/SherpaOnnx2Pass/app/src/main/java/com/k2fsa/sherpa/onnx/SherpaOnnx.kt index 228f19c1f..601ecf83f 100644 --- a/android/SherpaOnnx2Pass/app/src/main/java/com/k2fsa/sherpa/onnx/SherpaOnnx.kt +++ b/android/SherpaOnnx2Pass/app/src/main/java/com/k2fsa/sherpa/onnx/SherpaOnnx.kt @@ -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( diff --git a/sherpa-onnx/jni/jni.cc b/sherpa-onnx/jni/jni.cc index a8f0ef4a3..1dbf96a7d 100644 --- a/sherpa-onnx/jni/jni.cc +++ b/sherpa-onnx/jni/jni.cc @@ -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; }