whisper.rn 0.4.0-rc.9 → 0.4.1
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 +74 -1
- package/android/build.gradle +12 -3
- package/android/src/main/CMakeLists.txt +43 -13
- package/android/src/main/java/com/rnwhisper/RNWhisper.java +211 -0
- package/android/src/main/java/com/rnwhisper/WhisperContext.java +64 -36
- package/android/src/main/java/com/rnwhisper/WhisperVadContext.java +157 -0
- package/android/src/main/jni.cpp +205 -0
- 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 +26 -0
- package/android/src/oldarch/java/com/rnwhisper/RNWhisperModule.java +26 -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 +39 -37
- package/cpp/ggml-alloc.h +1 -1
- package/cpp/ggml-backend-impl.h +55 -27
- package/cpp/ggml-backend-reg.cpp +591 -0
- package/cpp/ggml-backend.cpp +336 -955
- package/cpp/ggml-backend.h +70 -42
- package/cpp/ggml-common.h +57 -49
- 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 +417 -23
- package/cpp/ggml-metal-impl.h +622 -0
- package/cpp/ggml-metal.h +9 -9
- package/cpp/ggml-metal.m +3451 -1344
- package/cpp/ggml-opt.cpp +1037 -0
- package/cpp/ggml-opt.h +237 -0
- package/cpp/ggml-quants.c +296 -10818
- package/cpp/ggml-quants.h +78 -125
- 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 +4633 -21450
- package/cpp/ggml.h +320 -661
- package/cpp/gguf.cpp +1347 -0
- package/cpp/gguf.h +202 -0
- package/cpp/rn-whisper.cpp +4 -11
- package/cpp/whisper-arch.h +197 -0
- package/cpp/whisper.cpp +2022 -495
- package/cpp/whisper.h +75 -18
- package/ios/CMakeLists.txt +95 -0
- package/ios/RNWhisper.h +5 -0
- package/ios/RNWhisper.mm +147 -0
- package/ios/RNWhisperAudioUtils.m +4 -0
- package/ios/RNWhisperContext.h +5 -0
- package/ios/RNWhisperContext.mm +22 -26
- package/ios/RNWhisperVadContext.h +29 -0
- package/ios/RNWhisperVadContext.mm +152 -0
- 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 +24 -0
- package/lib/commonjs/NativeRNWhisper.js.map +1 -1
- package/lib/commonjs/index.js +111 -1
- 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 +112 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/NativeRNWhisper.d.ts +35 -0
- package/lib/typescript/NativeRNWhisper.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +39 -3
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +10 -6
- package/src/NativeRNWhisper.ts +48 -0
- package/src/index.ts +132 -1
- package/src/version.json +1 -1
- package/whisper-rn.podspec +11 -18
- package/cpp/README.md +0 -4
- package/cpp/ggml-aarch64.c +0 -3209
- package/cpp/ggml-aarch64.h +0 -39
- package/cpp/ggml-cpu-impl.h +0 -614
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { NativeWhisperContext } from './NativeRNWhisper';
|
|
2
|
-
import type { TranscribeOptions, TranscribeResult } from './NativeRNWhisper';
|
|
1
|
+
import { NativeWhisperContext, NativeWhisperVadContext } from './NativeRNWhisper';
|
|
2
|
+
import type { TranscribeOptions, TranscribeResult, VadOptions, VadSegment } from './NativeRNWhisper';
|
|
3
3
|
import AudioSessionIos from './AudioSessionIos';
|
|
4
4
|
import type { AudioSessionCategoryIos, AudioSessionCategoryOptionIos, AudioSessionModeIos } from './AudioSessionIos';
|
|
5
|
-
export type { TranscribeOptions, TranscribeResult, AudioSessionCategoryIos, AudioSessionCategoryOptionIos, AudioSessionModeIos, };
|
|
5
|
+
export type { TranscribeOptions, TranscribeResult, AudioSessionCategoryIos, AudioSessionCategoryOptionIos, AudioSessionModeIos, VadOptions, VadSegment, };
|
|
6
6
|
export type TranscribeNewSegmentsResult = {
|
|
7
7
|
nNew: number;
|
|
8
8
|
totalNNew: number;
|
|
@@ -194,4 +194,40 @@ export declare const isUseCoreML: boolean;
|
|
|
194
194
|
/** Is allow fallback to CPU if load CoreML model failed */
|
|
195
195
|
export declare const isCoreMLAllowFallback: boolean;
|
|
196
196
|
export { AudioSessionIos };
|
|
197
|
+
export type VadContextOptions = {
|
|
198
|
+
filePath: string | number;
|
|
199
|
+
/** Is the file path a bundle asset for pure string filePath */
|
|
200
|
+
isBundleAsset?: boolean;
|
|
201
|
+
/** Use GPU if available. Currently iOS only */
|
|
202
|
+
useGpu?: boolean;
|
|
203
|
+
/** Number of threads to use during computation (Default: 2 for 4-core devices, 4 for more cores) */
|
|
204
|
+
nThreads?: number;
|
|
205
|
+
};
|
|
206
|
+
export declare class WhisperVadContext {
|
|
207
|
+
id: number;
|
|
208
|
+
gpu: boolean;
|
|
209
|
+
reasonNoGPU: string;
|
|
210
|
+
constructor({ contextId, gpu, reasonNoGPU, }: NativeWhisperVadContext);
|
|
211
|
+
/**
|
|
212
|
+
* Detect speech segments in audio file (path or base64 encoded wav file)
|
|
213
|
+
* base64: need add `data:audio/wav;base64,` prefix
|
|
214
|
+
*/
|
|
215
|
+
detectSpeech(filePathOrBase64: string | number, options?: VadOptions): Promise<VadSegment[]>;
|
|
216
|
+
/**
|
|
217
|
+
* Detect speech segments in raw audio data (base64 encoded float32 PCM data)
|
|
218
|
+
*/
|
|
219
|
+
detectSpeechData(audioData: string, options?: VadOptions): Promise<VadSegment[]>;
|
|
220
|
+
release(): Promise<void>;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Initialize a VAD context for voice activity detection
|
|
224
|
+
* @param options VAD context options
|
|
225
|
+
* @returns Promise resolving to WhisperVadContext instance
|
|
226
|
+
*/
|
|
227
|
+
export declare function initWhisperVad({ filePath, isBundleAsset, useGpu, nThreads, }: VadContextOptions): Promise<WhisperVadContext>;
|
|
228
|
+
/**
|
|
229
|
+
* Release all VAD contexts and free their memory
|
|
230
|
+
* @returns Promise resolving when all contexts are released
|
|
231
|
+
*/
|
|
232
|
+
export declare function releaseAllWhisperVad(): Promise<void>;
|
|
197
233
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAOA,OAAkB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAOA,OAAkB,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAC5F,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAEhB,UAAU,EACV,UAAU,EACX,MAAM,mBAAmB,CAAA;AAC1B,OAAO,eAAe,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAAK,EACV,uBAAuB,EACvB,6BAA6B,EAC7B,mBAAmB,EACpB,MAAM,mBAAmB,CAAA;AAY1B,YAAY,EACV,iBAAiB,EACjB,g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ClB,CAAA;AAED,qBAAa,iBAAiB;IAC5B,EAAE,EAAE,MAAM,CAAA;IAEV,GAAG,EAAE,OAAO,CAAQ;IAEpB,WAAW,EAAE,MAAM,CAAK;gBAEZ,EACV,SAAS,EACT,GAAG,EACH,WAAW,GACZ,EAAE,uBAAuB;IAM1B;;;OAGG;IACG,YAAY,CAChB,gBAAgB,EAAE,MAAM,GAAG,MAAM,EACjC,OAAO,GAAE,UAAe,GACvB,OAAO,CAAC,UAAU,EAAE,CAAC;IA4BxB;;OAEG;IACG,gBAAgB,CACpB,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,UAAe,GACvB,OAAO,CAAC,UAAU,EAAE,CAAC;IAIlB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAG/B;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,EACnC,QAAQ,EACR,aAAa,EACb,MAAa,EACb,QAAQ,GACT,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA0BhD;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAE1D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "whisper.rn",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
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",
|
package/src/NativeRNWhisper.ts
CHANGED
|
@@ -65,6 +65,39 @@ export type NativeWhisperContext = {
|
|
|
65
65
|
reasonNoGPU: string
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
export type VadOptions = {
|
|
69
|
+
/** Probability threshold to consider as speech (Default: 0.5) */
|
|
70
|
+
threshold?: number,
|
|
71
|
+
/** Min duration for a valid speech segment in ms (Default: 250) */
|
|
72
|
+
minSpeechDurationMs?: number,
|
|
73
|
+
/** Min silence duration to consider speech as ended in ms (Default: 100) */
|
|
74
|
+
minSilenceDurationMs?: number,
|
|
75
|
+
/** Max duration of a speech segment before forcing a new segment in seconds (Default: 30) */
|
|
76
|
+
maxSpeechDurationS?: number,
|
|
77
|
+
/** Padding added before and after speech segments in ms (Default: 30) */
|
|
78
|
+
speechPadMs?: number,
|
|
79
|
+
/** Overlap in seconds when copying audio samples from speech segment (Default: 0.1) */
|
|
80
|
+
samplesOverlap?: number,
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
type NativeVadContextOptions = {
|
|
84
|
+
filePath: string,
|
|
85
|
+
isBundleAsset: boolean,
|
|
86
|
+
useGpu?: boolean,
|
|
87
|
+
nThreads?: number,
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export type NativeWhisperVadContext = {
|
|
91
|
+
contextId: number
|
|
92
|
+
gpu: boolean
|
|
93
|
+
reasonNoGPU: string
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export type VadSegment = {
|
|
97
|
+
t0: number
|
|
98
|
+
t1: number
|
|
99
|
+
}
|
|
100
|
+
|
|
68
101
|
export interface Spec extends TurboModule {
|
|
69
102
|
getConstants(): {
|
|
70
103
|
useCoreML: boolean
|
|
@@ -94,6 +127,21 @@ export interface Spec extends TurboModule {
|
|
|
94
127
|
|
|
95
128
|
bench(contextId: number, maxThreads: number): Promise<string>;
|
|
96
129
|
|
|
130
|
+
// VAD methods
|
|
131
|
+
initVadContext(options: NativeVadContextOptions): Promise<NativeWhisperVadContext>;
|
|
132
|
+
releaseVadContext(contextId: number): Promise<void>;
|
|
133
|
+
releaseAllVadContexts(): Promise<void>;
|
|
134
|
+
vadDetectSpeech(
|
|
135
|
+
contextId: number,
|
|
136
|
+
audioData: string, // base64 encoded float32 PCM data
|
|
137
|
+
options: VadOptions,
|
|
138
|
+
): Promise<VadSegment[]>;
|
|
139
|
+
vadDetectSpeechFile(
|
|
140
|
+
contextId: number,
|
|
141
|
+
filePathOrBase64: string,
|
|
142
|
+
options: VadOptions,
|
|
143
|
+
): Promise<VadSegment[]>;
|
|
144
|
+
|
|
97
145
|
// iOS specific
|
|
98
146
|
getAudioSessionCurrentCategory: () => Promise<{
|
|
99
147
|
category: string,
|
package/src/index.ts
CHANGED
|
@@ -5,11 +5,13 @@ import {
|
|
|
5
5
|
DeviceEventEmitterStatic,
|
|
6
6
|
Image,
|
|
7
7
|
} from 'react-native'
|
|
8
|
-
import RNWhisper, { NativeWhisperContext } from './NativeRNWhisper'
|
|
8
|
+
import RNWhisper, { NativeWhisperContext, NativeWhisperVadContext } from './NativeRNWhisper'
|
|
9
9
|
import type {
|
|
10
10
|
TranscribeOptions,
|
|
11
11
|
TranscribeResult,
|
|
12
12
|
CoreMLAsset,
|
|
13
|
+
VadOptions,
|
|
14
|
+
VadSegment,
|
|
13
15
|
} from './NativeRNWhisper'
|
|
14
16
|
import AudioSessionIos from './AudioSessionIos'
|
|
15
17
|
import type {
|
|
@@ -34,6 +36,8 @@ export type {
|
|
|
34
36
|
AudioSessionCategoryIos,
|
|
35
37
|
AudioSessionCategoryOptionIos,
|
|
36
38
|
AudioSessionModeIos,
|
|
39
|
+
VadOptions,
|
|
40
|
+
VadSegment,
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
const EVENT_ON_TRANSCRIBE_PROGRESS = '@RNWhisper_onTranscribeProgress'
|
|
@@ -582,3 +586,130 @@ export const isUseCoreML: boolean = !!useCoreML
|
|
|
582
586
|
export const isCoreMLAllowFallback: boolean = !!coreMLAllowFallback
|
|
583
587
|
|
|
584
588
|
export { AudioSessionIos }
|
|
589
|
+
|
|
590
|
+
//
|
|
591
|
+
// VAD (Voice Activity Detection) Context
|
|
592
|
+
//
|
|
593
|
+
|
|
594
|
+
export type VadContextOptions = {
|
|
595
|
+
filePath: string | number
|
|
596
|
+
/** Is the file path a bundle asset for pure string filePath */
|
|
597
|
+
isBundleAsset?: boolean
|
|
598
|
+
/** Use GPU if available. Currently iOS only */
|
|
599
|
+
useGpu?: boolean
|
|
600
|
+
/** Number of threads to use during computation (Default: 2 for 4-core devices, 4 for more cores) */
|
|
601
|
+
nThreads?: number
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
export class WhisperVadContext {
|
|
605
|
+
id: number
|
|
606
|
+
|
|
607
|
+
gpu: boolean = false
|
|
608
|
+
|
|
609
|
+
reasonNoGPU: string = ''
|
|
610
|
+
|
|
611
|
+
constructor({
|
|
612
|
+
contextId,
|
|
613
|
+
gpu,
|
|
614
|
+
reasonNoGPU,
|
|
615
|
+
}: NativeWhisperVadContext) {
|
|
616
|
+
this.id = contextId
|
|
617
|
+
this.gpu = gpu
|
|
618
|
+
this.reasonNoGPU = reasonNoGPU
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* Detect speech segments in audio file (path or base64 encoded wav file)
|
|
623
|
+
* base64: need add `data:audio/wav;base64,` prefix
|
|
624
|
+
*/
|
|
625
|
+
async detectSpeech(
|
|
626
|
+
filePathOrBase64: string | number,
|
|
627
|
+
options: VadOptions = {}
|
|
628
|
+
): Promise<VadSegment[]> {
|
|
629
|
+
let path = ''
|
|
630
|
+
if (typeof filePathOrBase64 === 'number') {
|
|
631
|
+
try {
|
|
632
|
+
const source = Image.resolveAssetSource(filePathOrBase64)
|
|
633
|
+
if (source) path = source.uri
|
|
634
|
+
} catch (e) {
|
|
635
|
+
throw new Error(`Invalid asset: ${filePathOrBase64}`)
|
|
636
|
+
}
|
|
637
|
+
} else {
|
|
638
|
+
if (filePathOrBase64.startsWith('http'))
|
|
639
|
+
throw new Error(
|
|
640
|
+
'VAD remote file is not supported, please download it first',
|
|
641
|
+
)
|
|
642
|
+
path = filePathOrBase64
|
|
643
|
+
}
|
|
644
|
+
if (path.startsWith('file://')) path = path.slice(7)
|
|
645
|
+
|
|
646
|
+
// Check if this is base64 encoded audio data
|
|
647
|
+
if (path.startsWith('data:audio/')) {
|
|
648
|
+
// This is base64 encoded audio data, use the raw data method
|
|
649
|
+
return RNWhisper.vadDetectSpeech(this.id, path, options)
|
|
650
|
+
} else {
|
|
651
|
+
// This is a file path, use the file method
|
|
652
|
+
return RNWhisper.vadDetectSpeechFile(this.id, path, options)
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* Detect speech segments in raw audio data (base64 encoded float32 PCM data)
|
|
658
|
+
*/
|
|
659
|
+
async detectSpeechData(
|
|
660
|
+
audioData: string,
|
|
661
|
+
options: VadOptions = {}
|
|
662
|
+
): Promise<VadSegment[]> {
|
|
663
|
+
return RNWhisper.vadDetectSpeech(this.id, audioData, options)
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
async release(): Promise<void> {
|
|
667
|
+
return RNWhisper.releaseVadContext(this.id)
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* Initialize a VAD context for voice activity detection
|
|
673
|
+
* @param options VAD context options
|
|
674
|
+
* @returns Promise resolving to WhisperVadContext instance
|
|
675
|
+
*/
|
|
676
|
+
export async function initWhisperVad({
|
|
677
|
+
filePath,
|
|
678
|
+
isBundleAsset,
|
|
679
|
+
useGpu = true,
|
|
680
|
+
nThreads,
|
|
681
|
+
}: VadContextOptions): Promise<WhisperVadContext> {
|
|
682
|
+
let path = ''
|
|
683
|
+
if (typeof filePath === 'number') {
|
|
684
|
+
try {
|
|
685
|
+
const source = Image.resolveAssetSource(filePath)
|
|
686
|
+
if (source) {
|
|
687
|
+
path = source.uri
|
|
688
|
+
}
|
|
689
|
+
} catch (e) {
|
|
690
|
+
throw new Error(`Invalid asset: ${filePath}`)
|
|
691
|
+
}
|
|
692
|
+
} else {
|
|
693
|
+
if (!isBundleAsset && filePath.startsWith('http'))
|
|
694
|
+
throw new Error(
|
|
695
|
+
'VAD remote file is not supported, please download it first',
|
|
696
|
+
)
|
|
697
|
+
path = filePath
|
|
698
|
+
}
|
|
699
|
+
if (path.startsWith('file://')) path = path.slice(7)
|
|
700
|
+
const { contextId, gpu, reasonNoGPU } = await RNWhisper.initVadContext({
|
|
701
|
+
filePath: path,
|
|
702
|
+
isBundleAsset: !!isBundleAsset,
|
|
703
|
+
useGpu,
|
|
704
|
+
nThreads,
|
|
705
|
+
})
|
|
706
|
+
return new WhisperVadContext({ contextId, gpu, reasonNoGPU })
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* Release all VAD contexts and free their memory
|
|
711
|
+
* @returns Promise resolving when all contexts are released
|
|
712
|
+
*/
|
|
713
|
+
export async function releaseAllWhisperVad(): Promise<void> {
|
|
714
|
+
return RNWhisper.releaseAllVadContexts()
|
|
715
|
+
}
|
package/src/version.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"1.7.
|
|
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,14 @@ 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
|
|
36
42
|
|
|
37
43
|
s.requires_arc = true
|
|
38
44
|
|
|
@@ -42,25 +48,12 @@ Pod::Spec.new do |s|
|
|
|
42
48
|
s.pod_target_xcconfig = {
|
|
43
49
|
"OTHER_LDFLAGS" => base_ld_flags,
|
|
44
50
|
"OTHER_CFLAGS" => base_optimizer_flags,
|
|
45
|
-
"OTHER_CPLUSPLUSFLAGS" => base_optimizer_flags
|
|
51
|
+
"OTHER_CPLUSPLUSFLAGS" => base_optimizer_flags + " -std=c++17"
|
|
46
52
|
}
|
|
47
53
|
|
|
48
54
|
# Don't install the dependencies when we run `pod install` in the old architecture.
|
|
49
55
|
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
|
|
50
|
-
s
|
|
51
|
-
new_arch_cpp_flags = "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1"
|
|
52
|
-
s.pod_target_xcconfig = {
|
|
53
|
-
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
|
|
54
|
-
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
|
|
55
|
-
"OTHER_LDFLAGS" => base_ld_flags,
|
|
56
|
-
"OTHER_CFLAGS" => base_optimizer_flags,
|
|
57
|
-
"OTHER_CPLUSPLUSFLAGS" => new_arch_cpp_flags + " " + base_optimizer_flags
|
|
58
|
-
}
|
|
59
|
-
s.dependency "React-Codegen"
|
|
60
|
-
s.dependency "RCT-Folly"
|
|
61
|
-
s.dependency "RCTRequired"
|
|
62
|
-
s.dependency "RCTTypeSafety"
|
|
63
|
-
s.dependency "ReactCommon/turbomodule/core"
|
|
56
|
+
install_modules_dependencies(s)
|
|
64
57
|
end
|
|
65
58
|
|
|
66
59
|
s.subspec "no-require-arc" do |ss|
|
package/cpp/README.md
DELETED