whisper.rn 0.4.0-rc.9 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/README.md +5 -1
  2. package/android/build.gradle +12 -3
  3. package/android/src/main/CMakeLists.txt +43 -13
  4. package/android/src/main/java/com/rnwhisper/WhisperContext.java +33 -35
  5. package/android/src/main/jni.cpp +9 -0
  6. package/android/src/main/jniLibs/arm64-v8a/librnwhisper.so +0 -0
  7. package/android/src/main/jniLibs/arm64-v8a/librnwhisper_v8fp16_va_2.so +0 -0
  8. package/android/src/main/jniLibs/armeabi-v7a/librnwhisper.so +0 -0
  9. package/android/src/main/jniLibs/armeabi-v7a/librnwhisper_vfpv4.so +0 -0
  10. package/android/src/main/jniLibs/x86_64/librnwhisper.so +0 -0
  11. package/android/src/main/jniLibs/x86_64/librnwhisper_x86_64.so +0 -0
  12. package/cpp/coreml/whisper-compat.h +10 -0
  13. package/cpp/coreml/whisper-compat.m +35 -0
  14. package/cpp/coreml/whisper-decoder-impl.h +27 -15
  15. package/cpp/coreml/whisper-decoder-impl.m +36 -10
  16. package/cpp/coreml/whisper-encoder-impl.h +21 -9
  17. package/cpp/coreml/whisper-encoder-impl.m +29 -3
  18. package/cpp/ggml-alloc.c +39 -37
  19. package/cpp/ggml-alloc.h +1 -1
  20. package/cpp/ggml-backend-impl.h +55 -27
  21. package/cpp/ggml-backend-reg.cpp +591 -0
  22. package/cpp/ggml-backend.cpp +336 -955
  23. package/cpp/ggml-backend.h +70 -42
  24. package/cpp/ggml-common.h +57 -49
  25. package/cpp/ggml-cpp.h +39 -0
  26. package/cpp/ggml-cpu/amx/amx.cpp +221 -0
  27. package/cpp/ggml-cpu/amx/amx.h +8 -0
  28. package/cpp/ggml-cpu/amx/common.h +91 -0
  29. package/cpp/ggml-cpu/amx/mmq.cpp +2511 -0
  30. package/cpp/ggml-cpu/amx/mmq.h +10 -0
  31. package/cpp/ggml-cpu/arch/arm/cpu-feats.cpp +94 -0
  32. package/cpp/ggml-cpu/arch/arm/quants.c +4113 -0
  33. package/cpp/ggml-cpu/arch/arm/repack.cpp +2162 -0
  34. package/cpp/ggml-cpu/arch/x86/cpu-feats.cpp +327 -0
  35. package/cpp/ggml-cpu/arch/x86/quants.c +4310 -0
  36. package/cpp/ggml-cpu/arch/x86/repack.cpp +3284 -0
  37. package/cpp/ggml-cpu/arch-fallback.h +184 -0
  38. package/cpp/ggml-cpu/binary-ops.cpp +158 -0
  39. package/cpp/ggml-cpu/binary-ops.h +16 -0
  40. package/cpp/ggml-cpu/common.h +72 -0
  41. package/cpp/ggml-cpu/ggml-cpu-impl.h +511 -0
  42. package/cpp/ggml-cpu/ggml-cpu.c +3473 -0
  43. package/cpp/ggml-cpu/ggml-cpu.cpp +671 -0
  44. package/cpp/ggml-cpu/ops.cpp +9085 -0
  45. package/cpp/ggml-cpu/ops.h +111 -0
  46. package/cpp/ggml-cpu/quants.c +1157 -0
  47. package/cpp/ggml-cpu/quants.h +89 -0
  48. package/cpp/ggml-cpu/repack.cpp +1570 -0
  49. package/cpp/ggml-cpu/repack.h +98 -0
  50. package/cpp/ggml-cpu/simd-mappings.h +1006 -0
  51. package/cpp/ggml-cpu/traits.cpp +36 -0
  52. package/cpp/ggml-cpu/traits.h +38 -0
  53. package/cpp/ggml-cpu/unary-ops.cpp +186 -0
  54. package/cpp/ggml-cpu/unary-ops.h +28 -0
  55. package/cpp/ggml-cpu/vec.cpp +321 -0
  56. package/cpp/ggml-cpu/vec.h +973 -0
  57. package/cpp/ggml-cpu.h +143 -0
  58. package/cpp/ggml-impl.h +417 -23
  59. package/cpp/ggml-metal-impl.h +622 -0
  60. package/cpp/ggml-metal.h +9 -9
  61. package/cpp/ggml-metal.m +3451 -1344
  62. package/cpp/ggml-opt.cpp +1037 -0
  63. package/cpp/ggml-opt.h +237 -0
  64. package/cpp/ggml-quants.c +296 -10818
  65. package/cpp/ggml-quants.h +78 -125
  66. package/cpp/ggml-threading.cpp +12 -0
  67. package/cpp/ggml-threading.h +14 -0
  68. package/cpp/ggml-whisper-sim.metallib +0 -0
  69. package/cpp/ggml-whisper.metallib +0 -0
  70. package/cpp/ggml.c +4633 -21450
  71. package/cpp/ggml.h +320 -661
  72. package/cpp/gguf.cpp +1347 -0
  73. package/cpp/gguf.h +202 -0
  74. package/cpp/rn-whisper.cpp +4 -11
  75. package/cpp/whisper-arch.h +197 -0
  76. package/cpp/whisper.cpp +2022 -495
  77. package/cpp/whisper.h +75 -18
  78. package/ios/CMakeLists.txt +95 -0
  79. package/ios/RNWhisper.h +5 -0
  80. package/ios/RNWhisperAudioUtils.m +4 -0
  81. package/ios/RNWhisperContext.h +5 -0
  82. package/ios/RNWhisperContext.mm +4 -2
  83. package/ios/rnwhisper.xcframework/Info.plist +74 -0
  84. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-alloc.h +76 -0
  85. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-backend-impl.h +255 -0
  86. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-backend.h +354 -0
  87. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-common.h +1861 -0
  88. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-cpp.h +39 -0
  89. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-cpu.h +143 -0
  90. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-impl.h +603 -0
  91. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-metal-impl.h +622 -0
  92. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-metal.h +66 -0
  93. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-opt.h +237 -0
  94. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-quants.h +100 -0
  95. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-threading.h +14 -0
  96. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml.h +2221 -0
  97. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/gguf.h +202 -0
  98. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/rn-audioutils.h +14 -0
  99. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/rn-whisper-log.h +11 -0
  100. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/rn-whisper.h +52 -0
  101. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/whisper-arch.h +197 -0
  102. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/whisper.h +739 -0
  103. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Info.plist +0 -0
  104. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/ggml-whisper.metallib +0 -0
  105. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/rnwhisper +0 -0
  106. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-alloc.h +76 -0
  107. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend-impl.h +255 -0
  108. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend.h +354 -0
  109. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-common.h +1861 -0
  110. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-cpp.h +39 -0
  111. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-cpu.h +143 -0
  112. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-impl.h +603 -0
  113. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-metal-impl.h +622 -0
  114. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-metal.h +66 -0
  115. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-opt.h +237 -0
  116. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-quants.h +100 -0
  117. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-threading.h +14 -0
  118. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml.h +2221 -0
  119. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/gguf.h +202 -0
  120. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/rn-audioutils.h +14 -0
  121. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/rn-whisper-log.h +11 -0
  122. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/rn-whisper.h +52 -0
  123. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/whisper-arch.h +197 -0
  124. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/whisper.h +739 -0
  125. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Info.plist +0 -0
  126. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/_CodeSignature/CodeResources +101 -0
  127. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/ggml-whisper-sim.metallib +0 -0
  128. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/rnwhisper +0 -0
  129. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-alloc.h +76 -0
  130. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-backend-impl.h +255 -0
  131. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-backend.h +354 -0
  132. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-common.h +1861 -0
  133. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-cpp.h +39 -0
  134. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-cpu.h +143 -0
  135. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-impl.h +603 -0
  136. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-metal-impl.h +622 -0
  137. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-metal.h +66 -0
  138. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-opt.h +237 -0
  139. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-quants.h +100 -0
  140. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-threading.h +14 -0
  141. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml.h +2221 -0
  142. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/gguf.h +202 -0
  143. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/rn-audioutils.h +14 -0
  144. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/rn-whisper-log.h +11 -0
  145. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/rn-whisper.h +52 -0
  146. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/whisper-arch.h +197 -0
  147. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/whisper.h +739 -0
  148. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Info.plist +0 -0
  149. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/ggml-whisper.metallib +0 -0
  150. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/rnwhisper +0 -0
  151. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-alloc.h +76 -0
  152. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend-impl.h +255 -0
  153. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend.h +354 -0
  154. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-common.h +1861 -0
  155. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-cpp.h +39 -0
  156. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-cpu.h +143 -0
  157. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-impl.h +603 -0
  158. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-metal-impl.h +622 -0
  159. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-metal.h +66 -0
  160. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-opt.h +237 -0
  161. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-quants.h +100 -0
  162. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-threading.h +14 -0
  163. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml.h +2221 -0
  164. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/gguf.h +202 -0
  165. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/rn-audioutils.h +14 -0
  166. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/rn-whisper-log.h +11 -0
  167. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/rn-whisper.h +52 -0
  168. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/whisper-arch.h +197 -0
  169. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/whisper.h +739 -0
  170. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Info.plist +0 -0
  171. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/_CodeSignature/CodeResources +101 -0
  172. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/ggml-whisper-sim.metallib +0 -0
  173. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/rnwhisper +0 -0
  174. package/jest/mock.js +5 -0
  175. package/lib/commonjs/version.json +1 -1
  176. package/lib/module/version.json +1 -1
  177. package/package.json +10 -6
  178. package/src/version.json +1 -1
  179. package/whisper-rn.podspec +11 -18
  180. package/cpp/README.md +0 -4
  181. package/cpp/ggml-aarch64.c +0 -3209
  182. package/cpp/ggml-aarch64.h +0 -39
  183. package/cpp/ggml-cpu-impl.h +0 -614
