MCPcopy Create free account
hub / github.com/cactus-compute/cactus / Java_com_cactus_CactusJNI_nativeAudioEmbed

Function Java_com_cactus_CactusJNI_nativeAudioEmbed

android/cactus_jni.cpp:478–503  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

476}
477
478JNIEXPORT jfloatArray JNICALL
479Java_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
505JNIEXPORT jstring JNICALL
506Java_com_cactus_CactusJNI_nativeVad(JNIEnv* env, jobject, jlong handle,

Callers

nothing calls this directly

Calls 7

throwCactusExceptionFunction · 0.85
jstring_to_cstrFunction · 0.85
release_jstringFunction · 0.85
throwOnErrorFunction · 0.85
dataMethod · 0.80
sizeMethod · 0.80
cactus_audio_embedFunction · 0.50

Tested by

no test coverage detected