Skip to content

Commit

Permalink
Update offline-recognizer.cc (#1253)
Browse files Browse the repository at this point in the history
Adding setConfig method to JNI to support setting a config on the previously initialized offline-recognizer.
  • Loading branch information
iprovalo authored Aug 13, 2024
1 parent 619279b commit 9f06b05
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions sherpa-onnx/jni/offline-recognizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,20 @@ Java_com_k2fsa_sherpa_onnx_OfflineRecognizer_newFromFile(JNIEnv *env,
return (jlong)model;
}


SHERPA_ONNX_EXTERN_C
JNIEXPORT void JNICALL
Java_com_k2fsa_sherpa_onnx_OfflineRecognizer_setConfig(JNIEnv *env,
jobject /*obj*/,
jlong ptr,
jobject _config) {
auto config = sherpa_onnx::GetOfflineConfig(env, _config);
SHERPA_ONNX_LOGE("config:\n%s", config.ToString().c_str());

auto recognizer = reinterpret_cast<sherpa_onnx::OfflineRecognizer *>(ptr);
recognizer->SetConfig(config);
}

SHERPA_ONNX_EXTERN_C
JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_OfflineRecognizer_delete(
JNIEnv * /*env*/, jobject /*obj*/, jlong ptr) {
Expand Down

0 comments on commit 9f06b05

Please sign in to comment.