whisper.rn 0.4.0-rc.3 → 0.4.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/CMakeLists.txt +2 -0
- package/android/src/main/java/com/rnwhisper/RNWhisper.java +6 -1
- package/android/src/main/java/com/rnwhisper/WhisperContext.java +3 -3
- package/android/src/main/jni.cpp +6 -2
- package/cpp/ggml-alloc.c +413 -280
- package/cpp/ggml-alloc.h +67 -8
- package/cpp/ggml-backend-impl.h +87 -0
- package/cpp/ggml-backend.c +950 -0
- package/cpp/ggml-backend.h +136 -0
- package/cpp/ggml-impl.h +243 -0
- package/cpp/{ggml-metal.metal → ggml-metal-whisper.metal} +591 -121
- package/cpp/ggml-metal.h +21 -0
- package/cpp/ggml-metal.m +623 -234
- package/cpp/ggml-quants.c +7377 -0
- package/cpp/ggml-quants.h +224 -0
- package/cpp/ggml.c +3773 -4455
- package/cpp/ggml.h +279 -146
- package/cpp/whisper.cpp +182 -103
- package/cpp/whisper.h +48 -11
- package/ios/RNWhisper.mm +8 -2
- package/ios/RNWhisper.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
- package/ios/RNWhisper.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/RNWhisper.xcodeproj/project.xcworkspace/xcuserdata/jhen.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/RNWhisper.xcodeproj/xcuserdata/jhen.xcuserdatad/xcschemes/xcschememanagement.plist +19 -0
- package/ios/RNWhisperContext.h +5 -1
- package/ios/RNWhisperContext.mm +76 -10
- package/jest/mock.js +1 -1
- package/lib/commonjs/NativeRNWhisper.js.map +1 -1
- package/lib/commonjs/index.js +28 -9
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/NativeRNWhisper.js.map +1 -1
- package/lib/module/index.js +28 -9
- package/lib/module/index.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/NativeRNWhisper.d.ts +7 -1
- package/lib/typescript/NativeRNWhisper.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +7 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/NativeRNWhisper.ts +8 -1
- package/src/index.ts +29 -17
- package/src/version.json +1 -1
- package/whisper-rn.podspec +1 -2
|
@@ -9,6 +9,8 @@ set(
|
|
|
9
9
|
SOURCE_FILES
|
|
10
10
|
${RNWHISPER_LIB_DIR}/ggml.c
|
|
11
11
|
${RNWHISPER_LIB_DIR}/ggml-alloc.c
|
|
12
|
+
${RNWHISPER_LIB_DIR}/ggml-backend.c
|
|
13
|
+
${RNWHISPER_LIB_DIR}/ggml-quants.c
|
|
12
14
|
${RNWHISPER_LIB_DIR}/whisper.cpp
|
|
13
15
|
${RNWHISPER_LIB_DIR}/rn-whisper.cpp
|
|
14
16
|
${CMAKE_SOURCE_DIR}/jni.cpp
|
|
@@ -13,6 +13,7 @@ import com.facebook.react.bridge.ReactMethod;
|
|
|
13
13
|
import com.facebook.react.bridge.LifecycleEventListener;
|
|
14
14
|
import com.facebook.react.bridge.ReadableMap;
|
|
15
15
|
import com.facebook.react.bridge.WritableMap;
|
|
16
|
+
import com.facebook.react.bridge.Arguments;
|
|
16
17
|
|
|
17
18
|
import java.util.HashMap;
|
|
18
19
|
import java.util.Random;
|
|
@@ -107,7 +108,11 @@ public class RNWhisper implements LifecycleEventListener {
|
|
|
107
108
|
promise.reject(exception);
|
|
108
109
|
return;
|
|
109
110
|
}
|
|
110
|
-
|
|
111
|
+
WritableMap result = Arguments.createMap();
|
|
112
|
+
result.putInt("contextId", id);
|
|
113
|
+
result.putBoolean("gpu", false);
|
|
114
|
+
result.putString("reasonNoGPU", "Currently not supported");
|
|
115
|
+
promise.resolve(result);
|
|
111
116
|
tasks.remove(this);
|
|
112
117
|
}
|
|
113
118
|
}.execute();
|
|
@@ -278,7 +278,7 @@ public class WhisperContext {
|
|
|
278
278
|
|
|
279
279
|
if (code == 0) {
|
|
280
280
|
payload.putMap("data", getTextSegments(0, getTextSegmentCount(context)));
|
|
281
|
-
} else {
|
|
281
|
+
} else if (code != -999) { // Not aborted
|
|
282
282
|
payload.putString("error", "Transcribe failed with code " + code);
|
|
283
283
|
}
|
|
284
284
|
|
|
@@ -297,7 +297,7 @@ public class WhisperContext {
|
|
|
297
297
|
nSamplesTranscribing = 0;
|
|
298
298
|
}
|
|
299
299
|
|
|
300
|
-
boolean continueNeeded = !isCapturing && nSamplesTranscribing != nSamplesOfIndex;
|
|
300
|
+
boolean continueNeeded = !isCapturing && nSamplesTranscribing != nSamplesOfIndex && code != -999;
|
|
301
301
|
|
|
302
302
|
if (isStopped && !continueNeeded) {
|
|
303
303
|
payload.putBoolean("isCapturing", false);
|
|
@@ -386,7 +386,7 @@ public class WhisperContext {
|
|
|
386
386
|
int code = full(jobId, options, audioData, audioData.length);
|
|
387
387
|
isTranscribing = false;
|
|
388
388
|
this.jobId = -1;
|
|
389
|
-
if (code != 0) {
|
|
389
|
+
if (code != 0 && code != 999) {
|
|
390
390
|
throw new Exception("Failed to transcribe the file. Code: " + code);
|
|
391
391
|
}
|
|
392
392
|
WritableMap result = getTextSegments(0, getTextSegmentCount(context));
|
package/android/src/main/jni.cpp
CHANGED
|
@@ -297,16 +297,17 @@ Java_com_rnwhisper_WhisperContext_fullTranscribe(
|
|
|
297
297
|
}
|
|
298
298
|
|
|
299
299
|
// abort handlers
|
|
300
|
+
bool* abort_ptr = rn_whisper_assign_abort_map(job_id);
|
|
300
301
|
params.encoder_begin_callback = [](struct whisper_context * /*ctx*/, struct whisper_state * /*state*/, void * user_data) {
|
|
301
302
|
bool is_aborted = *(bool*)user_data;
|
|
302
303
|
return !is_aborted;
|
|
303
304
|
};
|
|
304
|
-
params.encoder_begin_callback_user_data =
|
|
305
|
+
params.encoder_begin_callback_user_data = abort_ptr;
|
|
305
306
|
params.abort_callback = [](void * user_data) {
|
|
306
307
|
bool is_aborted = *(bool*)user_data;
|
|
307
308
|
return is_aborted;
|
|
308
309
|
};
|
|
309
|
-
params.abort_callback_user_data =
|
|
310
|
+
params.abort_callback_user_data = abort_ptr;
|
|
310
311
|
|
|
311
312
|
if (callback_instance != nullptr) {
|
|
312
313
|
callback_context *cb_ctx = new callback_context;
|
|
@@ -344,6 +345,9 @@ Java_com_rnwhisper_WhisperContext_fullTranscribe(
|
|
|
344
345
|
}
|
|
345
346
|
env->ReleaseFloatArrayElements(audio_data, audio_data_arr, JNI_ABORT);
|
|
346
347
|
env->ReleaseStringUTFChars(language, language_chars);
|
|
348
|
+
if (rn_whisper_transcribe_is_aborted(job_id)) {
|
|
349
|
+
code = -999;
|
|
350
|
+
}
|
|
347
351
|
rn_whisper_remove_abort_map(job_id);
|
|
348
352
|
return code;
|
|
349
353
|
}
|