package/README.md CHANGED
@@ -25,6 +25,8 @@ npm install whisper.rn
25
25
 
26
26
  Please re-run `npx pod-install` again.
27
27
 
28
+ By default, `whisper.rn` will use pre-built `rnwhisper.xcframework` for iOS. If you want to build from source, please set `RNWHISPER_BUILD_FROM_SOURCE` to `1` in your Podfile.
29
+
28
30
  If you want to use `medium` or `large` model, the [Extended Virtual Addressing](https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_kernel_extended-virtual-addressing) capability is recommended to enable on iOS project.
29
31
 
30
32
  #### Android
@@ -36,7 +38,9 @@ Add proguard rule if it's enabled in project (android/app/proguard-rules.pro):
36
38
  -keep class com.rnwhisper.** { *; }
37
39
  ```
38
40
 
39
- For build, it's recommended to use `ndkVersion = "24.0.8215888"` (or above) in your root project build configuration for Apple Silicon Macs. Otherwise please follow this trobleshooting [issue](./TROUBLESHOOTING.md#android-got-build-error-unknown-host-cpu-architecture-arm64-on-apple-silicon-macs).
41
+ By default, `whisper.rn` will use pre-built libraries for Android. If you want to build from source, please set `rnwhisperBuildFromSource` to `true` in `android/gradle.properties`.
42
+
43
+ For build from source, it's recommended to use `ndkVersion = "24.0.8215888"` (or above) in your root project build configuration for Apple Silicon Macs. Otherwise please follow this trobleshooting [issue](./TROUBLESHOOTING.md#android-got-build-error-unknown-host-cpu-architecture-arm64-on-apple-silicon-macs).
40
44
 
41
45
  #### Expo
42
46
 
@@ -53,9 +53,18 @@ android {
53
53
  }
54
54
  }
55
55
  }
56
- externalNativeBuild {
57
- cmake {
58
- path = file('src/main/CMakeLists.txt')
56
+ def rnwhisperBuildFromSource = project.properties["rnwhisperBuildFromSource"]
57
+ if (rnwhisperBuildFromSource == "true") {
58
+ externalNativeBuild {
59
+ cmake {
60
+ path = file('src/main/CMakeLists.txt')
61
+ }
62
+ }
63
+ // Exclude jniLibs
64
+ sourceSets {
65
+ main {
66
+ jniLibs.srcDirs = []
67
+ }
59
68
  }
60
69
  }
61
70
  buildTypes {
@@ -2,16 +2,35 @@ cmake_minimum_required(VERSION 3.10)
2
2
 
3
3
  project(whisper.rn)
4
4
 
5
- set(CMAKE_CXX_STANDARD 11)
5
+ set(CMAKE_CXX_STANDARD 17)
6
6
  set(RNWHISPER_LIB_DIR ${CMAKE_SOURCE_DIR}/../../../cpp)
7
7
 
8
+ include_directories(
9
+ ${RNWHISPER_LIB_DIR}
10
+ ${RNWHISPER_LIB_DIR}/ggml-cpu
11
+ )
12
+
8
13
  set(
9
14
  SOURCE_FILES
10
15
  ${RNWHISPER_LIB_DIR}/ggml.c
11
16
  ${RNWHISPER_LIB_DIR}/ggml-alloc.c
12
17
  ${RNWHISPER_LIB_DIR}/ggml-backend.cpp
18
+ ${RNWHISPER_LIB_DIR}/ggml-backend-reg.cpp
19
+ ${RNWHISPER_LIB_DIR}/ggml-cpu/amx/amx.cpp
20
+ ${RNWHISPER_LIB_DIR}/ggml-cpu/amx/mmq.cpp
21
+ ${RNWHISPER_LIB_DIR}/ggml-cpu/ggml-cpu.c
22
+ ${RNWHISPER_LIB_DIR}/ggml-cpu/ggml-cpu.cpp
23
+ ${RNWHISPER_LIB_DIR}/ggml-cpu/quants.c
24
+ ${RNWHISPER_LIB_DIR}/ggml-cpu/traits.cpp
25
+ ${RNWHISPER_LIB_DIR}/ggml-cpu/repack.cpp
26
+ ${RNWHISPER_LIB_DIR}/ggml-cpu/unary-ops.cpp
27
+ ${RNWHISPER_LIB_DIR}/ggml-cpu/binary-ops.cpp
28
+ ${RNWHISPER_LIB_DIR}/ggml-cpu/vec.cpp
29
+ ${RNWHISPER_LIB_DIR}/ggml-cpu/ops.cpp
30
+ ${RNWHISPER_LIB_DIR}/ggml-opt.cpp
31
+ ${RNWHISPER_LIB_DIR}/ggml-threading.cpp
13
32
  ${RNWHISPER_LIB_DIR}/ggml-quants.c
14
- ${RNWHISPER_LIB_DIR}/ggml-aarch64.c
33
+ ${RNWHISPER_LIB_DIR}/gguf.cpp
15
34
  ${RNWHISPER_LIB_DIR}/whisper.cpp
16
35
  ${RNWHISPER_LIB_DIR}/rn-audioutils.cpp
17
36
  ${RNWHISPER_LIB_DIR}/rn-whisper.cpp
@@ -20,45 +39,56 @@ set(
20
39
 
21
40
  find_library(LOG_LIB log)
22
41
 
23
- function(build_library target_name)
42
+ function(build_library target_name arch cpu_flags)
43
+ if (NOT ${arch} STREQUAL "generic")
44
+ set(SOURCE_FILES_ARCH
45
+ ${RNWHISPER_LIB_DIR}/ggml-cpu/arch/${arch}/quants.c
46
+ ${RNWHISPER_LIB_DIR}/ggml-cpu/arch/${arch}/repack.cpp
47
+ )
48
+ endif ()
49
+
24
50
  add_library(
25
51
  ${target_name}
26
52
  SHARED
27
53
  ${SOURCE_FILES}
54
+ ${SOURCE_FILES_ARCH}
28
55
  )
29
56
 
30
57
  target_link_libraries(${target_name} ${LOG_LIB} android)
31
58
 
32
- if (${target_name} STREQUAL "whisper_v8fp16_va")
33
- target_compile_options(${target_name} PRIVATE -march=armv8.2-a+fp16)
34
- elseif (${target_name} STREQUAL "whisper_vfpv4")
35
- target_compile_options(${target_name} PRIVATE -mfpu=neon-vfpv4)
59
+ if (${arch} STREQUAL "generic")
60
+ target_compile_options(${target_name} PRIVATE -DWSP_GGML_CPU_GENERIC)
36
61
  endif ()
37
62
 
63
+ target_compile_options(${target_name} PRIVATE -DWSP_GGML_USE_CPU -DWSP_GGML_USE_CPU_REPACK -pthread ${cpu_flags})
64
+
38
65
  if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
39
66
  target_compile_options(${target_name} PRIVATE -DRNWHISPER_ANDROID_ENABLE_LOGGING)
40
67
  endif ()
41
68
 
42
69
  # NOTE: If you want to debug the native code, you can uncomment if and endif
70
+ # Note that it will be extremely slow
43
71
  # if (NOT ${CMAKE_BUILD_TYPE} STREQUAL "Debug")
44
-
45
- target_compile_options(${target_name} PRIVATE -O3 -DNDEBUG -pthread)
72
+ target_compile_options(${target_name} PRIVATE -O3 -DNDEBUG)
46
73
  target_compile_options(${target_name} PRIVATE -fvisibility=hidden -fvisibility-inlines-hidden)
47
74
  target_compile_options(${target_name} PRIVATE -ffunction-sections -fdata-sections)
48
75
 
49
76
  target_link_options(${target_name} PRIVATE -Wl,--gc-sections)
50
77
  target_link_options(${target_name} PRIVATE -Wl,--exclude-libs,ALL)
51
78
  target_link_options(${target_name} PRIVATE -flto)
52
-
53
79
  # endif ()
54
80
  endfunction()
55
81
 
56
- build_library("whisper") # Default target
82
+ build_library("rnwhisper" "generic" "")
57
83
 
58
84
  if (${ANDROID_ABI} STREQUAL "arm64-v8a")
59
- build_library("whisper_v8fp16_va")
85
+ build_library("rnwhisper_v8fp16_va_2" "arm" "-march=armv8.2-a+fp16")
60
86
  elseif (${ANDROID_ABI} STREQUAL "armeabi-v7a")
61
- build_library("whisper_vfpv4")
87
+ build_library("rnwhisper_vfpv4" "arm" "-mfpu=neon-vfpv4")
88
+ elseif (${ANDROID_ABI} STREQUAL "x86_64")
89
+ # x86_64 target
90
+ build_library("rnwhisper_x86_64" "x86" "-march=x86-64" "-mtune=intel" "-msse4.2" "-mpopcnt")
62
91
  endif ()
63
92
 
93
+
64
94
  include_directories(${RNWHISPER_LIB_DIR})
@@ -27,6 +27,8 @@ import java.io.PushbackInputStream;
27
27
  public class WhisperContext {
28
28
  public static final String NAME = "RNWhisperContext";
29
29
 
30
+ private static String loadedLibrary = "";
31
+
30
32
  private static final int SAMPLE_RATE = 16000;
31
33
  private static final int CHANNEL_CONFIG = AudioFormat.CHANNEL_IN_MONO;
32
34
  private static final int AUDIO_FORMAT = AudioFormat.ENCODING_PCM_16BIT;
@@ -433,64 +435,60 @@ public class WhisperContext {
433
435
 
434
436
  static {
435
437
  Log.d(NAME, "Primary ABI: " + Build.SUPPORTED_ABIS[0]);
436
- boolean loadVfpv4 = false;
437
- boolean loadV8fp16 = false;
438
- if (isArmeabiV7a()) {
439
- // armeabi-v7a needs runtime detection support
440
- String cpuInfo = cpuInfo();
441
- if (cpuInfo != null) {
442
- Log.d(NAME, "CPU info: " + cpuInfo);
443
- if (cpuInfo.contains("vfpv4")) {
444
- Log.d(NAME, "CPU supports vfpv4");
445
- loadVfpv4 = true;
446
- }
447
- }
448
- } else if (isArmeabiV8a()) {
449
- // ARMv8.2a needs runtime detection support
450
- String cpuInfo = cpuInfo();
451
- if (cpuInfo != null) {
452
- Log.d(NAME, "CPU info: " + cpuInfo);
453
- if (cpuInfo.contains("fphp")) {
454
- Log.d(NAME, "CPU supports fp16 arithmetic");
455
- loadV8fp16 = true;
456
- }
457
- }
458
- }
459
438
 
460
- if (loadVfpv4) {
461
- Log.d(NAME, "Loading libwhisper_vfpv4.so");
462
- System.loadLibrary("whisper_vfpv4");
463
- } else if (loadV8fp16) {
464
- Log.d(NAME, "Loading libwhisper_v8fp16_va.so");
465
- System.loadLibrary("whisper_v8fp16_va");
439
+ String cpuFeatures = WhisperContext.getCpuFeatures();
440
+ Log.d(NAME, "CPU features: " + cpuFeatures);
441
+ boolean hasFp16 = cpuFeatures.contains("fp16") || cpuFeatures.contains("fphp");
442
+ Log.d(NAME, "- hasFp16: " + hasFp16);
443
+
444
+ if (WhisperContext.isArm64V8a()) {
445
+ if (hasFp16) {
446
+ Log.d(NAME, "Loading librnwhisper_v8fp16_va_2.so");
447
+ System.loadLibrary("rnwhisper_v8fp16_va_2");
448
+ loadedLibrary = "rnwhisper_v8fp16_va_2";
449
+ }
450
+ } else if (WhisperContext.isArmeabiV7a()) {
451
+ Log.d(NAME, "Loading librnwhisper_vfpv4.so");
452
+ System.loadLibrary("rnwhisper_vfpv4");
453
+ loadedLibrary = "rnwhisper_vfpv4";
454
+ } else if (WhisperContext.isX86_64()) {
455
+ Log.d(NAME, "Loading librnwhisper_x86_64.so");
456
+ System.loadLibrary("rnwhisper_x86_64");
457
+ loadedLibrary = "rnwhisper_x86_64";
466
458
  } else {
467
- Log.d(NAME, "Loading libwhisper.so");
468
- System.loadLibrary("whisper");
459
+ Log.d(NAME, "ARM32 is not supported, skipping loading library");
469
460
  }
470
461
  }
471
462
 
463
+ private static boolean isArm64V8a() {
464
+ return Build.SUPPORTED_ABIS[0].equals("arm64-v8a");
465
+ }
466
+
472
467
  private static boolean isArmeabiV7a() {
473
468
  return Build.SUPPORTED_ABIS[0].equals("armeabi-v7a");
474
469
  }
475
470
 
476
- private static boolean isArmeabiV8a() {
477
- return Build.SUPPORTED_ABIS[0].equals("arm64-v8a");
471
+ private static boolean isX86_64() {
472
+ return Build.SUPPORTED_ABIS[0].equals("x86_64");
478
473
  }
479
474
 
480
- private static String cpuInfo() {
475
+ private static String getCpuFeatures() {
481
476
  File file = new File("/proc/cpuinfo");
482
477
  StringBuilder stringBuilder = new StringBuilder();
483
478
  try {
484
479
  BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
485
480
  String line;
486
481
  while ((line = bufferedReader.readLine()) != null) {
482
+ if (line.startsWith("Features")) {
487
483
  stringBuilder.append(line);
484
+ break;
485
+ }
488
486
  }
489
487
  bufferedReader.close();
490
488
  return stringBuilder.toString();
491
489
  } catch (IOException e) {
492
490
  Log.w(NAME, "Couldn't read /proc/cpuinfo", e);
493
- return null;
491
+ return "";
494
492
  }
495
493
  }
496
494
 
@@ -155,7 +155,10 @@ Java_com_rnwhisper_WhisperContext_initContext(
155
155
  JNIEnv *env, jobject thiz, jstring model_path_str) {
156
156
  UNUSED(thiz);
157
157
  struct whisper_context_params cparams;
158
+
159
+ // TODO: Expose dtw_token_timestamps and dtw_aheads_preset
158
160
  cparams.dtw_token_timestamps = false;
161
+ // cparams.dtw_aheads_preset = WHISPER_AHEADS_BASE;
159
162
 
160
163
  struct whisper_context *context = nullptr;
161
164
  const char *model_path_chars = env->GetStringUTFChars(model_path_str, nullptr);
@@ -173,7 +176,10 @@ Java_com_rnwhisper_WhisperContext_initContextWithAsset(
173
176
  ) {
174
177
  UNUSED(thiz);
175
178
  struct whisper_context_params cparams;
179
+
180
+ // TODO: Expose dtw_token_timestamps and dtw_aheads_preset
176
181
  cparams.dtw_token_timestamps = false;
182
+ // cparams.dtw_aheads_preset = WHISPER_AHEADS_BASE;
177
183
 
178
184
  struct whisper_context *context = nullptr;
179
185
  const char *model_path_chars = env->GetStringUTFChars(model_path_str, nullptr);
@@ -190,7 +196,10 @@ Java_com_rnwhisper_WhisperContext_initContextWithInputStream(
190
196
  ) {
191
197
  UNUSED(thiz);
192
198
  struct whisper_context_params cparams;
199
+
200
+ // TODO: Expose dtw_token_timestamps and dtw_aheads_preset
193
201
  cparams.dtw_token_timestamps = false;
202
+ // cparams.dtw_aheads_preset = WHISPER_AHEADS_BASE;
194
203
 
195
204
  struct whisper_context *context = nullptr;
196
205
  context = whisper_init_from_input_stream(env, input_stream, cparams);
@@ -0,0 +1,10 @@
1
+ #import <CoreML/CoreML.h>
2
+
3
+ @interface MLModel (Compat)
4
+ - (void) predictionFromFeatures:(id<MLFeatureProvider>) input
5
+ completionHandler:(void (^)(id<MLFeatureProvider> output, NSError * error)) completionHandler;
6
+
7
+ - (void) predictionFromFeatures:(id<MLFeatureProvider>) input
8
+ options:(MLPredictionOptions *) options
9
+ completionHandler:(void (^)(id<MLFeatureProvider> output, NSError * error)) completionHandler;
10
+ @end
@@ -0,0 +1,35 @@
1
+ #import "whisper-compat.h"
2
+ #import <Foundation/Foundation.h>
3
+
4
+ @implementation MLModel (Compat)
5
+
6
+ #if !defined(MAC_OS_X_VERSION_14_00) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_14_00
7
+
8
+ - (void) predictionFromFeatures:(id<MLFeatureProvider>) input
9
+ completionHandler:(void (^)(id<MLFeatureProvider> output, NSError * error)) completionHandler {
10
+ [NSOperationQueue.new addOperationWithBlock:^{
11
+ NSError *error = nil;
12
+ id<MLFeatureProvider> prediction = [self predictionFromFeatures:input error:&error];
13
+
14
+ [NSOperationQueue.mainQueue addOperationWithBlock:^{
15
+ completionHandler(prediction, error);
16
+ }];
17
+ }];
18
+ }
19
+
20
+ - (void) predictionFromFeatures:(id<MLFeatureProvider>) input
21
+ options:(MLPredictionOptions *) options
22
+ completionHandler:(void (^)(id<MLFeatureProvider> output, NSError * error)) completionHandler {
23
+ [NSOperationQueue.new addOperationWithBlock:^{
24
+ NSError *error = nil;
25
+ id<MLFeatureProvider> prediction = [self predictionFromFeatures:input options:options error:&error];
26
+
27
+ [NSOperationQueue.mainQueue addOperationWithBlock:^{
28
+ completionHandler(prediction, error);
29
+ }];
30
+ }];
31
+ }
32
+
33
+ #endif
34
+
35
+ @end
@@ -11,36 +11,33 @@
11
11
 
12
12
  NS_ASSUME_NONNULL_BEGIN
13
13
 
14
-
15
14
  /// Model Prediction Input Type
16
- API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0)) __attribute__((visibility("hidden")))
15
+ API_AVAILABLE(macos(10.15), ios(13.0), watchos(6.0), tvos(13.0)) __attribute__((visibility("hidden")))
17
16
  @interface whisper_decoder_implInput : NSObject<MLFeatureProvider>
18
17
 
19
- /// token_data as 1 by 1 matrix of 32-bit integers
18
+ /// token_data as 1 by 1 matrix of floats
20
19
  @property (readwrite, nonatomic, strong) MLMultiArray * token_data;
21
20
 
22
- /// audio_data as 1 × 384 × 1 × 1500 4-dimensional array of floats
21
+ /// audio_data as 1 × 1500 × 384 3-dimensional array of floats
23
22
  @property (readwrite, nonatomic, strong) MLMultiArray * audio_data;
24
23
  - (instancetype)init NS_UNAVAILABLE;
25
24
  - (instancetype)initWithToken_data:(MLMultiArray *)token_data audio_data:(MLMultiArray *)audio_data NS_DESIGNATED_INITIALIZER;
26
25
 
27
26
  @end
28
27
 
29
-
30
28
  /// Model Prediction Output Type
31
- API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0)) __attribute__((visibility("hidden")))
29
+ API_AVAILABLE(macos(10.15), ios(13.0), watchos(6.0), tvos(13.0)) __attribute__((visibility("hidden")))
32
30
  @interface whisper_decoder_implOutput : NSObject<MLFeatureProvider>
33
31
 
34
- /// var_1346 as multidimensional array of floats
35
- @property (readwrite, nonatomic, strong) MLMultiArray * var_1346;
32
+ /// cast_76 as multidimensional array of floats
33
+ @property (readwrite, nonatomic, strong) MLMultiArray * cast_76;
36
34
  - (instancetype)init NS_UNAVAILABLE;
37
- - (instancetype)initWithVar_1346:(MLMultiArray *)var_1346 NS_DESIGNATED_INITIALIZER;
35
+ - (instancetype)initWithCast_76:(MLMultiArray *)cast_76 NS_DESIGNATED_INITIALIZER;
38
36
 
39
37
  @end
40
38
 
41
-
42
39
  /// Class for model loading and prediction
43
- API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0)) __attribute__((visibility("hidden")))
40
+ API_AVAILABLE(macos(10.15), ios(13.0), watchos(6.0), tvos(13.0)) __attribute__((visibility("hidden")))
44
41
  @interface whisper_decoder_impl : NSObject
45
42
  @property (readonly, nonatomic, nullable) MLModel * model;
46
43
 
@@ -94,7 +91,7 @@ API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0)) __attribute__((v
94
91
  @param configuration The model configuration
95
92
  @param handler When the model load completes successfully or unsuccessfully, the completion handler is invoked with a valid whisper_decoder_impl instance or NSError object.
96
93
  */
97
- + (void)loadWithConfiguration:(MLModelConfiguration *)configuration completionHandler:(void (^)(whisper_decoder_impl * _Nullable model, NSError * _Nullable error))handler;
94
+ + (void)loadWithConfiguration:(MLModelConfiguration *)configuration completionHandler:(void (^)(whisper_decoder_impl * _Nullable model, NSError * _Nullable error))handler API_AVAILABLE(macos(11.0), ios(14.0), watchos(7.0), tvos(14.0)) __attribute__((visibility("hidden")));
98
95
 
99
96
  /**
100
97
  Construct whisper_decoder_impl instance asynchronously with URL of .mlmodelc directory and optional configuration.
@@ -105,7 +102,7 @@ API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0)) __attribute__((v
105
102
  @param configuration The model configuration
106
103
  @param handler When the model load completes successfully or unsuccessfully, the completion handler is invoked with a valid whisper_decoder_impl instance or NSError object.
107
104
  */
108
- + (void)loadContentsOfURL:(NSURL *)modelURL configuration:(MLModelConfiguration *)configuration completionHandler:(void (^)(whisper_decoder_impl * _Nullable model, NSError * _Nullable error))handler;
105
+ + (void)loadContentsOfURL:(NSURL *)modelURL configuration:(MLModelConfiguration *)configuration completionHandler:(void (^)(whisper_decoder_impl * _Nullable model, NSError * _Nullable error))handler API_AVAILABLE(macos(11.0), ios(14.0), watchos(7.0), tvos(14.0)) __attribute__((visibility("hidden")));
109
106
 
110
107
  /**
111
108
  Make a prediction using the standard interface
@@ -124,10 +121,25 @@ API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0)) __attribute__((v
124
121
  */
125
122
  - (nullable whisper_decoder_implOutput *)predictionFromFeatures:(whisper_decoder_implInput *)input options:(MLPredictionOptions *)options error:(NSError * _Nullable __autoreleasing * _Nullable)error;
126
123
 
124
+ /**
125
+ Make an asynchronous prediction using the standard interface
126
+ @param input an instance of whisper_decoder_implInput to predict from
127
+ @param completionHandler a block that will be called upon completion of the prediction. error will be nil if no error occurred.
128
+ */
129
+ - (void)predictionFromFeatures:(whisper_decoder_implInput *)input completionHandler:(void (^)(whisper_decoder_implOutput * _Nullable output, NSError * _Nullable error))completionHandler API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0)) __attribute__((visibility("hidden")));
130
+
131
+ /**
132
+ Make an asynchronous prediction using the standard interface
133
+ @param input an instance of whisper_decoder_implInput to predict from
134
+ @param options prediction options
135
+ @param completionHandler a block that will be called upon completion of the prediction. error will be nil if no error occurred.
136
+ */
137
+ - (void)predictionFromFeatures:(whisper_decoder_implInput *)input options:(MLPredictionOptions *)options completionHandler:(void (^)(whisper_decoder_implOutput * _Nullable output, NSError * _Nullable error))completionHandler API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0)) __attribute__((visibility("hidden")));
138
+
127
139
  /**
128
140
  Make a prediction using the convenience interface
129
- @param token_data as 1 by 1 matrix of 32-bit integers:
130
- @param audio_data as 1 × 384 × 1 × 1500 4-dimensional array of floats:
141
+ @param token_data 1 by 1 matrix of floats
142
+ @param audio_data 1 × 1500 × 384 3-dimensional array of floats
131
143
  @param error If an error occurs, upon return contains an NSError object that describes the problem. If you are not interested in possible errors, pass in NULL.
132
144
  @return the prediction as whisper_decoder_implOutput
133
145
  */
@@ -8,6 +8,7 @@
8
8
  #error This file must be compiled with automatic reference counting enabled (-fobjc-arc)
9
9
  #endif
10
10
 
11
+ #import "whisper-compat.h"
11
12
  #import "whisper-decoder-impl.h"
12
13
 
13
14
  @implementation whisper_decoder_implInput
@@ -39,21 +40,21 @@
39
40
 
40
41
  @implementation whisper_decoder_implOutput
41
42
 
42
- - (instancetype)initWithVar_1346:(MLMultiArray *)var_1346 {
43
+ - (instancetype)initWithCast_76:(MLMultiArray *)cast_76 {
43
44
  self = [super init];
44
45
  if (self) {
45
- _var_1346 = var_1346;
46
+ _cast_76 = cast_76;
46
47
  }
47
48
  return self;
48
49
  }
49
50
 
50
51
  - (NSSet<NSString *> *)featureNames {
51
- return [NSSet setWithArray:@[@"var_1346"]];
52
+ return [NSSet setWithArray:@[@"cast_76"]];
52
53
  }
53
54
 
54
55
  - (nullable MLFeatureValue *)featureValueForName:(NSString *)featureName {
55
- if ([featureName isEqualToString:@"var_1346"]) {
56
- return [MLFeatureValue featureValueWithMultiArray:self.var_1346];
56
+ if ([featureName isEqualToString:@"cast_76"]) {
57
+ return [MLFeatureValue featureValueWithMultiArray:self.cast_76];
57
58
  }
58
59
  return nil;
59
60
  }
@@ -80,10 +81,13 @@
80
81
  Such application may want to use `-[MLModel initWithContentsOfURL:configuration:error:]` and `+URLOfModelInThisBundle` to create a MLModel object to pass-in.
81
82
  */
82
83
  - (instancetype)initWithMLModel:(MLModel *)model {
84
+ if (model == nil) {
85
+ return nil;
86
+ }
83
87
  self = [super init];
84
- if (!self) { return nil; }
85
- _model = model;
86
- if (_model == nil) { return nil; }
88
+ if (self != nil) {
89
+ _model = model;
90
+ }
87
91
  return self;
88
92
  }
89
93
 
@@ -177,7 +181,29 @@
177
181
  - (nullable whisper_decoder_implOutput *)predictionFromFeatures:(whisper_decoder_implInput *)input options:(MLPredictionOptions *)options error:(NSError * _Nullable __autoreleasing * _Nullable)error {
178
182
  id<MLFeatureProvider> outFeatures = [self.model predictionFromFeatures:input options:options error:error];
179
183
  if (!outFeatures) { return nil; }
180
- return [[whisper_decoder_implOutput alloc] initWithVar_1346:(MLMultiArray *)[outFeatures featureValueForName:@"var_1346"].multiArrayValue];
184
+ return [[whisper_decoder_implOutput alloc] initWithCast_76:(MLMultiArray *)[outFeatures featureValueForName:@"cast_76"].multiArrayValue];
185
+ }
186
+
187
+ - (void)predictionFromFeatures:(whisper_decoder_implInput *)input completionHandler:(void (^)(whisper_decoder_implOutput * _Nullable output, NSError * _Nullable error))completionHandler {
188
+ [self.model predictionFromFeatures:input completionHandler:^(id<MLFeatureProvider> prediction, NSError *predictionError) {
189
+ if (prediction != nil) {
190
+ whisper_decoder_implOutput *output = [[whisper_decoder_implOutput alloc] initWithCast_76:(MLMultiArray *)[prediction featureValueForName:@"cast_76"].multiArrayValue];
191
+ completionHandler(output, predictionError);
192
+ } else {
193
+ completionHandler(nil, predictionError);
194
+ }
195
+ }];
196
+ }
197
+
198
+ - (void)predictionFromFeatures:(whisper_decoder_implInput *)input options:(MLPredictionOptions *)options completionHandler:(void (^)(whisper_decoder_implOutput * _Nullable output, NSError * _Nullable error))completionHandler {
199
+ [self.model predictionFromFeatures:input options:options completionHandler:^(id<MLFeatureProvider> prediction, NSError *predictionError) {
200
+ if (prediction != nil) {
201
+ whisper_decoder_implOutput *output = [[whisper_decoder_implOutput alloc] initWithCast_76:(MLMultiArray *)[prediction featureValueForName:@"cast_76"].multiArrayValue];
202
+ completionHandler(output, predictionError);
203
+ } else {
204
+ completionHandler(nil, predictionError);
205
+ }
206
+ }];
181
207
  }
182
208
 
183
209
  - (nullable whisper_decoder_implOutput *)predictionFromToken_data:(MLMultiArray *)token_data audio_data:(MLMultiArray *)audio_data error:(NSError * _Nullable __autoreleasing * _Nullable)error {
@@ -192,7 +218,7 @@
192
218
  NSMutableArray<whisper_decoder_implOutput*> *results = [NSMutableArray arrayWithCapacity:(NSUInteger)outBatch.count];
193
219
  for (NSInteger i = 0; i < outBatch.count; i++) {
194
220
  id<MLFeatureProvider> resultProvider = [outBatch featuresAtIndex:i];
195
- whisper_decoder_implOutput * result = [[whisper_decoder_implOutput alloc] initWithVar_1346:(MLMultiArray *)[resultProvider featureValueForName:@"var_1346"].multiArrayValue];
221
+ whisper_decoder_implOutput * result = [[whisper_decoder_implOutput alloc] initWithCast_76:(MLMultiArray *)[resultProvider featureValueForName:@"cast_76"].multiArrayValue];
196
222
  [results addObject:result];
197
223
  }
198
224
  return results;
@@ -11,9 +11,8 @@
11
11
 
12
12
  NS_ASSUME_NONNULL_BEGIN
13
13
 
14
-
15
14
  /// Model Prediction Input Type
16
- API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0)) __attribute__((visibility("hidden")))
15
+ API_AVAILABLE(macos(10.15), ios(13.0), watchos(6.0), tvos(13.0)) __attribute__((visibility("hidden")))
17
16
  @interface whisper_encoder_implInput : NSObject<MLFeatureProvider>
18
17
 
19
18
  /// logmel_data as 1 × 80 × 3000 3-dimensional array of floats
@@ -23,9 +22,8 @@ API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0)) __attribute__((v
23
22
 
24
23
  @end
25
24
 
26
-
27
25
  /// Model Prediction Output Type
28
- API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0)) __attribute__((visibility("hidden")))
26
+ API_AVAILABLE(macos(10.15), ios(13.0), watchos(6.0), tvos(13.0)) __attribute__((visibility("hidden")))
29
27
  @interface whisper_encoder_implOutput : NSObject<MLFeatureProvider>
30
28
 
31
29
  /// output as multidimensional array of floats
@@ -35,9 +33,8 @@ API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0)) __attribute__((v
35
33
 
36
34
  @end
37
35
 
38
-
39
36
  /// Class for model loading and prediction
40
- API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0)) __attribute__((visibility("hidden")))
37
+ API_AVAILABLE(macos(10.15), ios(13.0), watchos(6.0), tvos(13.0)) __attribute__((visibility("hidden")))
41
38
  @interface whisper_encoder_impl : NSObject
42
39
  @property (readonly, nonatomic, nullable) MLModel * model;
43
40
 
@@ -91,7 +88,7 @@ API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0)) __attribute__((v
91
88
  @param configuration The model configuration
92
89
  @param handler When the model load completes successfully or unsuccessfully, the completion handler is invoked with a valid whisper_encoder_impl instance or NSError object.
93
90
  */
94
- + (void)loadWithConfiguration:(MLModelConfiguration *)configuration completionHandler:(void (^)(whisper_encoder_impl * _Nullable model, NSError * _Nullable error))handler;
91
+ + (void)loadWithConfiguration:(MLModelConfiguration *)configuration completionHandler:(void (^)(whisper_encoder_impl * _Nullable model, NSError * _Nullable error))handler API_AVAILABLE(macos(11.0), ios(14.0), watchos(7.0), tvos(14.0)) __attribute__((visibility("hidden")));
95
92
 
96
93
  /**
97
94
  Construct whisper_encoder_impl instance asynchronously with URL of .mlmodelc directory and optional configuration.
@@ -102,7 +99,7 @@ API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0)) __attribute__((v
102
99
  @param configuration The model configuration
103
100
  @param handler When the model load completes successfully or unsuccessfully, the completion handler is invoked with a valid whisper_encoder_impl instance or NSError object.
104
101
  */
105
- + (void)loadContentsOfURL:(NSURL *)modelURL configuration:(MLModelConfiguration *)configuration completionHandler:(void (^)(whisper_encoder_impl * _Nullable model, NSError * _Nullable error))handler;
102
+ + (void)loadContentsOfURL:(NSURL *)modelURL configuration:(MLModelConfiguration *)configuration completionHandler:(void (^)(whisper_encoder_impl * _Nullable model, NSError * _Nullable error))handler API_AVAILABLE(macos(11.0), ios(14.0), watchos(7.0), tvos(14.0)) __attribute__((visibility("hidden")));
106
103
 
107
104
  /**
108
105
  Make a prediction using the standard interface
@@ -121,9 +118,24 @@ API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0)) __attribute__((v
121
118
  */
122
119
  - (nullable whisper_encoder_implOutput *)predictionFromFeatures:(whisper_encoder_implInput *)input options:(MLPredictionOptions *)options error:(NSError * _Nullable __autoreleasing * _Nullable)error;
123
120
 
121
+ /**
122
+ Make an asynchronous prediction using the standard interface
123
+ @param input an instance of whisper_encoder_implInput to predict from
124
+ @param completionHandler a block that will be called upon completion of the prediction. error will be nil if no error occurred.
125
+ */
126
+ - (void)predictionFromFeatures:(whisper_encoder_implInput *)input completionHandler:(void (^)(whisper_encoder_implOutput * _Nullable output, NSError * _Nullable error))completionHandler API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0)) __attribute__((visibility("hidden")));
127
+
128
+ /**
129
+ Make an asynchronous prediction using the standard interface
130
+ @param input an instance of whisper_encoder_implInput to predict from
131
+ @param options prediction options
132
+ @param completionHandler a block that will be called upon completion of the prediction. error will be nil if no error occurred.
133
+ */
134
+ - (void)predictionFromFeatures:(whisper_encoder_implInput *)input options:(MLPredictionOptions *)options completionHandler:(void (^)(whisper_encoder_implOutput * _Nullable output, NSError * _Nullable error))completionHandler API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0)) __attribute__((visibility("hidden")));
135
+
124
136
  /**
125
137
  Make a prediction using the convenience interface
126
- @param logmel_data as 1 × n_mel × 3000 3-dimensional array of floats:
138
+ @param logmel_data 1 × 80 × 3000 3-dimensional array of floats
127
139
  @param error If an error occurs, upon return contains an NSError object that describes the problem. If you are not interested in possible errors, pass in NULL.
128
140
  @return the prediction as whisper_encoder_implOutput
129
141
  */