log:
Solutions
1. 確保 std::string 是有效的 UTF-8
env->NewStringUTF() 只能處理有效的 UTF-8 字符串。如果 transcribeMelBuffer 返回的 std::string 不是 UTF-8,則應該先進行轉換。例如:
std::string result = engine->transcribeMelBuffer(sampleVector);
// 確保 result 是 UTF-8
if (!isValidUTF8(result)) {
return env->NewStringUTF("Error: Invalid UTF-8 output");
}
return env->NewStringUTF(result.c_str());
About 2 min