kruko-whisper-rn 1.0.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/LICENSE +20 -0
- package/README.md +136 -0
- package/android/build.gradle +176 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/CMakeLists.txt +127 -0
- package/android/src/main/java/com/rnwhisper/JSCallInvokerResolver.java +40 -0
- package/android/src/main/java/com/rnwhisper/RNWhisper.java +108 -0
- package/android/src/main/java/com/rnwhisper/RNWhisperPackage.java +48 -0
- package/android/src/main/jni.cpp +848 -0
- package/android/src/newarch/java/com/rnwhisper/RNWhisperModule.java +89 -0
- package/android/src/oldarch/java/com/rnwhisper/RNWhisperModule.java +90 -0
- package/cpp/coreml/whisper-compat.h +10 -0
- package/cpp/coreml/whisper-compat.m +35 -0
- package/cpp/coreml/whisper-decoder-impl.h +158 -0
- package/cpp/coreml/whisper-decoder-impl.m +227 -0
- package/cpp/coreml/whisper-encoder-impl.h +154 -0
- package/cpp/coreml/whisper-encoder-impl.m +223 -0
- package/cpp/coreml/whisper-encoder.h +26 -0
- package/cpp/coreml/whisper-encoder.mm +73 -0
- package/cpp/ggml-alloc.c +1249 -0
- package/cpp/ggml-alloc.h +86 -0
- package/cpp/ggml-backend-dl.cpp +48 -0
- package/cpp/ggml-backend-dl.h +45 -0
- package/cpp/ggml-backend-impl.h +275 -0
- package/cpp/ggml-backend-meta.cpp +2495 -0
- package/cpp/ggml-backend-reg.cpp +593 -0
- package/cpp/ggml-backend.cpp +2443 -0
- package/cpp/ggml-backend.h +437 -0
- package/cpp/ggml-common.h +1911 -0
- package/cpp/ggml-cpp.h +39 -0
- package/cpp/ggml-cpu/amx/amx.cpp +249 -0
- package/cpp/ggml-cpu/amx/amx.h +8 -0
- package/cpp/ggml-cpu/amx/common.h +115 -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 +41 -0
- package/cpp/ggml-cpu/arch/arm/quants.c +4324 -0
- package/cpp/ggml-cpu/arch/arm/repack.cpp +5161 -0
- package/cpp/ggml-cpu/arch/x86/cpu-feats.cpp +327 -0
- package/cpp/ggml-cpu/arch/x86/quants.c +4113 -0
- package/cpp/ggml-cpu/arch/x86/repack.cpp +6412 -0
- package/cpp/ggml-cpu/arch-fallback.h +353 -0
- package/cpp/ggml-cpu/binary-ops.cpp +154 -0
- package/cpp/ggml-cpu/binary-ops.h +16 -0
- package/cpp/ggml-cpu/common.h +95 -0
- package/cpp/ggml-cpu/ggml-cpu-impl.h +539 -0
- package/cpp/ggml-cpu/ggml-cpu.c +3900 -0
- package/cpp/ggml-cpu/ggml-cpu.cpp +712 -0
- package/cpp/ggml-cpu/ops.cpp +12021 -0
- package/cpp/ggml-cpu/ops.h +124 -0
- package/cpp/ggml-cpu/quants.c +1339 -0
- package/cpp/ggml-cpu/quants.h +106 -0
- package/cpp/ggml-cpu/repack.cpp +4836 -0
- package/cpp/ggml-cpu/repack.h +245 -0
- package/cpp/ggml-cpu/simd-gemm.h +226 -0
- package/cpp/ggml-cpu/simd-mappings.h +1319 -0
- package/cpp/ggml-cpu/traits.cpp +36 -0
- package/cpp/ggml-cpu/traits.h +38 -0
- package/cpp/ggml-cpu/unary-ops.cpp +337 -0
- package/cpp/ggml-cpu/unary-ops.h +35 -0
- package/cpp/ggml-cpu/vec.cpp +613 -0
- package/cpp/ggml-cpu/vec.h +1570 -0
- package/cpp/ggml-cpu.h +152 -0
- package/cpp/ggml-feats.h +166 -0
- package/cpp/ggml-impl.h +783 -0
- package/cpp/ggml-metal/ggml-metal-common.cpp +457 -0
- package/cpp/ggml-metal/ggml-metal-common.h +52 -0
- package/cpp/ggml-metal/ggml-metal-context.h +41 -0
- package/cpp/ggml-metal/ggml-metal-context.m +739 -0
- package/cpp/ggml-metal/ggml-metal-device.cpp +2267 -0
- package/cpp/ggml-metal/ggml-metal-device.h +347 -0
- package/cpp/ggml-metal/ggml-metal-device.m +2352 -0
- package/cpp/ggml-metal/ggml-metal-impl.h +1314 -0
- package/cpp/ggml-metal/ggml-metal-ops.cpp +5369 -0
- package/cpp/ggml-metal/ggml-metal-ops.h +105 -0
- package/cpp/ggml-metal/ggml-metal-tuning.cpp +1087 -0
- package/cpp/ggml-metal/ggml-metal-tuning.h +77 -0
- package/cpp/ggml-metal/ggml-metal.cpp +998 -0
- package/cpp/ggml-metal/ggml-metal.metal +15106 -0
- package/cpp/ggml-metal/kernels/argsort.metal +232 -0
- package/cpp/ggml-metal/kernels/binbcast.metal +228 -0
- package/cpp/ggml-metal/kernels/common.h +126 -0
- package/cpp/ggml-metal/kernels/conv.metal +723 -0
- package/cpp/ggml-metal/kernels/dequantize.h +735 -0
- package/cpp/ggml-metal/kernels/fa.metal +2252 -0
- package/cpp/ggml-metal/kernels/gated_delta_net.metal +250 -0
- package/cpp/ggml-metal/kernels/misc.metal +595 -0
- package/cpp/ggml-metal/kernels/mul_mm.metal +853 -0
- package/cpp/ggml-metal/kernels/mul_mv.metal +3225 -0
- package/cpp/ggml-metal/kernels/norm.metal +308 -0
- package/cpp/ggml-metal/kernels/pool.metal +148 -0
- package/cpp/ggml-metal/kernels/quantize.h +262 -0
- package/cpp/ggml-metal/kernels/quantize.metal +435 -0
- package/cpp/ggml-metal/kernels/reduce.metal +228 -0
- package/cpp/ggml-metal/kernels/rope.metal +333 -0
- package/cpp/ggml-metal/kernels/softmax.metal +223 -0
- package/cpp/ggml-metal/kernels/solve_tri.metal +75 -0
- package/cpp/ggml-metal/kernels/ssm.metal +287 -0
- package/cpp/ggml-metal/kernels/tri.metal +69 -0
- package/cpp/ggml-metal/kernels/unary.metal +374 -0
- package/cpp/ggml-metal/kernels/upscale.metal +179 -0
- package/cpp/ggml-metal/kernels/wkv.metal +179 -0
- package/cpp/ggml-metal-impl.h +688 -0
- package/cpp/ggml-metal.h +61 -0
- package/cpp/ggml-opt.cpp +1094 -0
- package/cpp/ggml-opt.h +256 -0
- package/cpp/ggml-quants.c +5667 -0
- package/cpp/ggml-quants.h +115 -0
- package/cpp/ggml-threading.cpp +12 -0
- package/cpp/ggml-threading.h +14 -0
- package/cpp/ggml.c +8075 -0
- package/cpp/ggml.cpp +26 -0
- package/cpp/ggml.h +2950 -0
- package/cpp/gguf.cpp +1706 -0
- package/cpp/gguf.h +211 -0
- package/cpp/jsi/RNWhisperJSI.cpp +2792 -0
- package/cpp/jsi/RNWhisperJSI.h +102 -0
- package/cpp/jsi/ThreadPool.h +158 -0
- package/cpp/parakeet-arch.h +239 -0
- package/cpp/parakeet.cpp +3885 -0
- package/cpp/parakeet.h +342 -0
- package/cpp/rn-whisper-log.h +11 -0
- package/cpp/rn-whisper.cpp +155 -0
- package/cpp/rn-whisper.h +40 -0
- package/cpp/whisper-arch.h +197 -0
- package/cpp/whisper.cpp +9297 -0
- package/cpp/whisper.h +773 -0
- package/ios/CMakeLists.txt +131 -0
- package/ios/RNWhisper.h +18 -0
- package/ios/RNWhisper.mm +391 -0
- package/ios/RNWhisper.xcodeproj/project.pbxproj +278 -0
- package/ios/rnwhisper.xcframework/Info.plist +74 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-alloc.h +86 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-backend-dl.h +45 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-backend-impl.h +275 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-backend.h +437 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-common.h +1911 -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 +152 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-feats.h +166 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-impl.h +783 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-metal-impl.h +688 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-metal.h +61 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-opt.h +256 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-quants.h +115 -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 +2950 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/gguf.h +211 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/parakeet-arch.h +239 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/parakeet.h +342 -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 +40 -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 +773 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Info.plist +0 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/_CodeSignature/CodeResources +619 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/ggml-common.h +1911 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/ggml-metal-impl.h +1314 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/kernels/argsort.metal +232 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/kernels/binbcast.metal +228 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/kernels/common.h +126 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/kernels/conv.metal +723 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/kernels/dequantize.h +735 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/kernels/fa.metal +2252 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/kernels/gated_delta_net.metal +250 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/kernels/misc.metal +595 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/kernels/mul_mm.metal +853 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/kernels/mul_mv.metal +3225 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/kernels/norm.metal +308 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/kernels/pool.metal +148 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/kernels/quantize.h +262 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/kernels/quantize.metal +435 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/kernels/reduce.metal +228 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/kernels/rope.metal +333 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/kernels/softmax.metal +223 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/kernels/solve_tri.metal +75 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/kernels/ssm.metal +287 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/kernels/tri.metal +69 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/kernels/unary.metal +374 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/kernels/upscale.metal +179 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/kernels/wkv.metal +179 -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 +86 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend-dl.h +45 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend-impl.h +275 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend.h +437 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-common.h +1911 -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 +152 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-feats.h +166 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-impl.h +783 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-metal-impl.h +688 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-metal.h +61 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-opt.h +256 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-quants.h +115 -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 +2950 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/gguf.h +211 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/parakeet-arch.h +239 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/parakeet.h +342 -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 +40 -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 +773 -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 +619 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/ggml-common.h +1911 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/ggml-metal-impl.h +1314 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/kernels/argsort.metal +232 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/kernels/binbcast.metal +228 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/kernels/common.h +126 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/kernels/conv.metal +723 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/kernels/dequantize.h +735 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/kernels/fa.metal +2252 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/kernels/gated_delta_net.metal +250 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/kernels/misc.metal +595 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/kernels/mul_mm.metal +853 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/kernels/mul_mv.metal +3225 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/kernels/norm.metal +308 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/kernels/pool.metal +148 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/kernels/quantize.h +262 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/kernels/quantize.metal +435 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/kernels/reduce.metal +228 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/kernels/rope.metal +333 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/kernels/softmax.metal +223 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/kernels/solve_tri.metal +75 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/kernels/ssm.metal +287 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/kernels/tri.metal +69 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/kernels/unary.metal +374 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/kernels/upscale.metal +179 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/kernels/wkv.metal +179 -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 +86 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-backend-dl.h +45 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-backend-impl.h +275 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-backend.h +437 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-common.h +1911 -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 +152 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-feats.h +166 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-impl.h +783 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-metal-impl.h +688 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-metal.h +61 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-opt.h +256 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-quants.h +115 -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 +2950 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/gguf.h +211 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/parakeet-arch.h +239 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/parakeet.h +342 -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 +40 -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 +773 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Info.plist +0 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/_CodeSignature/CodeResources +619 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/ggml-common.h +1911 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/ggml-metal-impl.h +1314 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/kernels/argsort.metal +232 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/kernels/binbcast.metal +228 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/kernels/common.h +126 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/kernels/conv.metal +723 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/kernels/dequantize.h +735 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/kernels/fa.metal +2252 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/kernels/gated_delta_net.metal +250 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/kernels/misc.metal +595 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/kernels/mul_mm.metal +853 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/kernels/mul_mv.metal +3225 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/kernels/norm.metal +308 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/kernels/pool.metal +148 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/kernels/quantize.h +262 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/kernels/quantize.metal +435 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/kernels/reduce.metal +228 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/kernels/rope.metal +333 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/kernels/softmax.metal +223 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/kernels/solve_tri.metal +75 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/kernels/ssm.metal +287 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/kernels/tri.metal +69 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/kernels/unary.metal +374 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/kernels/upscale.metal +179 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/kernels/wkv.metal +179 -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 +86 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend-dl.h +45 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend-impl.h +275 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend.h +437 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-common.h +1911 -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 +152 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-feats.h +166 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-impl.h +783 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-metal-impl.h +688 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-metal.h +61 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-opt.h +256 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-quants.h +115 -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 +2950 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/gguf.h +211 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/parakeet-arch.h +239 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/parakeet.h +342 -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 +40 -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 +773 -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 +619 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/ggml-common.h +1911 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/ggml-metal-impl.h +1314 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/kernels/argsort.metal +232 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/kernels/binbcast.metal +228 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/kernels/common.h +126 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/kernels/conv.metal +723 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/kernels/dequantize.h +735 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/kernels/fa.metal +2252 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/kernels/gated_delta_net.metal +250 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/kernels/misc.metal +595 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/kernels/mul_mm.metal +853 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/kernels/mul_mv.metal +3225 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/kernels/norm.metal +308 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/kernels/pool.metal +148 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/kernels/quantize.h +262 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/kernels/quantize.metal +435 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/kernels/reduce.metal +228 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/kernels/rope.metal +333 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/kernels/softmax.metal +223 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/kernels/solve_tri.metal +75 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/kernels/ssm.metal +287 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/kernels/tri.metal +69 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/kernels/unary.metal +374 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/kernels/upscale.metal +179 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/kernels/wkv.metal +179 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/rnwhisper +0 -0
- package/lib/commonjs/NativeRNWhisper.js +10 -0
- package/lib/commonjs/NativeRNWhisper.js.map +1 -0
- package/lib/commonjs/index.js +543 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/jest-mock.js +87 -0
- package/lib/commonjs/jest-mock.js.map +1 -0
- package/lib/commonjs/jsi.js +6 -0
- package/lib/commonjs/jsi.js.map +1 -0
- package/lib/commonjs/realtime-transcription/RealtimeTranscriber.js +752 -0
- package/lib/commonjs/realtime-transcription/RealtimeTranscriber.js.map +1 -0
- package/lib/commonjs/realtime-transcription/RingBuffer.js +143 -0
- package/lib/commonjs/realtime-transcription/RingBuffer.js.map +1 -0
- package/lib/commonjs/realtime-transcription/RingBufferVad.js +241 -0
- package/lib/commonjs/realtime-transcription/RingBufferVad.js.map +1 -0
- package/lib/commonjs/realtime-transcription/SliceManager.js +230 -0
- package/lib/commonjs/realtime-transcription/SliceManager.js.map +1 -0
- package/lib/commonjs/realtime-transcription/adapters/AudioPcmStreamAdapter.js +133 -0
- package/lib/commonjs/realtime-transcription/adapters/AudioPcmStreamAdapter.js.map +1 -0
- package/lib/commonjs/realtime-transcription/adapters/JestAudioStreamAdapter.js +199 -0
- package/lib/commonjs/realtime-transcription/adapters/JestAudioStreamAdapter.js.map +1 -0
- package/lib/commonjs/realtime-transcription/adapters/SimulateFileAudioStreamAdapter.js +312 -0
- package/lib/commonjs/realtime-transcription/adapters/SimulateFileAudioStreamAdapter.js.map +1 -0
- package/lib/commonjs/realtime-transcription/index.js +41 -0
- package/lib/commonjs/realtime-transcription/index.js.map +1 -0
- package/lib/commonjs/realtime-transcription/types.js +122 -0
- package/lib/commonjs/realtime-transcription/types.js.map +1 -0
- package/lib/commonjs/utils/WavFileReader.js +207 -0
- package/lib/commonjs/utils/WavFileReader.js.map +1 -0
- package/lib/commonjs/utils/WavFileWriter.js +181 -0
- package/lib/commonjs/utils/WavFileWriter.js.map +1 -0
- package/lib/commonjs/utils/common.js +25 -0
- package/lib/commonjs/utils/common.js.map +1 -0
- package/lib/commonjs/utils/pcm.js +80 -0
- package/lib/commonjs/utils/pcm.js.map +1 -0
- package/lib/commonjs/version.json +1 -0
- package/lib/module/NativeRNWhisper.js +6 -0
- package/lib/module/NativeRNWhisper.js.map +1 -0
- package/lib/module/index.js +523 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/jest-mock.js +85 -0
- package/lib/module/jest-mock.js.map +1 -0
- package/lib/module/jsi.js +4 -0
- package/lib/module/jsi.js.map +1 -0
- package/lib/module/realtime-transcription/RealtimeTranscriber.js +745 -0
- package/lib/module/realtime-transcription/RealtimeTranscriber.js.map +1 -0
- package/lib/module/realtime-transcription/RingBuffer.js +136 -0
- package/lib/module/realtime-transcription/RingBuffer.js.map +1 -0
- package/lib/module/realtime-transcription/RingBufferVad.js +234 -0
- package/lib/module/realtime-transcription/RingBufferVad.js.map +1 -0
- package/lib/module/realtime-transcription/SliceManager.js +223 -0
- package/lib/module/realtime-transcription/SliceManager.js.map +1 -0
- package/lib/module/realtime-transcription/adapters/AudioPcmStreamAdapter.js +124 -0
- package/lib/module/realtime-transcription/adapters/AudioPcmStreamAdapter.js.map +1 -0
- package/lib/module/realtime-transcription/adapters/JestAudioStreamAdapter.js +192 -0
- package/lib/module/realtime-transcription/adapters/JestAudioStreamAdapter.js.map +1 -0
- package/lib/module/realtime-transcription/adapters/SimulateFileAudioStreamAdapter.js +305 -0
- package/lib/module/realtime-transcription/adapters/SimulateFileAudioStreamAdapter.js.map +1 -0
- package/lib/module/realtime-transcription/index.js +15 -0
- package/lib/module/realtime-transcription/index.js.map +1 -0
- package/lib/module/realtime-transcription/types.js +116 -0
- package/lib/module/realtime-transcription/types.js.map +1 -0
- package/lib/module/utils/WavFileReader.js +200 -0
- package/lib/module/utils/WavFileReader.js.map +1 -0
- package/lib/module/utils/WavFileWriter.js +174 -0
- package/lib/module/utils/WavFileWriter.js.map +1 -0
- package/lib/module/utils/common.js +18 -0
- package/lib/module/utils/common.js.map +1 -0
- package/lib/module/utils/pcm.js +72 -0
- package/lib/module/utils/pcm.js.map +1 -0
- package/lib/module/version.json +1 -0
- package/lib/typescript/NativeRNWhisper.d.ts +109 -0
- package/lib/typescript/NativeRNWhisper.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +197 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/jest-mock.d.ts +2 -0
- package/lib/typescript/jest-mock.d.ts.map +1 -0
- package/lib/typescript/jsi.d.ts +49 -0
- package/lib/typescript/jsi.d.ts.map +1 -0
- package/lib/typescript/realtime-transcription/RealtimeTranscriber.d.ts +147 -0
- package/lib/typescript/realtime-transcription/RealtimeTranscriber.d.ts.map +1 -0
- package/lib/typescript/realtime-transcription/RingBuffer.d.ts +66 -0
- package/lib/typescript/realtime-transcription/RingBuffer.d.ts.map +1 -0
- package/lib/typescript/realtime-transcription/RingBufferVad.d.ts +44 -0
- package/lib/typescript/realtime-transcription/RingBufferVad.d.ts.map +1 -0
- package/lib/typescript/realtime-transcription/SliceManager.d.ts +72 -0
- package/lib/typescript/realtime-transcription/SliceManager.d.ts.map +1 -0
- package/lib/typescript/realtime-transcription/adapters/AudioPcmStreamAdapter.d.ts +22 -0
- package/lib/typescript/realtime-transcription/adapters/AudioPcmStreamAdapter.d.ts.map +1 -0
- package/lib/typescript/realtime-transcription/adapters/JestAudioStreamAdapter.d.ts +44 -0
- package/lib/typescript/realtime-transcription/adapters/JestAudioStreamAdapter.d.ts.map +1 -0
- package/lib/typescript/realtime-transcription/adapters/SimulateFileAudioStreamAdapter.d.ts +76 -0
- package/lib/typescript/realtime-transcription/adapters/SimulateFileAudioStreamAdapter.d.ts.map +1 -0
- package/lib/typescript/realtime-transcription/index.d.ts +8 -0
- package/lib/typescript/realtime-transcription/index.d.ts.map +1 -0
- package/lib/typescript/realtime-transcription/types.d.ts +257 -0
- package/lib/typescript/realtime-transcription/types.d.ts.map +1 -0
- package/lib/typescript/utils/WavFileReader.d.ts +63 -0
- package/lib/typescript/utils/WavFileReader.d.ts.map +1 -0
- package/lib/typescript/utils/WavFileWriter.d.ts +57 -0
- package/lib/typescript/utils/WavFileWriter.d.ts.map +1 -0
- package/lib/typescript/utils/common.d.ts +9 -0
- package/lib/typescript/utils/common.d.ts.map +1 -0
- package/lib/typescript/utils/pcm.d.ts +37 -0
- package/lib/typescript/utils/pcm.d.ts.map +1 -0
- package/package.json +176 -0
- package/src/NativeRNWhisper.ts +122 -0
- package/src/index.ts +778 -0
- package/src/jest-mock.ts +83 -0
- package/src/jsi.ts +100 -0
- package/src/realtime-transcription/RealtimeTranscriber.ts +867 -0
- package/src/realtime-transcription/RingBuffer.ts +147 -0
- package/src/realtime-transcription/RingBufferVad.ts +283 -0
- package/src/realtime-transcription/SliceManager.ts +252 -0
- package/src/realtime-transcription/adapters/AudioPcmStreamAdapter.ts +143 -0
- package/src/realtime-transcription/adapters/JestAudioStreamAdapter.ts +251 -0
- package/src/realtime-transcription/adapters/SimulateFileAudioStreamAdapter.ts +382 -0
- package/src/realtime-transcription/index.ts +37 -0
- package/src/realtime-transcription/types.ts +337 -0
- package/src/utils/WavFileReader.ts +282 -0
- package/src/utils/WavFileWriter.ts +206 -0
- package/src/utils/common.ts +17 -0
- package/src/utils/pcm.ts +87 -0
- package/src/version.json +1 -0
- package/whisper-rn.podspec +70 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Jhen-Jie Hong
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# kruko-whisper-rn
|
|
2
|
+
|
|
3
|
+
A hardened fork of [`whisper.rn`](https://github.com/mybigday/whisper.rn) — the React Native binding of
|
|
4
|
+
`whisper.cpp` — maintained by **Kruko AI** for the Kruko AI mobile engine.
|
|
5
|
+
|
|
6
|
+
`whisper.rn` is MIT-licensed work by [Jhen-Jie Hong](https://github.com/mybigday). This fork keeps that
|
|
7
|
+
licence and that attribution; see [License](#license). It tracks upstream `0.7.4`.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Why this fork exists
|
|
12
|
+
|
|
13
|
+
`whisper.rn` requires **mono, 16 kHz, signed 16-bit PCM**. The native side reads the input buffer as
|
|
14
|
+
`int16` and divides by 32767. There is no float32 decoder on the JSI path.
|
|
15
|
+
|
|
16
|
+
That contract was easy to violate in a way that is nearly invisible, because the source disagreed with
|
|
17
|
+
itself about it:
|
|
18
|
+
|
|
19
|
+
| Source | Said |
|
|
20
|
+
|---|---|
|
|
21
|
+
| `WhisperContext.transcribeData` JSDoc | *"base64 encoded **float32** PCM data or ArrayBuffer"* |
|
|
22
|
+
| `ParakeetContext.transcribeData` JSDoc | *"base64-encoded signed **16-bit** PCM data"* |
|
|
23
|
+
| `README` | *"accepts raw signed **16-bit** PCM as a base64 string or `ArrayBuffer`"* |
|
|
24
|
+
|
|
25
|
+
Pass `float32.buffer` to the first one and nothing throws. The native side reads each pair of float bytes
|
|
26
|
+
as one `int16` sample, so you get twice as many samples of noise, and usually an empty transcription with
|
|
27
|
+
no error anywhere. We lost days to that on a real device before working out that our input was wrong and
|
|
28
|
+
the library was right.
|
|
29
|
+
|
|
30
|
+
So this fork's goal is narrow and specific: **make the input contract impossible to get wrong.**
|
|
31
|
+
|
|
32
|
+
## What this fork adds
|
|
33
|
+
|
|
34
|
+
**1. The documentation no longer lies.** Both `transcribeData` JSDoc comments now state the real
|
|
35
|
+
requirement, with the failure mode spelled out.
|
|
36
|
+
|
|
37
|
+
**2. `Float32Array` is accepted directly.** Samples in `-1..1` are converted to signed 16-bit PCM for you
|
|
38
|
+
(`src/utils/pcm.ts`). `Int16Array` and `ArrayBuffer` are taken as already being int16, exactly as before.
|
|
39
|
+
|
|
40
|
+
**3. Malformed input is rejected instead of truncated.** A buffer with an odd byte length cannot be int16
|
|
41
|
+
at all. It now throws a message naming the likely cause, rather than producing an empty transcription.
|
|
42
|
+
|
|
43
|
+
**4. An opt-in silence gate.** `silenceThreshold` drops a buffer whose peak sample is below the threshold
|
|
44
|
+
before inference runs:
|
|
45
|
+
|
|
46
|
+
```js
|
|
47
|
+
const { promise } = context.transcribeData(pcm16, {
|
|
48
|
+
language: 'en',
|
|
49
|
+
silenceThreshold: 0.01,
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
const { result, skipped } = await promise
|
|
53
|
+
// skipped === 'silence' -> the buffer was dropped, result is ''
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
This matters because `whisper.cpp` does not return *nothing* on silence — it returns fluent,
|
|
57
|
+
confident-looking text. Measuring the buffer is the only way to tell "nothing was said" from "something
|
|
58
|
+
was said". The gate is opt-in: omit `silenceThreshold` and behaviour is unchanged.
|
|
59
|
+
|
|
60
|
+
## What this fork does **not** do
|
|
61
|
+
|
|
62
|
+
Worth stating plainly, because forks tend to overclaim:
|
|
63
|
+
|
|
64
|
+
- **Upstream does not have a float32 HAL bug, and this fork does not fix one.** The int16 requirement is
|
|
65
|
+
upstream's documented contract and upstream is correct about it. Our original client code was wrong.
|
|
66
|
+
- **No native code is modified.** `android/`, `ios/` and `cpp/` are upstream `0.7.4` untouched. Everything
|
|
67
|
+
here is in the JavaScript/TypeScript layer.
|
|
68
|
+
- **The silence gate suppresses silence, not hallucinations in general.** It cannot tell you whether a
|
|
69
|
+
non-silent buffer was transcribed correctly. We have not measured an effect on music or noise; on
|
|
70
|
+
anything above the threshold, behaviour is upstream's.
|
|
71
|
+
- **No lifecycle or concurrency changes.** Upstream's `start`/`stop` handling is unchanged.
|
|
72
|
+
- **No performance work.** Nothing here makes inference faster.
|
|
73
|
+
|
|
74
|
+
If you need the fixes to audio *capture* (sample-rate, channel count, buffer format from the platform
|
|
75
|
+
recorder), those live in the application, not in this library — see
|
|
76
|
+
[Settings that are not in this fork](#settings-that-are-not-in-this-fork).
|
|
77
|
+
|
|
78
|
+
## Install
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
npm install kruko-whisper-rn
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Native setup is unchanged from `whisper.rn` (autolinking; nothing to add by hand). Read the
|
|
85
|
+
[upstream README](https://github.com/mybigday/whisper.rn#readme) and the
|
|
86
|
+
[upstream API docs](https://github.com/mybigday/whisper.rn/tree/main/docs/API) — they apply here too.
|
|
87
|
+
|
|
88
|
+
## Usage
|
|
89
|
+
|
|
90
|
+
Everything from `whisper.rn` works unchanged:
|
|
91
|
+
|
|
92
|
+
```js
|
|
93
|
+
import { initWhisper } from 'kruko-whisper-rn'
|
|
94
|
+
|
|
95
|
+
const context = await initWhisper({ filePath: require('./ggml-base.bin') })
|
|
96
|
+
|
|
97
|
+
const { promise } = context.transcribeData(pcm16ArrayBuffer, { language: 'en' })
|
|
98
|
+
const { result } = await promise
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
New in this fork — hand it float samples and let it convert:
|
|
102
|
+
|
|
103
|
+
```js
|
|
104
|
+
const floatSamples = new Float32Array(/* -1..1, mono, 16 kHz */)
|
|
105
|
+
|
|
106
|
+
const { promise } = context.transcribeData(floatSamples, {
|
|
107
|
+
language: 'en',
|
|
108
|
+
silenceThreshold: 0.01,
|
|
109
|
+
})
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Settings that are not in this fork
|
|
113
|
+
|
|
114
|
+
These are application-level, and are listed only so nobody goes looking for them in the source:
|
|
115
|
+
|
|
116
|
+
| Concern | Where it belongs |
|
|
117
|
+
|---|---|
|
|
118
|
+
| Transcription language | `options.language` — `whisper.cpp` defaults to `en`, so pass `'auto'` or an explicit code, and set `translate: false` unless you want English output |
|
|
119
|
+
| Capture format (sample rate, channels) | Your recorder. Read the rate and channel count from the actual buffer, not from the stream configuration |
|
|
120
|
+
| Resampling to 16 kHz | Your recorder or a resampler before `transcribeData` |
|
|
121
|
+
| Guarding against double-submission | Your UI layer |
|
|
122
|
+
|
|
123
|
+
## Version lineage
|
|
124
|
+
|
|
125
|
+
This package versions independently of upstream. It is based on `whisper.rn@0.7.4`; when upstream moves,
|
|
126
|
+
this fork rebases onto the new release rather than diverging.
|
|
127
|
+
|
|
128
|
+
## License
|
|
129
|
+
|
|
130
|
+
MIT, as upstream. The original copyright notice is retained in [`LICENSE`](./LICENSE):
|
|
131
|
+
|
|
132
|
+
> Copyright (c) 2023 Jhen-Jie Hong
|
|
133
|
+
|
|
134
|
+
Original project: <https://github.com/mybigday/whisper.rn>
|
|
135
|
+
|
|
136
|
+
Maintained by Kruko AI.
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
repositories {
|
|
3
|
+
google()
|
|
4
|
+
mavenCentral()
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
dependencies {
|
|
8
|
+
classpath "com.android.tools.build:gradle:7.2.1"
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
def isNewArchitectureEnabled() {
|
|
13
|
+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
apply plugin: "com.android.library"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }
|
|
20
|
+
|
|
21
|
+
if (isNewArchitectureEnabled()) {
|
|
22
|
+
apply plugin: "com.facebook.react"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
def getExtOrDefault(name) {
|
|
26
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["RNWhisper_" + name]
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
def getExtOrIntegerDefault(name) {
|
|
30
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["RNWhisper_" + name]).toInteger()
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
def reactNativeArchitectures() {
|
|
34
|
+
def value = project.getProperties().get("reactNativeArchitectures")
|
|
35
|
+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Detect RN Version as done here:
|
|
39
|
+
// https://github.com/software-mansion/react-native-reanimated/blob/66a6bd0e3a819ca7ae46751d36e405fe32b68b71/packages/react-native-reanimated/android/build.gradle#L73
|
|
40
|
+
def resolveReactNativeDirectory() {
|
|
41
|
+
def reactNativeLocation = rootProject.ext.has("REACT_NATIVE_NODE_MODULES_DIR") ? rootProject.ext.get("REACT_NATIVE_NODE_MODULES_DIR") : null
|
|
42
|
+
if (reactNativeLocation != null) {
|
|
43
|
+
return file(reactNativeLocation)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Fallback to node resolver for custom directory structures like monorepos.
|
|
47
|
+
def reactNativePackage = file(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim())
|
|
48
|
+
if(reactNativePackage.exists()) {
|
|
49
|
+
return reactNativePackage.parentFile
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
throw new GradleException(
|
|
53
|
+
"[Reanimated] Unable to resolve react-native location in node_modules. You should project extension property (in `app/build.gradle`) `REACT_NATIVE_NODE_MODULES_DIR` with path to react-native."
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
def reactNativeRootDir = resolveReactNativeDirectory()
|
|
58
|
+
|
|
59
|
+
def reactProperties = new Properties()
|
|
60
|
+
file("$reactNativeRootDir/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }
|
|
61
|
+
|
|
62
|
+
def REACT_NATIVE_VERSION = reactProperties.getProperty("VERSION_NAME")
|
|
63
|
+
def REACT_NATIVE_MINOR_VERSION = REACT_NATIVE_VERSION.startsWith("0.0.0-") ? 1000 : REACT_NATIVE_VERSION.split("\\.")[1].toInteger()
|
|
64
|
+
|
|
65
|
+
android {
|
|
66
|
+
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
|
|
67
|
+
if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
|
|
68
|
+
namespace "com.rnwhisper"
|
|
69
|
+
}
|
|
70
|
+
ndkVersion getExtOrDefault("ndkVersion")
|
|
71
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
72
|
+
|
|
73
|
+
defaultConfig {
|
|
74
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
75
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
76
|
+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
77
|
+
externalNativeBuild {
|
|
78
|
+
cmake {
|
|
79
|
+
abiFilters (*reactNativeArchitectures())
|
|
80
|
+
// Configure STL to be compatible with ReactAndroid JSI libraries
|
|
81
|
+
arguments "-DANDROID_STL=c++_shared",
|
|
82
|
+
"-DREACT_NATIVE_MINOR_VERSION=${REACT_NATIVE_MINOR_VERSION}",
|
|
83
|
+
"-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON"
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
ndk {
|
|
87
|
+
// Ensure shared STL is used for JSI compatibility
|
|
88
|
+
abiFilters (*reactNativeArchitectures())
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
packagingOptions {
|
|
93
|
+
doNotStrip resolveBuildType() == "debug" ? "**/**/*.so" : ""
|
|
94
|
+
excludes = [
|
|
95
|
+
"META-INF",
|
|
96
|
+
"META-INF/**",
|
|
97
|
+
"**/libc++_shared.so",
|
|
98
|
+
"**/libfbjni.so",
|
|
99
|
+
"**/libjsi.so",
|
|
100
|
+
"**/libfolly_json.so",
|
|
101
|
+
"**/libfolly_runtime.so",
|
|
102
|
+
"**/libglog.so",
|
|
103
|
+
"**/libreactnative.so",
|
|
104
|
+
"**/libreactnativejni.so",
|
|
105
|
+
"**/libturbomodulejsijni.so",
|
|
106
|
+
"**/libreact_nativemodule_core.so",
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
buildFeatures {
|
|
111
|
+
prefab = true
|
|
112
|
+
}
|
|
113
|
+
externalNativeBuild {
|
|
114
|
+
cmake {
|
|
115
|
+
path = file('src/main/CMakeLists.txt')
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// Exclude jniLibs when building from source
|
|
119
|
+
sourceSets {
|
|
120
|
+
main {
|
|
121
|
+
jniLibs.srcDirs = []
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
buildTypes {
|
|
125
|
+
release {
|
|
126
|
+
minifyEnabled false
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
lintOptions {
|
|
131
|
+
disable "GradleCompatible"
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
compileOptions {
|
|
135
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
136
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
sourceSets {
|
|
140
|
+
main {
|
|
141
|
+
if (isNewArchitectureEnabled()) {
|
|
142
|
+
java.srcDirs += ['src/newarch']
|
|
143
|
+
} else {
|
|
144
|
+
java.srcDirs += ['src/oldarch']
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
repositories {
|
|
151
|
+
mavenCentral()
|
|
152
|
+
google()
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
dependencies {
|
|
157
|
+
// For < 0.71, this will be from the local maven repo
|
|
158
|
+
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
159
|
+
//noinspection GradleDynamicVersion
|
|
160
|
+
implementation "com.facebook.react:react-native:+"
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (isNewArchitectureEnabled()) {
|
|
164
|
+
react {
|
|
165
|
+
jsRootDir = file("../src/")
|
|
166
|
+
libraryName = "RNWhisper"
|
|
167
|
+
codegenJavaPackageName = "com.rnwhisper"
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
def resolveBuildType() {
|
|
172
|
+
Gradle gradle = getGradle()
|
|
173
|
+
String tskReqStr = gradle.getStartParameter().getTaskRequests()["args"].toString()
|
|
174
|
+
|
|
175
|
+
return tskReqStr.contains("Release") ? "release" : "debug"
|
|
176
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.10)
|
|
2
|
+
|
|
3
|
+
project(whisper.rn)
|
|
4
|
+
|
|
5
|
+
set(CMAKE_CXX_STANDARD 17)
|
|
6
|
+
set(RNWHISPER_LIB_DIR ${CMAKE_SOURCE_DIR}/../../../cpp)
|
|
7
|
+
|
|
8
|
+
# Configure STL to be compatible with ReactAndroid JSI libraries
|
|
9
|
+
set(CMAKE_ANDROID_STL_TYPE c++_shared)
|
|
10
|
+
|
|
11
|
+
# Find ReactAndroid package for JSI
|
|
12
|
+
find_package(ReactAndroid REQUIRED CONFIG)
|
|
13
|
+
find_package(fbjni REQUIRED CONFIG)
|
|
14
|
+
|
|
15
|
+
include_directories(
|
|
16
|
+
${RNWHISPER_LIB_DIR}
|
|
17
|
+
${RNWHISPER_LIB_DIR}/ggml-cpu
|
|
18
|
+
${RNWHISPER_LIB_DIR}/jsi
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
set(
|
|
22
|
+
SOURCE_FILES
|
|
23
|
+
${RNWHISPER_LIB_DIR}/ggml.c
|
|
24
|
+
${RNWHISPER_LIB_DIR}/ggml.cpp
|
|
25
|
+
${RNWHISPER_LIB_DIR}/ggml-alloc.c
|
|
26
|
+
${RNWHISPER_LIB_DIR}/ggml-backend.cpp
|
|
27
|
+
${RNWHISPER_LIB_DIR}/ggml-backend-meta.cpp
|
|
28
|
+
${RNWHISPER_LIB_DIR}/ggml-backend-reg.cpp
|
|
29
|
+
${RNWHISPER_LIB_DIR}/ggml-backend-dl.cpp
|
|
30
|
+
${RNWHISPER_LIB_DIR}/ggml-cpu/amx/amx.cpp
|
|
31
|
+
${RNWHISPER_LIB_DIR}/ggml-cpu/amx/mmq.cpp
|
|
32
|
+
${RNWHISPER_LIB_DIR}/ggml-cpu/ggml-cpu.c
|
|
33
|
+
${RNWHISPER_LIB_DIR}/ggml-cpu/ggml-cpu.cpp
|
|
34
|
+
${RNWHISPER_LIB_DIR}/ggml-cpu/quants.c
|
|
35
|
+
${RNWHISPER_LIB_DIR}/ggml-cpu/traits.cpp
|
|
36
|
+
${RNWHISPER_LIB_DIR}/ggml-cpu/repack.cpp
|
|
37
|
+
${RNWHISPER_LIB_DIR}/ggml-cpu/unary-ops.cpp
|
|
38
|
+
${RNWHISPER_LIB_DIR}/ggml-cpu/binary-ops.cpp
|
|
39
|
+
${RNWHISPER_LIB_DIR}/ggml-cpu/vec.cpp
|
|
40
|
+
${RNWHISPER_LIB_DIR}/ggml-cpu/ops.cpp
|
|
41
|
+
${RNWHISPER_LIB_DIR}/ggml-opt.cpp
|
|
42
|
+
${RNWHISPER_LIB_DIR}/ggml-threading.cpp
|
|
43
|
+
${RNWHISPER_LIB_DIR}/ggml-quants.c
|
|
44
|
+
${RNWHISPER_LIB_DIR}/gguf.cpp
|
|
45
|
+
${RNWHISPER_LIB_DIR}/whisper.cpp
|
|
46
|
+
${RNWHISPER_LIB_DIR}/parakeet.cpp
|
|
47
|
+
${RNWHISPER_LIB_DIR}/rn-whisper.cpp
|
|
48
|
+
${RNWHISPER_LIB_DIR}/jsi/RNWhisperJSI.cpp
|
|
49
|
+
${CMAKE_SOURCE_DIR}/jni.cpp
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
find_library(LOG_LIB log)
|
|
53
|
+
|
|
54
|
+
function(build_library target_name arch cpu_flags)
|
|
55
|
+
if (NOT ${arch} STREQUAL "generic")
|
|
56
|
+
set(SOURCE_FILES_ARCH
|
|
57
|
+
${RNWHISPER_LIB_DIR}/ggml-cpu/arch/${arch}/quants.c
|
|
58
|
+
${RNWHISPER_LIB_DIR}/ggml-cpu/arch/${arch}/repack.cpp
|
|
59
|
+
)
|
|
60
|
+
endif ()
|
|
61
|
+
|
|
62
|
+
add_library(
|
|
63
|
+
${target_name}
|
|
64
|
+
SHARED
|
|
65
|
+
${SOURCE_FILES}
|
|
66
|
+
${SOURCE_FILES_ARCH}
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
# Link JSI libraries
|
|
70
|
+
if(${REACT_NATIVE_MINOR_VERSION} GREATER_EQUAL 76)
|
|
71
|
+
target_link_libraries(${target_name}
|
|
72
|
+
${LOG_LIB}
|
|
73
|
+
android
|
|
74
|
+
fbjni::fbjni
|
|
75
|
+
ReactAndroid::jsi
|
|
76
|
+
ReactAndroid::reactnative
|
|
77
|
+
)
|
|
78
|
+
else ()
|
|
79
|
+
target_link_libraries(${target_name}
|
|
80
|
+
${LOG_LIB}
|
|
81
|
+
android
|
|
82
|
+
fbjni::fbjni
|
|
83
|
+
ReactAndroid::jsi
|
|
84
|
+
ReactAndroid::turbomodulejsijni
|
|
85
|
+
ReactAndroid::react_nativemodule_core
|
|
86
|
+
)
|
|
87
|
+
endif ()
|
|
88
|
+
|
|
89
|
+
if (${arch} STREQUAL "generic")
|
|
90
|
+
target_compile_options(${target_name} PRIVATE -DWSP_GGML_CPU_GENERIC)
|
|
91
|
+
endif ()
|
|
92
|
+
|
|
93
|
+
# Expose Linux CPU affinity APIs used by ggml on Android.
|
|
94
|
+
target_compile_definitions(${target_name} PRIVATE _GNU_SOURCE)
|
|
95
|
+
target_compile_options(${target_name} PRIVATE -DWSP_GGML_USE_CPU -DWSP_GGML_USE_CPU_REPACK -pthread ${cpu_flags})
|
|
96
|
+
|
|
97
|
+
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
|
|
98
|
+
target_compile_options(${target_name} PRIVATE -DRNWHISPER_ANDROID_ENABLE_LOGGING)
|
|
99
|
+
endif ()
|
|
100
|
+
|
|
101
|
+
# NOTE: If you want to debug the native code, you can uncomment if and endif
|
|
102
|
+
# Note that it will be extremely slow
|
|
103
|
+
# if (NOT ${CMAKE_BUILD_TYPE} STREQUAL "Debug")
|
|
104
|
+
target_compile_options(${target_name} PRIVATE -O3 -DNDEBUG)
|
|
105
|
+
target_compile_options(${target_name} PRIVATE -fvisibility=hidden -fvisibility-inlines-hidden)
|
|
106
|
+
target_compile_options(${target_name} PRIVATE -ffunction-sections -fdata-sections)
|
|
107
|
+
|
|
108
|
+
target_link_options(${target_name} PRIVATE -Wl,--gc-sections)
|
|
109
|
+
target_link_options(${target_name} PRIVATE -Wl,--exclude-libs,ALL)
|
|
110
|
+
target_link_options(${target_name} PRIVATE -flto)
|
|
111
|
+
# endif ()
|
|
112
|
+
endfunction()
|
|
113
|
+
|
|
114
|
+
build_library("rnwhisper" "generic" "")
|
|
115
|
+
|
|
116
|
+
if (${ANDROID_ABI} STREQUAL "arm64-v8a")
|
|
117
|
+
build_library("rnwhisper_v8fp16_va_2" "arm" "-march=armv8.2-a+fp16")
|
|
118
|
+
build_library("rnwhisper_v8" "arm" "-march=armv8-a")
|
|
119
|
+
elseif (${ANDROID_ABI} STREQUAL "armeabi-v7a")
|
|
120
|
+
build_library("rnwhisper_vfpv4" "arm" "-mfpu=neon-vfpv4")
|
|
121
|
+
elseif (${ANDROID_ABI} STREQUAL "x86_64")
|
|
122
|
+
# x86_64 target
|
|
123
|
+
build_library("rnwhisper_x86_64" "x86" "-march=x86-64" "-mtune=intel" "-msse4.2" "-mpopcnt")
|
|
124
|
+
endif ()
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
include_directories(${RNWHISPER_LIB_DIR})
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
package com.rnwhisper;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.OptIn;
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
5
|
+
import com.facebook.react.common.annotations.FrameworkAPI;
|
|
6
|
+
import com.facebook.react.turbomodule.core.CallInvokerHolderImpl;
|
|
7
|
+
|
|
8
|
+
public class JSCallInvokerResolver {
|
|
9
|
+
|
|
10
|
+
@OptIn(markerClass = FrameworkAPI.class)
|
|
11
|
+
public static CallInvokerHolderImpl getJSCallInvokerHolder(ReactApplicationContext context) {
|
|
12
|
+
try {
|
|
13
|
+
var method = context.getClass().getMethod("getJSCallInvokerHolder");
|
|
14
|
+
return (CallInvokerHolderImpl) method.invoke(context);
|
|
15
|
+
} catch (Exception ignored) {
|
|
16
|
+
// In newer implementations, the method is in CatalystInstance, continue.
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
var catalystInstance = context.getClass().getMethod("getCatalystInstance").invoke(context);
|
|
20
|
+
assert catalystInstance != null;
|
|
21
|
+
var method = catalystInstance.getClass().getMethod("getJSCallInvokerHolder");
|
|
22
|
+
return (CallInvokerHolderImpl) method.invoke(catalystInstance);
|
|
23
|
+
} catch (Exception e) {
|
|
24
|
+
throw new RuntimeException("Failed to get JSCallInvokerHolder", e);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@OptIn(markerClass = FrameworkAPI.class)
|
|
29
|
+
public static long getJavaScriptContextHolder(ReactApplicationContext context) {
|
|
30
|
+
try {
|
|
31
|
+
var method = context.getClass().getMethod("getJavaScriptContextHolder");
|
|
32
|
+
var holder = method.invoke(context);
|
|
33
|
+
var getMethod = holder.getClass().getMethod("get");
|
|
34
|
+
return (Long) getMethod.invoke(holder);
|
|
35
|
+
} catch (Exception e) {
|
|
36
|
+
throw new RuntimeException("Failed to get JavaScriptContextHolder", e);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
package com.rnwhisper;
|
|
2
|
+
|
|
3
|
+
import android.os.Build;
|
|
4
|
+
import android.util.Log;
|
|
5
|
+
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
7
|
+
|
|
8
|
+
import java.io.BufferedReader;
|
|
9
|
+
import java.io.File;
|
|
10
|
+
import java.io.FileReader;
|
|
11
|
+
import java.io.IOException;
|
|
12
|
+
|
|
13
|
+
public class RNWhisper {
|
|
14
|
+
public static final String NAME = "RNWhisper";
|
|
15
|
+
private static final String TAG = "RNWhisper";
|
|
16
|
+
private static boolean libsLoaded = false;
|
|
17
|
+
|
|
18
|
+
private static boolean tryLoadLibrary(String library) {
|
|
19
|
+
try {
|
|
20
|
+
System.loadLibrary(library);
|
|
21
|
+
Log.d(TAG, "Loaded native library: " + library);
|
|
22
|
+
return true;
|
|
23
|
+
} catch (UnsatisfiedLinkError error) {
|
|
24
|
+
Log.w(TAG, "Unable to load native library " + library, error);
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public static synchronized boolean loadNative(ReactApplicationContext context) {
|
|
30
|
+
if (libsLoaded) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (Build.SUPPORTED_ABIS.length == 0) {
|
|
35
|
+
Log.w(TAG, "No supported ABIs reported by the runtime");
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
String cpuFeatures = getCpuFeatures();
|
|
40
|
+
boolean hasFp16 = cpuFeatures.contains("fp16") || cpuFeatures.contains("fphp");
|
|
41
|
+
|
|
42
|
+
try {
|
|
43
|
+
if (isArm64V8a()) {
|
|
44
|
+
if (hasFp16 && tryLoadLibrary("rnwhisper_v8fp16_va_2")) {
|
|
45
|
+
libsLoaded = true;
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (tryLoadLibrary("rnwhisper_v8")) {
|
|
50
|
+
libsLoaded = true;
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
} else if (isArmeabiV7a()) {
|
|
54
|
+
if (tryLoadLibrary("rnwhisper_vfpv4")) {
|
|
55
|
+
libsLoaded = true;
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
} else if (isX86_64()) {
|
|
59
|
+
if (tryLoadLibrary("rnwhisper_x86_64")) {
|
|
60
|
+
libsLoaded = true;
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (tryLoadLibrary("rnwhisper")) {
|
|
66
|
+
libsLoaded = true;
|
|
67
|
+
}
|
|
68
|
+
} catch (UnsatisfiedLinkError error) {
|
|
69
|
+
Log.e(TAG, "Failed to load RNWhisper native library", error);
|
|
70
|
+
libsLoaded = false;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return libsLoaded;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private static boolean isArm64V8a() {
|
|
77
|
+
return Build.SUPPORTED_ABIS.length > 0
|
|
78
|
+
&& Build.SUPPORTED_ABIS[0].equals("arm64-v8a");
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
private static boolean isArmeabiV7a() {
|
|
82
|
+
return Build.SUPPORTED_ABIS.length > 0
|
|
83
|
+
&& Build.SUPPORTED_ABIS[0].equals("armeabi-v7a");
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
private static boolean isX86_64() {
|
|
87
|
+
return Build.SUPPORTED_ABIS.length > 0
|
|
88
|
+
&& Build.SUPPORTED_ABIS[0].equals("x86_64");
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
private static String getCpuFeatures() {
|
|
92
|
+
File file = new File("/proc/cpuinfo");
|
|
93
|
+
StringBuilder builder = new StringBuilder();
|
|
94
|
+
try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) {
|
|
95
|
+
String line;
|
|
96
|
+
while ((line = bufferedReader.readLine()) != null) {
|
|
97
|
+
if (line.startsWith("Features")) {
|
|
98
|
+
builder.append(line);
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return builder.toString();
|
|
103
|
+
} catch (IOException error) {
|
|
104
|
+
Log.w(TAG, "Couldn't read /proc/cpuinfo", error);
|
|
105
|
+
return "";
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
package com.rnwhisper;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
5
|
+
|
|
6
|
+
import com.facebook.react.bridge.NativeModule;
|
|
7
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
8
|
+
import com.facebook.react.module.model.ReactModuleInfo;
|
|
9
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider;
|
|
10
|
+
import com.facebook.react.TurboReactPackage;
|
|
11
|
+
|
|
12
|
+
import java.util.List;
|
|
13
|
+
import java.util.HashMap;
|
|
14
|
+
import java.util.Map;
|
|
15
|
+
|
|
16
|
+
public class RNWhisperPackage extends TurboReactPackage {
|
|
17
|
+
|
|
18
|
+
@Nullable
|
|
19
|
+
@Override
|
|
20
|
+
public NativeModule getModule(String name, ReactApplicationContext reactContext) {
|
|
21
|
+
if (name.equals(RNWhisperModule.NAME)) {
|
|
22
|
+
return new com.rnwhisper.RNWhisperModule(reactContext);
|
|
23
|
+
} else {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@Override
|
|
29
|
+
public ReactModuleInfoProvider getReactModuleInfoProvider() {
|
|
30
|
+
return () -> {
|
|
31
|
+
final Map<String, ReactModuleInfo> moduleInfos = new HashMap<>();
|
|
32
|
+
boolean isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
|
|
33
|
+
moduleInfos.put(
|
|
34
|
+
RNWhisperModule.NAME,
|
|
35
|
+
new ReactModuleInfo(
|
|
36
|
+
RNWhisperModule.NAME,
|
|
37
|
+
RNWhisperModule.NAME,
|
|
38
|
+
false, // canOverrideExistingModule
|
|
39
|
+
false, // needsEagerInit
|
|
40
|
+
true, // hasConstants
|
|
41
|
+
false, // isCxxModule
|
|
42
|
+
isTurboModule // isTurboModule
|
|
43
|
+
)
|
|
44
|
+
);
|
|
45
|
+
return moduleInfos;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|