| 476 | } |
| 477 | |
| 478 | JNIEXPORT jfloatArray JNICALL |
| 479 | Java_com_cactus_CactusJNI_nativeAudioEmbed(JNIEnv* env, jobject, jlong handle, jstring audioPath) { |
| 480 | if (handle == 0) { throwCactusException(env, "Model not initialized"); return nullptr; } |
| 481 | |
| 482 | const char* path = jstring_to_cstr(env, audioPath); |
| 483 | std::vector<float> buffer(4096); |
| 484 | size_t embeddingDim = 0; |
| 485 | |
| 486 | int result = cactus_audio_embed( |
| 487 | reinterpret_cast<cactus_model_t>(handle), |
| 488 | path, |
| 489 | buffer.data(), |
| 490 | buffer.size(), |
| 491 | &embeddingDim |
| 492 | ); |
| 493 | |
| 494 | release_jstring(env, audioPath, path); |
| 495 | |
| 496 | if (result < 0) { throwOnError(env); return nullptr; } |
| 497 | |
| 498 | jfloatArray jarray = env->NewFloatArray(static_cast<jsize>(embeddingDim)); |
| 499 | if (embeddingDim > 0) { |
| 500 | env->SetFloatArrayRegion(jarray, 0, static_cast<jsize>(embeddingDim), buffer.data()); |
| 501 | } |
| 502 | return jarray; |
| 503 | } |
| 504 | |
| 505 | JNIEXPORT jstring JNICALL |
| 506 | Java_com_cactus_CactusJNI_nativeVad(JNIEnv* env, jobject, jlong handle, |
nothing calls this directly
no test coverage detected