whisper.rn 0.4.0-rc.3 → 0.4.0-rc.5

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 (59) hide show
  1. package/README.md +6 -6
  2. package/android/build.gradle +4 -0
  3. package/android/src/main/CMakeLists.txt +7 -0
  4. package/android/src/main/java/com/rnwhisper/AudioUtils.java +0 -80
  5. package/android/src/main/java/com/rnwhisper/RNWhisper.java +6 -1
  6. package/android/src/main/java/com/rnwhisper/WhisperContext.java +53 -135
  7. package/android/src/main/jni-utils.h +76 -0
  8. package/android/src/main/jni.cpp +188 -109
  9. package/cpp/README.md +1 -1
  10. package/cpp/coreml/whisper-encoder-impl.h +1 -1
  11. package/cpp/coreml/whisper-encoder.h +4 -0
  12. package/cpp/coreml/whisper-encoder.mm +4 -2
  13. package/cpp/ggml-alloc.c +451 -282
  14. package/cpp/ggml-alloc.h +74 -8
  15. package/cpp/ggml-backend-impl.h +112 -0
  16. package/cpp/ggml-backend.c +1357 -0
  17. package/cpp/ggml-backend.h +181 -0
  18. package/cpp/ggml-impl.h +243 -0
  19. package/cpp/{ggml-metal.metal → ggml-metal-whisper.metal} +1556 -329
  20. package/cpp/ggml-metal.h +28 -1
  21. package/cpp/ggml-metal.m +1128 -308
  22. package/cpp/ggml-quants.c +7382 -0
  23. package/cpp/ggml-quants.h +224 -0
  24. package/cpp/ggml.c +3848 -5245
  25. package/cpp/ggml.h +353 -155
  26. package/cpp/rn-audioutils.cpp +68 -0
  27. package/cpp/rn-audioutils.h +14 -0
  28. package/cpp/rn-whisper-log.h +11 -0
  29. package/cpp/rn-whisper.cpp +141 -59
  30. package/cpp/rn-whisper.h +47 -15
  31. package/cpp/whisper.cpp +1750 -964
  32. package/cpp/whisper.h +97 -15
  33. package/ios/RNWhisper.mm +15 -9
  34. package/ios/RNWhisper.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
  35. package/ios/RNWhisper.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  36. package/ios/RNWhisper.xcodeproj/project.xcworkspace/xcuserdata/jhen.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  37. package/ios/RNWhisper.xcodeproj/xcuserdata/jhen.xcuserdatad/xcschemes/xcschememanagement.plist +19 -0
  38. package/ios/RNWhisperAudioUtils.h +0 -2
  39. package/ios/RNWhisperAudioUtils.m +0 -56
  40. package/ios/RNWhisperContext.h +8 -12
  41. package/ios/RNWhisperContext.mm +132 -138
  42. package/jest/mock.js +1 -1
  43. package/lib/commonjs/NativeRNWhisper.js.map +1 -1
  44. package/lib/commonjs/index.js +28 -9
  45. package/lib/commonjs/index.js.map +1 -1
  46. package/lib/commonjs/version.json +1 -1
  47. package/lib/module/NativeRNWhisper.js.map +1 -1
  48. package/lib/module/index.js +28 -9
  49. package/lib/module/index.js.map +1 -1
  50. package/lib/module/version.json +1 -1
  51. package/lib/typescript/NativeRNWhisper.d.ts +7 -1
  52. package/lib/typescript/NativeRNWhisper.d.ts.map +1 -1
  53. package/lib/typescript/index.d.ts +7 -2
  54. package/lib/typescript/index.d.ts.map +1 -1
  55. package/package.json +6 -5
  56. package/src/NativeRNWhisper.ts +8 -1
  57. package/src/index.ts +29 -17
  58. package/src/version.json +1 -1
  59. package/whisper-rn.podspec +1 -2
package/cpp/ggml-metal.h CHANGED
@@ -19,11 +19,14 @@
19
19
 
20
20
  #pragma once
21
21
 
22
+ #include "ggml.h"
23
+ #include "ggml-backend.h"
24
+
22
25
  #include <stddef.h>
23
26
  #include <stdbool.h>
24
27
 
25
28
  // max memory buffers that can be mapped to the device
26
- #define WSP_GGML_METAL_MAX_BUFFERS 16
29
+ #define WSP_GGML_METAL_MAX_BUFFERS 64
27
30
  #define WSP_GGML_METAL_MAX_COMMAND_BUFFERS 32
28
31
 
29
32
  struct wsp_ggml_tensor;
@@ -33,8 +36,15 @@ struct wsp_ggml_cgraph;
33
36
  extern "C" {
34
37
  #endif
35
38
 
39
+ //
40
+ // internal API
41
+ // temporary exposed to user-code
42
+ //
43
+
36
44
  struct wsp_ggml_metal_context;
37
45
 
46
+ void wsp_ggml_metal_log_set_callback(wsp_ggml_log_callback log_callback, void * user_data);
47
+
38
48
  // number of command buffers to use
39
49
  struct wsp_ggml_metal_context * wsp_ggml_metal_init(int n_cb);
40
50
  void wsp_ggml_metal_free(struct wsp_ggml_metal_context * ctx);
@@ -79,6 +89,23 @@ int * wsp_ggml_metal_get_concur_list(struct wsp_ggml_metal_context * ctx);
79
89
  // creates gf->n_threads command buffers in parallel
80
90
  void wsp_ggml_metal_graph_compute(struct wsp_ggml_metal_context * ctx, struct wsp_ggml_cgraph * gf);
81
91
 
92
+ //
93
+ // backend API
94
+ // user-code should use only these functions
95
+ //
96
+
97
+ WSP_GGML_API wsp_ggml_backend_t wsp_ggml_backend_metal_init(void);
98
+
99
+ WSP_GGML_API bool wsp_ggml_backend_is_metal(wsp_ggml_backend_t backend);
100
+
101
+ WSP_GGML_API void wsp_ggml_backend_metal_set_n_cb(wsp_ggml_backend_t backend, int n_cb);
102
+ WSP_GGML_API wsp_ggml_backend_buffer_type_t wsp_ggml_backend_metal_buffer_type(void);
103
+
104
+ // helper to check if the device supports a specific family
105
+ // ideally, the user code should be doing these checks
106
+ // ref: https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf
107
+ WSP_GGML_API bool wsp_ggml_backend_metal_supports_family(wsp_ggml_backend_t backend, int family);
108
+
82
109
  #ifdef __cplusplus
83
110
  }
84
111
  #endif