whisper.rn 0.4.0-rc.8 → 0.4.0
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/README.md +5 -1
- package/android/build.gradle +12 -3
- package/android/src/main/CMakeLists.txt +44 -13
- package/android/src/main/java/com/rnwhisper/AudioUtils.java +27 -12
- package/android/src/main/java/com/rnwhisper/RNWhisper.java +75 -34
- package/android/src/main/java/com/rnwhisper/WhisperContext.java +53 -38
- package/android/src/main/jni.cpp +38 -1
- package/android/src/main/jniLibs/arm64-v8a/librnwhisper.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/librnwhisper_v8fp16_va_2.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/librnwhisper.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/librnwhisper_vfpv4.so +0 -0
- package/android/src/main/jniLibs/x86_64/librnwhisper.so +0 -0
- package/android/src/main/jniLibs/x86_64/librnwhisper_x86_64.so +0 -0
- package/android/src/newarch/java/com/rnwhisper/RNWhisperModule.java +10 -0
- package/android/src/oldarch/java/com/rnwhisper/RNWhisperModule.java +10 -0
- package/cpp/coreml/whisper-compat.h +10 -0
- package/cpp/coreml/whisper-compat.m +35 -0
- package/cpp/coreml/whisper-decoder-impl.h +27 -15
- package/cpp/coreml/whisper-decoder-impl.m +36 -10
- package/cpp/coreml/whisper-encoder-impl.h +21 -9
- package/cpp/coreml/whisper-encoder-impl.m +29 -3
- package/cpp/ggml-alloc.c +727 -517
- package/cpp/ggml-alloc.h +47 -65
- package/cpp/ggml-backend-impl.h +196 -57
- package/cpp/ggml-backend-reg.cpp +591 -0
- package/cpp/ggml-backend.cpp +2016 -0
- package/cpp/ggml-backend.h +234 -89
- package/cpp/ggml-common.h +1861 -0
- package/cpp/ggml-cpp.h +39 -0
- package/cpp/ggml-cpu/amx/amx.cpp +221 -0
- package/cpp/ggml-cpu/amx/amx.h +8 -0
- package/cpp/ggml-cpu/amx/common.h +91 -0
- package/cpp/ggml-cpu/amx/mmq.cpp +2511 -0
- package/cpp/ggml-cpu/amx/mmq.h +10 -0
- package/cpp/ggml-cpu/arch/arm/cpu-feats.cpp +94 -0
- package/cpp/ggml-cpu/arch/arm/quants.c +4113 -0
- package/cpp/ggml-cpu/arch/arm/repack.cpp +2162 -0
- package/cpp/ggml-cpu/arch/x86/cpu-feats.cpp +327 -0
- package/cpp/ggml-cpu/arch/x86/quants.c +4310 -0
- package/cpp/ggml-cpu/arch/x86/repack.cpp +3284 -0
- package/cpp/ggml-cpu/arch-fallback.h +184 -0
- package/cpp/ggml-cpu/binary-ops.cpp +158 -0
- package/cpp/ggml-cpu/binary-ops.h +16 -0
- package/cpp/ggml-cpu/common.h +72 -0
- package/cpp/ggml-cpu/ggml-cpu-impl.h +511 -0
- package/cpp/ggml-cpu/ggml-cpu.c +3473 -0
- package/cpp/ggml-cpu/ggml-cpu.cpp +671 -0
- package/cpp/ggml-cpu/ops.cpp +9085 -0
- package/cpp/ggml-cpu/ops.h +111 -0
- package/cpp/ggml-cpu/quants.c +1157 -0
- package/cpp/ggml-cpu/quants.h +89 -0
- package/cpp/ggml-cpu/repack.cpp +1570 -0
- package/cpp/ggml-cpu/repack.h +98 -0
- package/cpp/ggml-cpu/simd-mappings.h +1006 -0
- package/cpp/ggml-cpu/traits.cpp +36 -0
- package/cpp/ggml-cpu/traits.h +38 -0
- package/cpp/ggml-cpu/unary-ops.cpp +186 -0
- package/cpp/ggml-cpu/unary-ops.h +28 -0
- package/cpp/ggml-cpu/vec.cpp +321 -0
- package/cpp/ggml-cpu/vec.h +973 -0
- package/cpp/ggml-cpu.h +143 -0
- package/cpp/ggml-impl.h +525 -168
- package/cpp/ggml-metal-impl.h +622 -0
- package/cpp/ggml-metal.h +16 -14
- package/cpp/ggml-metal.m +5289 -1859
- package/cpp/ggml-opt.cpp +1037 -0
- package/cpp/ggml-opt.h +237 -0
- package/cpp/ggml-quants.c +2916 -6877
- package/cpp/ggml-quants.h +87 -249
- package/cpp/ggml-threading.cpp +12 -0
- package/cpp/ggml-threading.h +14 -0
- package/cpp/ggml-whisper-sim.metallib +0 -0
- package/cpp/ggml-whisper.metallib +0 -0
- package/cpp/ggml.c +3293 -16770
- package/cpp/ggml.h +778 -835
- package/cpp/gguf.cpp +1347 -0
- package/cpp/gguf.h +202 -0
- package/cpp/rn-whisper.cpp +84 -0
- package/cpp/rn-whisper.h +2 -0
- package/cpp/whisper-arch.h +197 -0
- package/cpp/whisper.cpp +3240 -944
- package/cpp/whisper.h +144 -31
- package/ios/CMakeLists.txt +95 -0
- package/ios/RNWhisper.h +5 -0
- package/ios/RNWhisper.mm +124 -37
- package/ios/RNWhisperAudioUtils.h +1 -0
- package/ios/RNWhisperAudioUtils.m +24 -13
- package/ios/RNWhisperContext.h +8 -2
- package/ios/RNWhisperContext.mm +42 -8
- package/ios/rnwhisper.xcframework/Info.plist +74 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-alloc.h +76 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-backend-impl.h +255 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-backend.h +354 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-common.h +1861 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-cpp.h +39 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-cpu.h +143 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-impl.h +603 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-metal-impl.h +622 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-metal.h +66 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-opt.h +237 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-quants.h +100 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-threading.h +14 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml.h +2221 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/gguf.h +202 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/rn-audioutils.h +14 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/rn-whisper-log.h +11 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/rn-whisper.h +52 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/whisper-arch.h +197 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/whisper.h +739 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Info.plist +0 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/ggml-whisper.metallib +0 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/rnwhisper +0 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-alloc.h +76 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend-impl.h +255 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend.h +354 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-common.h +1861 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-cpp.h +39 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-cpu.h +143 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-impl.h +603 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-metal-impl.h +622 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-metal.h +66 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-opt.h +237 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-quants.h +100 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-threading.h +14 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml.h +2221 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/gguf.h +202 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/rn-audioutils.h +14 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/rn-whisper-log.h +11 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/rn-whisper.h +52 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/whisper-arch.h +197 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/whisper.h +739 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Info.plist +0 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/_CodeSignature/CodeResources +101 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/ggml-whisper-sim.metallib +0 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/rnwhisper +0 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-alloc.h +76 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-backend-impl.h +255 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-backend.h +354 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-common.h +1861 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-cpp.h +39 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-cpu.h +143 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-impl.h +603 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-metal-impl.h +622 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-metal.h +66 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-opt.h +237 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-quants.h +100 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-threading.h +14 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml.h +2221 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/gguf.h +202 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/rn-audioutils.h +14 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/rn-whisper-log.h +11 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/rn-whisper.h +52 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/whisper-arch.h +197 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/whisper.h +739 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Info.plist +0 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/ggml-whisper.metallib +0 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/rnwhisper +0 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-alloc.h +76 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend-impl.h +255 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend.h +354 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-common.h +1861 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-cpp.h +39 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-cpu.h +143 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-impl.h +603 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-metal-impl.h +622 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-metal.h +66 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-opt.h +237 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-quants.h +100 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-threading.h +14 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml.h +2221 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/gguf.h +202 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/rn-audioutils.h +14 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/rn-whisper-log.h +11 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/rn-whisper.h +52 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/whisper-arch.h +197 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/whisper.h +739 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Info.plist +0 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/_CodeSignature/CodeResources +101 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/ggml-whisper-sim.metallib +0 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/rnwhisper +0 -0
- package/jest/mock.js +14 -1
- package/lib/commonjs/NativeRNWhisper.js.map +1 -1
- package/lib/commonjs/index.js +48 -19
- 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 +48 -19
- package/lib/module/index.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/NativeRNWhisper.d.ts +6 -3
- package/lib/typescript/NativeRNWhisper.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +25 -3
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +15 -10
- package/src/NativeRNWhisper.ts +12 -3
- package/src/index.ts +63 -24
- package/src/version.json +1 -1
- package/whisper-rn.podspec +18 -18
- package/cpp/README.md +0 -4
- package/cpp/ggml-backend.c +0 -1718
- package/cpp/ggml-metal-whisper.metal +0 -5820
|
@@ -47,6 +47,11 @@ public class RNWhisperModule extends ReactContextBaseJavaModule {
|
|
|
47
47
|
rnwhisper.transcribeFile(id, jobId, filePath, options, promise);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
@ReactMethod
|
|
51
|
+
public void transcribeData(double id, double jobId, String dataBase64, ReadableMap options, Promise promise) {
|
|
52
|
+
rnwhisper.transcribeData(id, jobId, dataBase64, options, promise);
|
|
53
|
+
}
|
|
54
|
+
|
|
50
55
|
@ReactMethod
|
|
51
56
|
public void startRealtimeTranscribe(double id, double jobId, ReadableMap options, Promise promise) {
|
|
52
57
|
rnwhisper.startRealtimeTranscribe(id, jobId, options, promise);
|
|
@@ -57,6 +62,11 @@ public class RNWhisperModule extends ReactContextBaseJavaModule {
|
|
|
57
62
|
rnwhisper.abortTranscribe(contextId, jobId, promise);
|
|
58
63
|
}
|
|
59
64
|
|
|
65
|
+
@ReactMethod
|
|
66
|
+
public void bench(double id, double nThreads, Promise promise) {
|
|
67
|
+
rnwhisper.bench(id, nThreads, promise);
|
|
68
|
+
}
|
|
69
|
+
|
|
60
70
|
@ReactMethod
|
|
61
71
|
public void releaseContext(double id, Promise promise) {
|
|
62
72
|
rnwhisper.releaseContext(id, promise);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#import <CoreML/CoreML.h>
|
|
2
|
+
|
|
3
|
+
@interface MLModel (Compat)
|
|
4
|
+
- (void) predictionFromFeatures:(id<MLFeatureProvider>) input
|
|
5
|
+
completionHandler:(void (^)(id<MLFeatureProvider> output, NSError * error)) completionHandler;
|
|
6
|
+
|
|
7
|
+
- (void) predictionFromFeatures:(id<MLFeatureProvider>) input
|
|
8
|
+
options:(MLPredictionOptions *) options
|
|
9
|
+
completionHandler:(void (^)(id<MLFeatureProvider> output, NSError * error)) completionHandler;
|
|
10
|
+
@end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#import "whisper-compat.h"
|
|
2
|
+
#import <Foundation/Foundation.h>
|
|
3
|
+
|
|
4
|
+
@implementation MLModel (Compat)
|
|
5
|
+
|
|
6
|
+
#if !defined(MAC_OS_X_VERSION_14_00) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_14_00
|
|
7
|
+
|
|
8
|
+
- (void) predictionFromFeatures:(id<MLFeatureProvider>) input
|
|
9
|
+
completionHandler:(void (^)(id<MLFeatureProvider> output, NSError * error)) completionHandler {
|
|
10
|
+
[NSOperationQueue.new addOperationWithBlock:^{
|
|
11
|
+
NSError *error = nil;
|
|
12
|
+
id<MLFeatureProvider> prediction = [self predictionFromFeatures:input error:&error];
|
|
13
|
+
|
|
14
|
+
[NSOperationQueue.mainQueue addOperationWithBlock:^{
|
|
15
|
+
completionHandler(prediction, error);
|
|
16
|
+
}];
|
|
17
|
+
}];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
- (void) predictionFromFeatures:(id<MLFeatureProvider>) input
|
|
21
|
+
options:(MLPredictionOptions *) options
|
|
22
|
+
completionHandler:(void (^)(id<MLFeatureProvider> output, NSError * error)) completionHandler {
|
|
23
|
+
[NSOperationQueue.new addOperationWithBlock:^{
|
|
24
|
+
NSError *error = nil;
|
|
25
|
+
id<MLFeatureProvider> prediction = [self predictionFromFeatures:input options:options error:&error];
|
|
26
|
+
|
|
27
|
+
[NSOperationQueue.mainQueue addOperationWithBlock:^{
|
|
28
|
+
completionHandler(prediction, error);
|
|
29
|
+
}];
|
|
30
|
+
}];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
#endif
|
|
34
|
+
|
|
35
|
+
@end
|
|
@@ -11,36 +11,33 @@
|
|
|
11
11
|
|
|
12
12
|
NS_ASSUME_NONNULL_BEGIN
|
|
13
13
|
|
|
14
|
-
|
|
15
14
|
/// Model Prediction Input Type
|
|
16
|
-
API_AVAILABLE(macos(
|
|
15
|
+
API_AVAILABLE(macos(10.15), ios(13.0), watchos(6.0), tvos(13.0)) __attribute__((visibility("hidden")))
|
|
17
16
|
@interface whisper_decoder_implInput : NSObject<MLFeatureProvider>
|
|
18
17
|
|
|
19
|
-
/// token_data as 1 by 1 matrix of
|
|
18
|
+
/// token_data as 1 by 1 matrix of floats
|
|
20
19
|
@property (readwrite, nonatomic, strong) MLMultiArray * token_data;
|
|
21
20
|
|
|
22
|
-
/// audio_data as 1 ×
|
|
21
|
+
/// audio_data as 1 × 1500 × 384 3-dimensional array of floats
|
|
23
22
|
@property (readwrite, nonatomic, strong) MLMultiArray * audio_data;
|
|
24
23
|
- (instancetype)init NS_UNAVAILABLE;
|
|
25
24
|
- (instancetype)initWithToken_data:(MLMultiArray *)token_data audio_data:(MLMultiArray *)audio_data NS_DESIGNATED_INITIALIZER;
|
|
26
25
|
|
|
27
26
|
@end
|
|
28
27
|
|
|
29
|
-
|
|
30
28
|
/// Model Prediction Output Type
|
|
31
|
-
API_AVAILABLE(macos(
|
|
29
|
+
API_AVAILABLE(macos(10.15), ios(13.0), watchos(6.0), tvos(13.0)) __attribute__((visibility("hidden")))
|
|
32
30
|
@interface whisper_decoder_implOutput : NSObject<MLFeatureProvider>
|
|
33
31
|
|
|
34
|
-
///
|
|
35
|
-
@property (readwrite, nonatomic, strong) MLMultiArray *
|
|
32
|
+
/// cast_76 as multidimensional array of floats
|
|
33
|
+
@property (readwrite, nonatomic, strong) MLMultiArray * cast_76;
|
|
36
34
|
- (instancetype)init NS_UNAVAILABLE;
|
|
37
|
-
- (instancetype)
|
|
35
|
+
- (instancetype)initWithCast_76:(MLMultiArray *)cast_76 NS_DESIGNATED_INITIALIZER;
|
|
38
36
|
|
|
39
37
|
@end
|
|
40
38
|
|
|
41
|
-
|
|
42
39
|
/// Class for model loading and prediction
|
|
43
|
-
API_AVAILABLE(macos(
|
|
40
|
+
API_AVAILABLE(macos(10.15), ios(13.0), watchos(6.0), tvos(13.0)) __attribute__((visibility("hidden")))
|
|
44
41
|
@interface whisper_decoder_impl : NSObject
|
|
45
42
|
@property (readonly, nonatomic, nullable) MLModel * model;
|
|
46
43
|
|
|
@@ -94,7 +91,7 @@ API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0)) __attribute__((v
|
|
|
94
91
|
@param configuration The model configuration
|
|
95
92
|
@param handler When the model load completes successfully or unsuccessfully, the completion handler is invoked with a valid whisper_decoder_impl instance or NSError object.
|
|
96
93
|
*/
|
|
97
|
-
+ (void)loadWithConfiguration:(MLModelConfiguration *)configuration completionHandler:(void (^)(whisper_decoder_impl * _Nullable model, NSError * _Nullable error))handler;
|
|
94
|
+
+ (void)loadWithConfiguration:(MLModelConfiguration *)configuration completionHandler:(void (^)(whisper_decoder_impl * _Nullable model, NSError * _Nullable error))handler API_AVAILABLE(macos(11.0), ios(14.0), watchos(7.0), tvos(14.0)) __attribute__((visibility("hidden")));
|
|
98
95
|
|
|
99
96
|
/**
|
|
100
97
|
Construct whisper_decoder_impl instance asynchronously with URL of .mlmodelc directory and optional configuration.
|
|
@@ -105,7 +102,7 @@ API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0)) __attribute__((v
|
|
|
105
102
|
@param configuration The model configuration
|
|
106
103
|
@param handler When the model load completes successfully or unsuccessfully, the completion handler is invoked with a valid whisper_decoder_impl instance or NSError object.
|
|
107
104
|
*/
|
|
108
|
-
+ (void)loadContentsOfURL:(NSURL *)modelURL configuration:(MLModelConfiguration *)configuration completionHandler:(void (^)(whisper_decoder_impl * _Nullable model, NSError * _Nullable error))handler;
|
|
105
|
+
+ (void)loadContentsOfURL:(NSURL *)modelURL configuration:(MLModelConfiguration *)configuration completionHandler:(void (^)(whisper_decoder_impl * _Nullable model, NSError * _Nullable error))handler API_AVAILABLE(macos(11.0), ios(14.0), watchos(7.0), tvos(14.0)) __attribute__((visibility("hidden")));
|
|
109
106
|
|
|
110
107
|
/**
|
|
111
108
|
Make a prediction using the standard interface
|
|
@@ -124,10 +121,25 @@ API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0)) __attribute__((v
|
|
|
124
121
|
*/
|
|
125
122
|
- (nullable whisper_decoder_implOutput *)predictionFromFeatures:(whisper_decoder_implInput *)input options:(MLPredictionOptions *)options error:(NSError * _Nullable __autoreleasing * _Nullable)error;
|
|
126
123
|
|
|
124
|
+
/**
|
|
125
|
+
Make an asynchronous prediction using the standard interface
|
|
126
|
+
@param input an instance of whisper_decoder_implInput to predict from
|
|
127
|
+
@param completionHandler a block that will be called upon completion of the prediction. error will be nil if no error occurred.
|
|
128
|
+
*/
|
|
129
|
+
- (void)predictionFromFeatures:(whisper_decoder_implInput *)input completionHandler:(void (^)(whisper_decoder_implOutput * _Nullable output, NSError * _Nullable error))completionHandler API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0)) __attribute__((visibility("hidden")));
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
Make an asynchronous prediction using the standard interface
|
|
133
|
+
@param input an instance of whisper_decoder_implInput to predict from
|
|
134
|
+
@param options prediction options
|
|
135
|
+
@param completionHandler a block that will be called upon completion of the prediction. error will be nil if no error occurred.
|
|
136
|
+
*/
|
|
137
|
+
- (void)predictionFromFeatures:(whisper_decoder_implInput *)input options:(MLPredictionOptions *)options completionHandler:(void (^)(whisper_decoder_implOutput * _Nullable output, NSError * _Nullable error))completionHandler API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0)) __attribute__((visibility("hidden")));
|
|
138
|
+
|
|
127
139
|
/**
|
|
128
140
|
Make a prediction using the convenience interface
|
|
129
|
-
@param token_data
|
|
130
|
-
@param audio_data
|
|
141
|
+
@param token_data 1 by 1 matrix of floats
|
|
142
|
+
@param audio_data 1 × 1500 × 384 3-dimensional array of floats
|
|
131
143
|
@param error If an error occurs, upon return contains an NSError object that describes the problem. If you are not interested in possible errors, pass in NULL.
|
|
132
144
|
@return the prediction as whisper_decoder_implOutput
|
|
133
145
|
*/
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
#error This file must be compiled with automatic reference counting enabled (-fobjc-arc)
|
|
9
9
|
#endif
|
|
10
10
|
|
|
11
|
+
#import "whisper-compat.h"
|
|
11
12
|
#import "whisper-decoder-impl.h"
|
|
12
13
|
|
|
13
14
|
@implementation whisper_decoder_implInput
|
|
@@ -39,21 +40,21 @@
|
|
|
39
40
|
|
|
40
41
|
@implementation whisper_decoder_implOutput
|
|
41
42
|
|
|
42
|
-
- (instancetype)
|
|
43
|
+
- (instancetype)initWithCast_76:(MLMultiArray *)cast_76 {
|
|
43
44
|
self = [super init];
|
|
44
45
|
if (self) {
|
|
45
|
-
|
|
46
|
+
_cast_76 = cast_76;
|
|
46
47
|
}
|
|
47
48
|
return self;
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
- (NSSet<NSString *> *)featureNames {
|
|
51
|
-
return [NSSet setWithArray:@[@"
|
|
52
|
+
return [NSSet setWithArray:@[@"cast_76"]];
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
- (nullable MLFeatureValue *)featureValueForName:(NSString *)featureName {
|
|
55
|
-
if ([featureName isEqualToString:@"
|
|
56
|
-
return [MLFeatureValue featureValueWithMultiArray:self.
|
|
56
|
+
if ([featureName isEqualToString:@"cast_76"]) {
|
|
57
|
+
return [MLFeatureValue featureValueWithMultiArray:self.cast_76];
|
|
57
58
|
}
|
|
58
59
|
return nil;
|
|
59
60
|
}
|
|
@@ -80,10 +81,13 @@
|
|
|
80
81
|
Such application may want to use `-[MLModel initWithContentsOfURL:configuration:error:]` and `+URLOfModelInThisBundle` to create a MLModel object to pass-in.
|
|
81
82
|
*/
|
|
82
83
|
- (instancetype)initWithMLModel:(MLModel *)model {
|
|
84
|
+
if (model == nil) {
|
|
85
|
+
return nil;
|
|
86
|
+
}
|
|
83
87
|
self = [super init];
|
|
84
|
-
if (
|
|
85
|
-
|
|
86
|
-
|
|
88
|
+
if (self != nil) {
|
|
89
|
+
_model = model;
|
|
90
|
+
}
|
|
87
91
|
return self;
|
|
88
92
|
}
|
|
89
93
|
|
|
@@ -177,7 +181,29 @@
|
|
|
177
181
|
- (nullable whisper_decoder_implOutput *)predictionFromFeatures:(whisper_decoder_implInput *)input options:(MLPredictionOptions *)options error:(NSError * _Nullable __autoreleasing * _Nullable)error {
|
|
178
182
|
id<MLFeatureProvider> outFeatures = [self.model predictionFromFeatures:input options:options error:error];
|
|
179
183
|
if (!outFeatures) { return nil; }
|
|
180
|
-
return [[whisper_decoder_implOutput alloc]
|
|
184
|
+
return [[whisper_decoder_implOutput alloc] initWithCast_76:(MLMultiArray *)[outFeatures featureValueForName:@"cast_76"].multiArrayValue];
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
- (void)predictionFromFeatures:(whisper_decoder_implInput *)input completionHandler:(void (^)(whisper_decoder_implOutput * _Nullable output, NSError * _Nullable error))completionHandler {
|
|
188
|
+
[self.model predictionFromFeatures:input completionHandler:^(id<MLFeatureProvider> prediction, NSError *predictionError) {
|
|
189
|
+
if (prediction != nil) {
|
|
190
|
+
whisper_decoder_implOutput *output = [[whisper_decoder_implOutput alloc] initWithCast_76:(MLMultiArray *)[prediction featureValueForName:@"cast_76"].multiArrayValue];
|
|
191
|
+
completionHandler(output, predictionError);
|
|
192
|
+
} else {
|
|
193
|
+
completionHandler(nil, predictionError);
|
|
194
|
+
}
|
|
195
|
+
}];
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
- (void)predictionFromFeatures:(whisper_decoder_implInput *)input options:(MLPredictionOptions *)options completionHandler:(void (^)(whisper_decoder_implOutput * _Nullable output, NSError * _Nullable error))completionHandler {
|
|
199
|
+
[self.model predictionFromFeatures:input options:options completionHandler:^(id<MLFeatureProvider> prediction, NSError *predictionError) {
|
|
200
|
+
if (prediction != nil) {
|
|
201
|
+
whisper_decoder_implOutput *output = [[whisper_decoder_implOutput alloc] initWithCast_76:(MLMultiArray *)[prediction featureValueForName:@"cast_76"].multiArrayValue];
|
|
202
|
+
completionHandler(output, predictionError);
|
|
203
|
+
} else {
|
|
204
|
+
completionHandler(nil, predictionError);
|
|
205
|
+
}
|
|
206
|
+
}];
|
|
181
207
|
}
|
|
182
208
|
|
|
183
209
|
- (nullable whisper_decoder_implOutput *)predictionFromToken_data:(MLMultiArray *)token_data audio_data:(MLMultiArray *)audio_data error:(NSError * _Nullable __autoreleasing * _Nullable)error {
|
|
@@ -192,7 +218,7 @@
|
|
|
192
218
|
NSMutableArray<whisper_decoder_implOutput*> *results = [NSMutableArray arrayWithCapacity:(NSUInteger)outBatch.count];
|
|
193
219
|
for (NSInteger i = 0; i < outBatch.count; i++) {
|
|
194
220
|
id<MLFeatureProvider> resultProvider = [outBatch featuresAtIndex:i];
|
|
195
|
-
whisper_decoder_implOutput * result = [[whisper_decoder_implOutput alloc]
|
|
221
|
+
whisper_decoder_implOutput * result = [[whisper_decoder_implOutput alloc] initWithCast_76:(MLMultiArray *)[resultProvider featureValueForName:@"cast_76"].multiArrayValue];
|
|
196
222
|
[results addObject:result];
|
|
197
223
|
}
|
|
198
224
|
return results;
|
|
@@ -11,9 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
NS_ASSUME_NONNULL_BEGIN
|
|
13
13
|
|
|
14
|
-
|
|
15
14
|
/// Model Prediction Input Type
|
|
16
|
-
API_AVAILABLE(macos(
|
|
15
|
+
API_AVAILABLE(macos(10.15), ios(13.0), watchos(6.0), tvos(13.0)) __attribute__((visibility("hidden")))
|
|
17
16
|
@interface whisper_encoder_implInput : NSObject<MLFeatureProvider>
|
|
18
17
|
|
|
19
18
|
/// logmel_data as 1 × 80 × 3000 3-dimensional array of floats
|
|
@@ -23,9 +22,8 @@ API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0)) __attribute__((v
|
|
|
23
22
|
|
|
24
23
|
@end
|
|
25
24
|
|
|
26
|
-
|
|
27
25
|
/// Model Prediction Output Type
|
|
28
|
-
API_AVAILABLE(macos(
|
|
26
|
+
API_AVAILABLE(macos(10.15), ios(13.0), watchos(6.0), tvos(13.0)) __attribute__((visibility("hidden")))
|
|
29
27
|
@interface whisper_encoder_implOutput : NSObject<MLFeatureProvider>
|
|
30
28
|
|
|
31
29
|
/// output as multidimensional array of floats
|
|
@@ -35,9 +33,8 @@ API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0)) __attribute__((v
|
|
|
35
33
|
|
|
36
34
|
@end
|
|
37
35
|
|
|
38
|
-
|
|
39
36
|
/// Class for model loading and prediction
|
|
40
|
-
API_AVAILABLE(macos(
|
|
37
|
+
API_AVAILABLE(macos(10.15), ios(13.0), watchos(6.0), tvos(13.0)) __attribute__((visibility("hidden")))
|
|
41
38
|
@interface whisper_encoder_impl : NSObject
|
|
42
39
|
@property (readonly, nonatomic, nullable) MLModel * model;
|
|
43
40
|
|
|
@@ -91,7 +88,7 @@ API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0)) __attribute__((v
|
|
|
91
88
|
@param configuration The model configuration
|
|
92
89
|
@param handler When the model load completes successfully or unsuccessfully, the completion handler is invoked with a valid whisper_encoder_impl instance or NSError object.
|
|
93
90
|
*/
|
|
94
|
-
+ (void)loadWithConfiguration:(MLModelConfiguration *)configuration completionHandler:(void (^)(whisper_encoder_impl * _Nullable model, NSError * _Nullable error))handler;
|
|
91
|
+
+ (void)loadWithConfiguration:(MLModelConfiguration *)configuration completionHandler:(void (^)(whisper_encoder_impl * _Nullable model, NSError * _Nullable error))handler API_AVAILABLE(macos(11.0), ios(14.0), watchos(7.0), tvos(14.0)) __attribute__((visibility("hidden")));
|
|
95
92
|
|
|
96
93
|
/**
|
|
97
94
|
Construct whisper_encoder_impl instance asynchronously with URL of .mlmodelc directory and optional configuration.
|
|
@@ -102,7 +99,7 @@ API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0)) __attribute__((v
|
|
|
102
99
|
@param configuration The model configuration
|
|
103
100
|
@param handler When the model load completes successfully or unsuccessfully, the completion handler is invoked with a valid whisper_encoder_impl instance or NSError object.
|
|
104
101
|
*/
|
|
105
|
-
+ (void)loadContentsOfURL:(NSURL *)modelURL configuration:(MLModelConfiguration *)configuration completionHandler:(void (^)(whisper_encoder_impl * _Nullable model, NSError * _Nullable error))handler;
|
|
102
|
+
+ (void)loadContentsOfURL:(NSURL *)modelURL configuration:(MLModelConfiguration *)configuration completionHandler:(void (^)(whisper_encoder_impl * _Nullable model, NSError * _Nullable error))handler API_AVAILABLE(macos(11.0), ios(14.0), watchos(7.0), tvos(14.0)) __attribute__((visibility("hidden")));
|
|
106
103
|
|
|
107
104
|
/**
|
|
108
105
|
Make a prediction using the standard interface
|
|
@@ -121,9 +118,24 @@ API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0)) __attribute__((v
|
|
|
121
118
|
*/
|
|
122
119
|
- (nullable whisper_encoder_implOutput *)predictionFromFeatures:(whisper_encoder_implInput *)input options:(MLPredictionOptions *)options error:(NSError * _Nullable __autoreleasing * _Nullable)error;
|
|
123
120
|
|
|
121
|
+
/**
|
|
122
|
+
Make an asynchronous prediction using the standard interface
|
|
123
|
+
@param input an instance of whisper_encoder_implInput to predict from
|
|
124
|
+
@param completionHandler a block that will be called upon completion of the prediction. error will be nil if no error occurred.
|
|
125
|
+
*/
|
|
126
|
+
- (void)predictionFromFeatures:(whisper_encoder_implInput *)input completionHandler:(void (^)(whisper_encoder_implOutput * _Nullable output, NSError * _Nullable error))completionHandler API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0)) __attribute__((visibility("hidden")));
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
Make an asynchronous prediction using the standard interface
|
|
130
|
+
@param input an instance of whisper_encoder_implInput to predict from
|
|
131
|
+
@param options prediction options
|
|
132
|
+
@param completionHandler a block that will be called upon completion of the prediction. error will be nil if no error occurred.
|
|
133
|
+
*/
|
|
134
|
+
- (void)predictionFromFeatures:(whisper_encoder_implInput *)input options:(MLPredictionOptions *)options completionHandler:(void (^)(whisper_encoder_implOutput * _Nullable output, NSError * _Nullable error))completionHandler API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0)) __attribute__((visibility("hidden")));
|
|
135
|
+
|
|
124
136
|
/**
|
|
125
137
|
Make a prediction using the convenience interface
|
|
126
|
-
@param logmel_data
|
|
138
|
+
@param logmel_data 1 × 80 × 3000 3-dimensional array of floats
|
|
127
139
|
@param error If an error occurs, upon return contains an NSError object that describes the problem. If you are not interested in possible errors, pass in NULL.
|
|
128
140
|
@return the prediction as whisper_encoder_implOutput
|
|
129
141
|
*/
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
#error This file must be compiled with automatic reference counting enabled (-fobjc-arc)
|
|
9
9
|
#endif
|
|
10
10
|
|
|
11
|
+
#import "whisper-compat.h"
|
|
11
12
|
#import "whisper-encoder-impl.h"
|
|
12
13
|
|
|
13
14
|
@implementation whisper_encoder_implInput
|
|
@@ -76,10 +77,13 @@
|
|
|
76
77
|
Such application may want to use `-[MLModel initWithContentsOfURL:configuration:error:]` and `+URLOfModelInThisBundle` to create a MLModel object to pass-in.
|
|
77
78
|
*/
|
|
78
79
|
- (instancetype)initWithMLModel:(MLModel *)model {
|
|
80
|
+
if (model == nil) {
|
|
81
|
+
return nil;
|
|
82
|
+
}
|
|
79
83
|
self = [super init];
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
|
|
84
|
+
if (self != nil) {
|
|
85
|
+
_model = model;
|
|
86
|
+
}
|
|
83
87
|
return self;
|
|
84
88
|
}
|
|
85
89
|
|
|
@@ -176,6 +180,28 @@
|
|
|
176
180
|
return [[whisper_encoder_implOutput alloc] initWithOutput:(MLMultiArray *)[outFeatures featureValueForName:@"output"].multiArrayValue];
|
|
177
181
|
}
|
|
178
182
|
|
|
183
|
+
- (void)predictionFromFeatures:(whisper_encoder_implInput *)input completionHandler:(void (^)(whisper_encoder_implOutput * _Nullable output, NSError * _Nullable error))completionHandler {
|
|
184
|
+
[self.model predictionFromFeatures:input completionHandler:^(id<MLFeatureProvider> prediction, NSError *predictionError) {
|
|
185
|
+
if (prediction != nil) {
|
|
186
|
+
whisper_encoder_implOutput *output = [[whisper_encoder_implOutput alloc] initWithOutput:(MLMultiArray *)[prediction featureValueForName:@"output"].multiArrayValue];
|
|
187
|
+
completionHandler(output, predictionError);
|
|
188
|
+
} else {
|
|
189
|
+
completionHandler(nil, predictionError);
|
|
190
|
+
}
|
|
191
|
+
}];
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
- (void)predictionFromFeatures:(whisper_encoder_implInput *)input options:(MLPredictionOptions *)options completionHandler:(void (^)(whisper_encoder_implOutput * _Nullable output, NSError * _Nullable error))completionHandler {
|
|
195
|
+
[self.model predictionFromFeatures:input options:options completionHandler:^(id<MLFeatureProvider> prediction, NSError *predictionError) {
|
|
196
|
+
if (prediction != nil) {
|
|
197
|
+
whisper_encoder_implOutput *output = [[whisper_encoder_implOutput alloc] initWithOutput:(MLMultiArray *)[prediction featureValueForName:@"output"].multiArrayValue];
|
|
198
|
+
completionHandler(output, predictionError);
|
|
199
|
+
} else {
|
|
200
|
+
completionHandler(nil, predictionError);
|
|
201
|
+
}
|
|
202
|
+
}];
|
|
203
|
+
}
|
|
204
|
+
|
|
179
205
|
- (nullable whisper_encoder_implOutput *)predictionFromLogmel_data:(MLMultiArray *)logmel_data error:(NSError * _Nullable __autoreleasing * _Nullable)error {
|
|
180
206
|
whisper_encoder_implInput *input_ = [[whisper_encoder_implInput alloc] initWithLogmel_data:logmel_data];
|
|
181
207
|
return [self predictionFromFeatures:input_ error:error];
|