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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "whisper.rn",
|
|
3
|
-
"version": "0.4.0
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "React Native binding of whisper.cpp",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -12,9 +12,8 @@
|
|
|
12
12
|
"lib",
|
|
13
13
|
"jest",
|
|
14
14
|
"android",
|
|
15
|
+
"cpp",
|
|
15
16
|
"ios",
|
|
16
|
-
"cpp/*.*",
|
|
17
|
-
"cpp/coreml/*.*",
|
|
18
17
|
"*.podspec",
|
|
19
18
|
"!lib/typescript/example",
|
|
20
19
|
"!ios/build",
|
|
@@ -30,13 +29,18 @@
|
|
|
30
29
|
],
|
|
31
30
|
"scripts": {
|
|
32
31
|
"bootstrap": "./scripts/bootstrap.sh",
|
|
33
|
-
"docgen": "typedoc src/index.ts --plugin typedoc-plugin-markdown --readme none --out docs/API",
|
|
32
|
+
"docgen": "typedoc src/index.ts --plugin typedoc-plugin-markdown --excludePrivate --readme none --out docs/API",
|
|
34
33
|
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
35
34
|
"typecheck": "tsc --noEmit",
|
|
36
|
-
"
|
|
35
|
+
"build": "bob build",
|
|
36
|
+
"prepack": "yarn docgen && ./scripts/build-ios.sh && ./scripts/build-android.sh && yarn build",
|
|
37
37
|
"test": "jest",
|
|
38
38
|
"example": "yarn --cwd example",
|
|
39
|
-
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build"
|
|
39
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build",
|
|
40
|
+
"build:ios-frameworks": "./scripts/build-ios.sh",
|
|
41
|
+
"build:ios": "cd example/ios && xcodebuild -workspace RNWhisperExample.xcworkspace -scheme RNWhisperExample -configuration Debug -sdk iphonesimulator CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ GCC_OPTIMIZATION_LEVEL=0 GCC_PRECOMPILE_PREFIX_HEADER=YES ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf COMPILER_INDEX_STORE_ENABLE=NO",
|
|
42
|
+
"build:android-libs": "./scripts/build-android.sh",
|
|
43
|
+
"build:android": "cd example/android && ./gradlew assembleDebug"
|
|
40
44
|
},
|
|
41
45
|
"keywords": [
|
|
42
46
|
"react-native",
|
|
@@ -59,21 +63,21 @@
|
|
|
59
63
|
"@commitlint/config-conventional": "^17.0.2",
|
|
60
64
|
"@evilmartians/lefthook": "^1.2.2",
|
|
61
65
|
"@fugood/eslint-config-react": "^0.5.0",
|
|
66
|
+
"@react-native/babel-preset": "0.74.88",
|
|
67
|
+
"@react-native/metro-config": "^0.73.2",
|
|
62
68
|
"@release-it/conventional-changelog": "^5.0.0",
|
|
63
69
|
"@types/jest": "^29.4.4",
|
|
64
70
|
"@types/react": "^18.2.6",
|
|
65
71
|
"@types/react-native": "0.70.0",
|
|
66
72
|
"@typescript-eslint/eslint-plugin": "^5.55.0",
|
|
67
73
|
"@typescript-eslint/parser": "^5.55.0",
|
|
68
|
-
"@react-native/babel-preset": "^0.73.18",
|
|
69
|
-
"@react-native/metro-config": "^0.73.2",
|
|
70
74
|
"commitlint": "^17.0.2",
|
|
71
75
|
"del-cli": "^5.0.0",
|
|
72
76
|
"eslint": "^8.36.0",
|
|
73
77
|
"jest": "^29.5.0",
|
|
74
78
|
"pod-install": "^0.1.38",
|
|
75
79
|
"react": "18.2.0",
|
|
76
|
-
"react-native": "0.
|
|
80
|
+
"react-native": "0.74.6",
|
|
77
81
|
"react-native-builder-bob": "^0.20.4",
|
|
78
82
|
"release-it": "^15.8.0",
|
|
79
83
|
"typedoc": "^0.24.7",
|
|
@@ -142,5 +146,6 @@
|
|
|
142
146
|
"name": "RNWhisperSpec",
|
|
143
147
|
"type": "all",
|
|
144
148
|
"jsSrcsDir": "./src/"
|
|
145
|
-
}
|
|
149
|
+
},
|
|
150
|
+
"packageManager": "yarn@1.22.22"
|
|
146
151
|
}
|
package/src/NativeRNWhisper.ts
CHANGED
|
@@ -15,6 +15,8 @@ export type TranscribeOptions = {
|
|
|
15
15
|
maxLen?: number,
|
|
16
16
|
/** Enable token-level timestamps */
|
|
17
17
|
tokenTimestamps?: boolean,
|
|
18
|
+
/** Enable tinydiarize (requires a tdrz model) */
|
|
19
|
+
tdrzEnable?: boolean,
|
|
18
20
|
/** Word timestamp probability threshold */
|
|
19
21
|
wordThold?: number,
|
|
20
22
|
/** Time offset in milliseconds */
|
|
@@ -28,8 +30,6 @@ export type TranscribeOptions = {
|
|
|
28
30
|
beamSize?: number,
|
|
29
31
|
/** Number of best candidates to keep */
|
|
30
32
|
bestOf?: number,
|
|
31
|
-
/** Speed up audio by x2 (reduced accuracy) */
|
|
32
|
-
speedUp?: boolean,
|
|
33
33
|
/** Initial Prompt */
|
|
34
34
|
prompt?: string,
|
|
35
35
|
}
|
|
@@ -52,6 +52,7 @@ export type CoreMLAsset = {
|
|
|
52
52
|
type NativeContextOptions = {
|
|
53
53
|
filePath: string,
|
|
54
54
|
isBundleAsset: boolean,
|
|
55
|
+
useFlashAttn?: boolean,
|
|
55
56
|
useGpu?: boolean,
|
|
56
57
|
useCoreMLIos?: boolean,
|
|
57
58
|
downloadCoreMLAssets?: boolean,
|
|
@@ -75,7 +76,13 @@ export interface Spec extends TurboModule {
|
|
|
75
76
|
transcribeFile(
|
|
76
77
|
contextId: number,
|
|
77
78
|
jobId: number,
|
|
78
|
-
|
|
79
|
+
pathOrBase64: string,
|
|
80
|
+
options: {}, // TranscribeOptions & { onProgress?: boolean, onNewSegments?: boolean }
|
|
81
|
+
): Promise<TranscribeResult>;
|
|
82
|
+
transcribeData(
|
|
83
|
+
contextId: number,
|
|
84
|
+
jobId: number,
|
|
85
|
+
dataBase64: string,
|
|
79
86
|
options: {}, // TranscribeOptions & { onProgress?: boolean, onNewSegments?: boolean }
|
|
80
87
|
): Promise<TranscribeResult>;
|
|
81
88
|
startRealtimeTranscribe(
|
|
@@ -85,6 +92,8 @@ export interface Spec extends TurboModule {
|
|
|
85
92
|
): Promise<void>;
|
|
86
93
|
abortTranscribe(contextId: number, jobId: number): Promise<void>;
|
|
87
94
|
|
|
95
|
+
bench(contextId: number, maxThreads: number): Promise<string>;
|
|
96
|
+
|
|
88
97
|
// iOS specific
|
|
89
98
|
getAudioSessionCurrentCategory: () => Promise<{
|
|
90
99
|
category: string,
|
package/src/index.ts
CHANGED
|
@@ -174,6 +174,15 @@ export type TranscribeRealtimeNativeEvent = {
|
|
|
174
174
|
payload: TranscribeRealtimeNativePayload
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
+
export type BenchResult = {
|
|
178
|
+
config: string
|
|
179
|
+
nThreads: number
|
|
180
|
+
encodeMs: number
|
|
181
|
+
decodeMs: number
|
|
182
|
+
batchMs: number
|
|
183
|
+
promptMs: number
|
|
184
|
+
}
|
|
185
|
+
|
|
177
186
|
const updateAudioSession = async (setting: AudioSessionSettingIos) => {
|
|
178
187
|
await AudioSessionIos.setCategory(
|
|
179
188
|
setting.category,
|
|
@@ -202,32 +211,10 @@ export class WhisperContext {
|
|
|
202
211
|
this.reasonNoGPU = reasonNoGPU
|
|
203
212
|
}
|
|
204
213
|
|
|
205
|
-
|
|
206
|
-
transcribe(
|
|
207
|
-
filePath: string | number,
|
|
208
|
-
options: TranscribeFileOptions = {},
|
|
209
|
-
): {
|
|
210
|
-
/** Stop the transcribe */
|
|
214
|
+
private transcribeWithNativeMethod(method: 'transcribeFile' | 'transcribeData', data: string, options: TranscribeFileOptions = {}): {
|
|
211
215
|
stop: () => Promise<void>
|
|
212
|
-
/** Transcribe result promise */
|
|
213
216
|
promise: Promise<TranscribeResult>
|
|
214
217
|
} {
|
|
215
|
-
let path = ''
|
|
216
|
-
if (typeof filePath === 'number') {
|
|
217
|
-
try {
|
|
218
|
-
const source = Image.resolveAssetSource(filePath)
|
|
219
|
-
if (source) path = source.uri
|
|
220
|
-
} catch (e) {
|
|
221
|
-
throw new Error(`Invalid asset: ${filePath}`)
|
|
222
|
-
}
|
|
223
|
-
} else {
|
|
224
|
-
if (filePath.startsWith('http'))
|
|
225
|
-
throw new Error(
|
|
226
|
-
'Transcribe remote file is not supported, please download it first',
|
|
227
|
-
)
|
|
228
|
-
path = filePath
|
|
229
|
-
}
|
|
230
|
-
if (path.startsWith('file://')) path = path.slice(7)
|
|
231
218
|
const jobId: number = Math.floor(Math.random() * 10000)
|
|
232
219
|
|
|
233
220
|
const { onProgress, onNewSegments, ...rest } = options
|
|
@@ -276,7 +263,7 @@ export class WhisperContext {
|
|
|
276
263
|
removeProgressListener()
|
|
277
264
|
removeNewSegmenetsListener()
|
|
278
265
|
},
|
|
279
|
-
promise: RNWhisper
|
|
266
|
+
promise: RNWhisper[method](this.id, jobId, data, {
|
|
280
267
|
...rest,
|
|
281
268
|
onProgress: !!onProgress,
|
|
282
269
|
onNewSegments: !!onNewSegments,
|
|
@@ -298,6 +285,48 @@ export class WhisperContext {
|
|
|
298
285
|
}
|
|
299
286
|
}
|
|
300
287
|
|
|
288
|
+
/**
|
|
289
|
+
* Transcribe audio file (path or base64 encoded wav file)
|
|
290
|
+
* base64: need add `data:audio/wav;base64,` prefix
|
|
291
|
+
*/
|
|
292
|
+
transcribe(
|
|
293
|
+
filePathOrBase64: string | number,
|
|
294
|
+
options: TranscribeFileOptions = {},
|
|
295
|
+
): {
|
|
296
|
+
/** Stop the transcribe */
|
|
297
|
+
stop: () => Promise<void>
|
|
298
|
+
/** Transcribe result promise */
|
|
299
|
+
promise: Promise<TranscribeResult>
|
|
300
|
+
} {
|
|
301
|
+
let path = ''
|
|
302
|
+
if (typeof filePathOrBase64 === 'number') {
|
|
303
|
+
try {
|
|
304
|
+
const source = Image.resolveAssetSource(filePathOrBase64)
|
|
305
|
+
if (source) path = source.uri
|
|
306
|
+
} catch (e) {
|
|
307
|
+
throw new Error(`Invalid asset: ${filePathOrBase64}`)
|
|
308
|
+
}
|
|
309
|
+
} else {
|
|
310
|
+
if (filePathOrBase64.startsWith('http'))
|
|
311
|
+
throw new Error(
|
|
312
|
+
'Transcribe remote file is not supported, please download it first',
|
|
313
|
+
)
|
|
314
|
+
path = filePathOrBase64
|
|
315
|
+
}
|
|
316
|
+
if (path.startsWith('file://')) path = path.slice(7)
|
|
317
|
+
return this.transcribeWithNativeMethod('transcribeFile', path, options)
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Transcribe audio data (base64 encoded float32 PCM data)
|
|
322
|
+
*/
|
|
323
|
+
transcribeData(data: string, options: TranscribeFileOptions = {}): {
|
|
324
|
+
stop: () => Promise<void>
|
|
325
|
+
promise: Promise<TranscribeResult>
|
|
326
|
+
} {
|
|
327
|
+
return this.transcribeWithNativeMethod('transcribeData', data, options)
|
|
328
|
+
}
|
|
329
|
+
|
|
301
330
|
/** Transcribe the microphone audio stream, the microphone user permission is required */
|
|
302
331
|
async transcribeRealtime(options: TranscribeRealtimeOptions = {}): Promise<{
|
|
303
332
|
/** Stop the realtime transcribe */
|
|
@@ -433,6 +462,12 @@ export class WhisperContext {
|
|
|
433
462
|
}
|
|
434
463
|
}
|
|
435
464
|
|
|
465
|
+
async bench(maxThreads: number): Promise<BenchResult> {
|
|
466
|
+
const result = await RNWhisper.bench(this.id, maxThreads)
|
|
467
|
+
const [config, nThreads, encodeMs, decodeMs, batchMs, promptMs] = JSON.parse(result)
|
|
468
|
+
return { config, nThreads, encodeMs, decodeMs, batchMs, promptMs } as BenchResult
|
|
469
|
+
}
|
|
470
|
+
|
|
436
471
|
async release(): Promise<void> {
|
|
437
472
|
return RNWhisper.releaseContext(this.id)
|
|
438
473
|
}
|
|
@@ -455,6 +490,8 @@ export type ContextOptions = {
|
|
|
455
490
|
useCoreMLIos?: boolean
|
|
456
491
|
/** Use GPU if available. Currently iOS only, if it's enabled, Core ML option will be ignored. */
|
|
457
492
|
useGpu?: boolean
|
|
493
|
+
/** Use Flash Attention, only recommended if GPU available */
|
|
494
|
+
useFlashAttn?: boolean,
|
|
458
495
|
}
|
|
459
496
|
|
|
460
497
|
const coreMLModelAssetPaths = [
|
|
@@ -470,6 +507,7 @@ export async function initWhisper({
|
|
|
470
507
|
isBundleAsset,
|
|
471
508
|
useGpu = true,
|
|
472
509
|
useCoreMLIos = true,
|
|
510
|
+
useFlashAttn = false,
|
|
473
511
|
}: ContextOptions): Promise<WhisperContext> {
|
|
474
512
|
let path = ''
|
|
475
513
|
let coreMLAssets: CoreMLAsset[] | undefined
|
|
@@ -518,6 +556,7 @@ export async function initWhisper({
|
|
|
518
556
|
const { contextId, gpu, reasonNoGPU } = await RNWhisper.initContext({
|
|
519
557
|
filePath: path,
|
|
520
558
|
isBundleAsset: !!isBundleAsset,
|
|
559
|
+
useFlashAttn,
|
|
521
560
|
useGpu,
|
|
522
561
|
useCoreMLIos,
|
|
523
562
|
// Only development mode need download Core ML model assets (from packager server)
|
package/src/version.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"1.
|
|
1
|
+
{"version":"1.7.6"}
|
package/whisper-rn.podspec
CHANGED
|
@@ -2,7 +2,7 @@ require "json"
|
|
|
2
2
|
|
|
3
3
|
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
4
|
base_ld_flags = "-framework Accelerate -framework Foundation -framework Metal -framework MetalKit"
|
|
5
|
-
base_compiler_flags = "-DWSP_GGML_USE_ACCELERATE -Wno-shorten-64-to-32"
|
|
5
|
+
base_compiler_flags = "-DWSP_GGML_USE_CPU -DWSP_GGML_USE_ACCELERATE -Wno-shorten-64-to-32"
|
|
6
6
|
folly_compiler_flags = "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma"
|
|
7
7
|
|
|
8
8
|
# Use base_optimizer_flags = "" for debug builds
|
|
@@ -31,8 +31,16 @@ Pod::Spec.new do |s|
|
|
|
31
31
|
s.platforms = { :ios => "11.0", :tvos => "11.0" }
|
|
32
32
|
s.source = { :git => "https://github.com/mybigday/whisper.rn.git", :tag => "#{s.version}" }
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
if ENV["RNWHISPER_BUILD_FROM_SOURCE"] == "1"
|
|
35
|
+
s.source_files = "ios/**/*.{h,m,mm}", "cpp/**/*.{h,cpp,hpp,c,m,mm}"
|
|
36
|
+
s.resources = "cpp/**/*.{metallib}"
|
|
37
|
+
base_compiler_flags += " -DRNWHISPER_BUILD_FROM_SOURCE"
|
|
38
|
+
else
|
|
39
|
+
s.source_files = "ios/**/*.{h,m,mm}"
|
|
40
|
+
s.vendored_frameworks = "ios/rnwhisper.xcframework"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
s.requires_arc = true
|
|
36
44
|
|
|
37
45
|
s.dependency "React-Core"
|
|
38
46
|
|
|
@@ -40,24 +48,16 @@ Pod::Spec.new do |s|
|
|
|
40
48
|
s.pod_target_xcconfig = {
|
|
41
49
|
"OTHER_LDFLAGS" => base_ld_flags,
|
|
42
50
|
"OTHER_CFLAGS" => base_optimizer_flags,
|
|
43
|
-
"OTHER_CPLUSPLUSFLAGS" => base_optimizer_flags
|
|
51
|
+
"OTHER_CPLUSPLUSFLAGS" => base_optimizer_flags + " -std=c++17"
|
|
44
52
|
}
|
|
45
53
|
|
|
46
54
|
# Don't install the dependencies when we run `pod install` in the old architecture.
|
|
47
55
|
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
|
|
48
|
-
s
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
"OTHER_CFLAGS" => base_optimizer_flags,
|
|
55
|
-
"OTHER_CPLUSPLUSFLAGS" => new_arch_cpp_flags + " " + base_optimizer_flags
|
|
56
|
-
}
|
|
57
|
-
s.dependency "React-Codegen"
|
|
58
|
-
s.dependency "RCT-Folly"
|
|
59
|
-
s.dependency "RCTRequired"
|
|
60
|
-
s.dependency "RCTTypeSafety"
|
|
61
|
-
s.dependency "ReactCommon/turbomodule/core"
|
|
56
|
+
install_modules_dependencies(s)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
s.subspec "no-require-arc" do |ss|
|
|
60
|
+
ss.requires_arc = false
|
|
61
|
+
ss.source_files = "cpp/*.m"
|
|
62
62
|
end
|
|
63
63
|
end
|
package/cpp/README.md
DELETED