@runanywhere/llamacpp 0.17.4 → 0.17.7

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 (72) hide show
  1. package/android/CMakeLists.txt +7 -7
  2. package/android/src/main/jniLibs/arm64-v8a/librac_backend_llamacpp.so +0 -0
  3. package/android/src/main/jniLibs/arm64-v8a/librac_backend_llamacpp_jni.so +0 -0
  4. package/ios/Frameworks/RABackendLLAMACPP.xcframework/Info.plist +5 -5
  5. package/ios/Frameworks/RABackendLLAMACPP.xcframework/ios-arm64/RABackendLLAMACPP.framework/RABackendLLAMACPP +0 -0
  6. package/ios/Frameworks/RABackendLLAMACPP.xcframework/ios-arm64_x86_64-simulator/RABackendLLAMACPP.framework/RABackendLLAMACPP +0 -0
  7. package/package.json +3 -3
  8. package/android/src/main/include/rac/backends/rac_llm_llamacpp.h +0 -218
  9. package/android/src/main/include/rac/backends/rac_stt_onnx.h +0 -99
  10. package/android/src/main/include/rac/backends/rac_stt_whispercpp.h +0 -153
  11. package/android/src/main/include/rac/backends/rac_tts_onnx.h +0 -71
  12. package/android/src/main/include/rac/backends/rac_vad_onnx.h +0 -84
  13. package/android/src/main/include/rac/core/capabilities/rac_lifecycle.h +0 -290
  14. package/android/src/main/include/rac/core/rac_analytics_events.h +0 -610
  15. package/android/src/main/include/rac/core/rac_audio_utils.h +0 -88
  16. package/android/src/main/include/rac/core/rac_component_types.h +0 -160
  17. package/android/src/main/include/rac/core/rac_core.h +0 -331
  18. package/android/src/main/include/rac/core/rac_error.h +0 -469
  19. package/android/src/main/include/rac/core/rac_events.h +0 -334
  20. package/android/src/main/include/rac/core/rac_logger.h +0 -416
  21. package/android/src/main/include/rac/core/rac_platform_adapter.h +0 -340
  22. package/android/src/main/include/rac/core/rac_sdk_state.h +0 -292
  23. package/android/src/main/include/rac/core/rac_structured_error.h +0 -594
  24. package/android/src/main/include/rac/core/rac_types.h +0 -264
  25. package/android/src/main/include/rac/features/llm/rac_llm.h +0 -17
  26. package/android/src/main/include/rac/features/llm/rac_llm_analytics.h +0 -188
  27. package/android/src/main/include/rac/features/llm/rac_llm_component.h +0 -228
  28. package/android/src/main/include/rac/features/llm/rac_llm_events.h +0 -215
  29. package/android/src/main/include/rac/features/llm/rac_llm_metrics.h +0 -402
  30. package/android/src/main/include/rac/features/llm/rac_llm_service.h +0 -163
  31. package/android/src/main/include/rac/features/llm/rac_llm_structured_output.h +0 -141
  32. package/android/src/main/include/rac/features/llm/rac_llm_types.h +0 -384
  33. package/android/src/main/include/rac/features/platform/rac_llm_platform.h +0 -204
  34. package/android/src/main/include/rac/features/platform/rac_tts_platform.h +0 -197
  35. package/android/src/main/include/rac/features/stt/rac_stt.h +0 -17
  36. package/android/src/main/include/rac/features/stt/rac_stt_analytics.h +0 -204
  37. package/android/src/main/include/rac/features/stt/rac_stt_component.h +0 -162
  38. package/android/src/main/include/rac/features/stt/rac_stt_events.h +0 -62
  39. package/android/src/main/include/rac/features/stt/rac_stt_service.h +0 -154
  40. package/android/src/main/include/rac/features/stt/rac_stt_types.h +0 -389
  41. package/android/src/main/include/rac/features/tts/rac_tts.h +0 -17
  42. package/android/src/main/include/rac/features/tts/rac_tts_analytics.h +0 -181
  43. package/android/src/main/include/rac/features/tts/rac_tts_component.h +0 -158
  44. package/android/src/main/include/rac/features/tts/rac_tts_events.h +0 -54
  45. package/android/src/main/include/rac/features/tts/rac_tts_service.h +0 -162
  46. package/android/src/main/include/rac/features/tts/rac_tts_types.h +0 -374
  47. package/android/src/main/include/rac/features/vad/rac_vad.h +0 -17
  48. package/android/src/main/include/rac/features/vad/rac_vad_analytics.h +0 -236
  49. package/android/src/main/include/rac/features/vad/rac_vad_component.h +0 -185
  50. package/android/src/main/include/rac/features/vad/rac_vad_energy.h +0 -443
  51. package/android/src/main/include/rac/features/vad/rac_vad_events.h +0 -76
  52. package/android/src/main/include/rac/features/vad/rac_vad_service.h +0 -167
  53. package/android/src/main/include/rac/features/vad/rac_vad_types.h +0 -244
  54. package/android/src/main/include/rac/features/voice_agent/rac_voice_agent.h +0 -612
  55. package/android/src/main/include/rac/infrastructure/device/rac_device_manager.h +0 -176
  56. package/android/src/main/include/rac/infrastructure/download/rac_download.h +0 -418
  57. package/android/src/main/include/rac/infrastructure/events/rac_events.h +0 -177
  58. package/android/src/main/include/rac/infrastructure/model_management/rac_model_assignment.h +0 -169
  59. package/android/src/main/include/rac/infrastructure/model_management/rac_model_paths.h +0 -258
  60. package/android/src/main/include/rac/infrastructure/model_management/rac_model_registry.h +0 -357
  61. package/android/src/main/include/rac/infrastructure/model_management/rac_model_strategy.h +0 -374
  62. package/android/src/main/include/rac/infrastructure/model_management/rac_model_types.h +0 -613
  63. package/android/src/main/include/rac/infrastructure/network/rac_api_types.h +0 -335
  64. package/android/src/main/include/rac/infrastructure/network/rac_auth_manager.h +0 -252
  65. package/android/src/main/include/rac/infrastructure/network/rac_dev_config.h +0 -85
  66. package/android/src/main/include/rac/infrastructure/network/rac_endpoints.h +0 -102
  67. package/android/src/main/include/rac/infrastructure/network/rac_environment.h +0 -220
  68. package/android/src/main/include/rac/infrastructure/network/rac_http_client.h +0 -233
  69. package/android/src/main/include/rac/infrastructure/storage/rac_storage_analyzer.h +0 -286
  70. package/android/src/main/include/rac/infrastructure/telemetry/rac_telemetry_manager.h +0 -206
  71. package/android/src/main/include/rac/infrastructure/telemetry/rac_telemetry_types.h +0 -234
  72. package/android/src/main/jniLibs/arm64-v8a/libomp.so +0 -0
@@ -18,17 +18,17 @@ set(JNILIB_DIR ${CMAKE_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI})
18
18
  # RABackendLlamaCPP - Llama LLM backend (REQUIRED)
19
19
  # Downloaded via Gradle downloadNativeLibs task
20
20
  # =============================================================================
21
- if(NOT EXISTS "${JNILIB_DIR}/librunanywhere_llamacpp.so")
22
- message(FATAL_ERROR "[RunAnywhereLlama] RABackendLlamaCPP not found at ${JNILIB_DIR}/librunanywhere_llamacpp.so\n"
21
+ if(NOT EXISTS "${JNILIB_DIR}/librac_backend_llamacpp.so")
22
+ message(FATAL_ERROR "[RunAnywhereLlama] RABackendLlamaCPP not found at ${JNILIB_DIR}/librac_backend_llamacpp.so\n"
23
23
  "Run: ./gradlew :runanywhere_llamacpp:downloadNativeLibs")
24
24
  endif()
25
25
 
26
- add_library(runanywhere_llamacpp SHARED IMPORTED)
27
- set_target_properties(runanywhere_llamacpp PROPERTIES
28
- IMPORTED_LOCATION "${JNILIB_DIR}/librunanywhere_llamacpp.so"
26
+ add_library(rac_backend_llamacpp SHARED IMPORTED)
27
+ set_target_properties(rac_backend_llamacpp PROPERTIES
28
+ IMPORTED_LOCATION "${JNILIB_DIR}/librac_backend_llamacpp.so"
29
29
  IMPORTED_NO_SONAME TRUE
30
30
  )
31
- message(STATUS "[RunAnywhereLlama] Found RABackendLlamaCPP at ${JNILIB_DIR}/librunanywhere_llamacpp.so")
31
+ message(STATUS "[RunAnywhereLlama] Found RABackendLlamaCPP at ${JNILIB_DIR}/librac_backend_llamacpp.so")
32
32
 
33
33
  # =============================================================================
34
34
  # Source files - Llama bridges
@@ -121,7 +121,7 @@ target_link_libraries(
121
121
  ${LOG_LIB}
122
122
  android
123
123
  rac_commons
124
- runanywhere_llamacpp
124
+ rac_backend_llamacpp
125
125
  )
126
126
 
127
127
  # HAS_LLAMACPP and HAS_RACOMMONS are always defined since backends are required
@@ -8,32 +8,32 @@
8
8
  <key>BinaryPath</key>
9
9
  <string>RABackendLLAMACPP.framework/RABackendLLAMACPP</string>
10
10
  <key>LibraryIdentifier</key>
11
- <string>ios-arm64</string>
11
+ <string>ios-arm64_x86_64-simulator</string>
12
12
  <key>LibraryPath</key>
13
13
  <string>RABackendLLAMACPP.framework</string>
14
14
  <key>SupportedArchitectures</key>
15
15
  <array>
16
16
  <string>arm64</string>
17
+ <string>x86_64</string>
17
18
  </array>
18
19
  <key>SupportedPlatform</key>
19
20
  <string>ios</string>
21
+ <key>SupportedPlatformVariant</key>
22
+ <string>simulator</string>
20
23
  </dict>
21
24
  <dict>
22
25
  <key>BinaryPath</key>
23
26
  <string>RABackendLLAMACPP.framework/RABackendLLAMACPP</string>
24
27
  <key>LibraryIdentifier</key>
25
- <string>ios-arm64_x86_64-simulator</string>
28
+ <string>ios-arm64</string>
26
29
  <key>LibraryPath</key>
27
30
  <string>RABackendLLAMACPP.framework</string>
28
31
  <key>SupportedArchitectures</key>
29
32
  <array>
30
33
  <string>arm64</string>
31
- <string>x86_64</string>
32
34
  </array>
33
35
  <key>SupportedPlatform</key>
34
36
  <string>ios</string>
35
- <key>SupportedPlatformVariant</key>
36
- <string>simulator</string>
37
37
  </dict>
38
38
  </array>
39
39
  <key>CFBundlePackageType</key>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runanywhere/llamacpp",
3
- "version": "0.17.4",
3
+ "version": "0.17.7",
4
4
  "description": "LlamaCpp backend for RunAnywhere React Native SDK - GGUF model support for on-device LLM",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -50,8 +50,8 @@
50
50
  "react-native-nitro-modules": ">=0.31.3"
51
51
  },
52
52
  "devDependencies": {
53
- "nitrogen": "^0.31.10",
54
- "react-native-nitro-modules": "^0.31.10",
53
+ "nitrogen": "^0.33.2",
54
+ "react-native-nitro-modules": "0.33.2",
55
55
  "typescript": "~5.9.2"
56
56
  },
57
57
  "create-react-native-library": {
@@ -1,218 +0,0 @@
1
- /**
2
- * @file rac_llm_llamacpp.h
3
- * @brief RunAnywhere Core - LlamaCPP Backend RAC API
4
- *
5
- * Direct RAC API export from runanywhere-core's LlamaCPP backend.
6
- * This header defines the public C API for LLM inference using llama.cpp.
7
- *
8
- * Mirrors Swift's LlamaCPPService implementation pattern.
9
- */
10
-
11
- #ifndef RAC_LLM_LLAMACPP_H
12
- #define RAC_LLM_LLAMACPP_H
13
-
14
- #include "rac/core/rac_error.h"
15
- #include "rac/core/rac_types.h"
16
- #include "rac/features/llm/rac_llm.h"
17
-
18
- #ifdef __cplusplus
19
- extern "C" {
20
- #endif
21
-
22
- // =============================================================================
23
- // EXPORT MACRO
24
- // =============================================================================
25
-
26
- #if defined(RAC_LLAMACPP_BUILDING)
27
- #if defined(_WIN32)
28
- #define RAC_LLAMACPP_API __declspec(dllexport)
29
- #elif defined(__GNUC__) || defined(__clang__)
30
- #define RAC_LLAMACPP_API __attribute__((visibility("default")))
31
- #else
32
- #define RAC_LLAMACPP_API
33
- #endif
34
- #else
35
- #define RAC_LLAMACPP_API
36
- #endif
37
-
38
- // =============================================================================
39
- // CONFIGURATION - Mirrors Swift's LlamaCPPGenerationConfig
40
- // =============================================================================
41
-
42
- /**
43
- * LlamaCPP-specific configuration.
44
- *
45
- * Mirrors Swift's LlamaCPPGenerationConfig.
46
- */
47
- typedef struct rac_llm_llamacpp_config {
48
- /** Context size (0 = auto-detect from model) */
49
- int32_t context_size;
50
-
51
- /** Number of threads (0 = auto-detect) */
52
- int32_t num_threads;
53
-
54
- /** Number of layers to offload to GPU (Metal on iOS/macOS) */
55
- int32_t gpu_layers;
56
-
57
- /** Batch size for prompt processing */
58
- int32_t batch_size;
59
- } rac_llm_llamacpp_config_t;
60
-
61
- /**
62
- * Default LlamaCPP configuration.
63
- */
64
- static const rac_llm_llamacpp_config_t RAC_LLM_LLAMACPP_CONFIG_DEFAULT = {
65
- .context_size = 0, // Auto-detect
66
- .num_threads = 0, // Auto-detect
67
- .gpu_layers = -1, // All layers on GPU
68
- .batch_size = 512};
69
-
70
- // =============================================================================
71
- // LLAMACPP-SPECIFIC API
72
- // =============================================================================
73
-
74
- /**
75
- * Creates a LlamaCPP LLM service.
76
- *
77
- * Mirrors Swift's LlamaCPPService.initialize(modelPath:)
78
- *
79
- * @param model_path Path to the GGUF model file
80
- * @param config LlamaCPP-specific configuration (can be NULL for defaults)
81
- * @param out_handle Output: Handle to the created service
82
- * @return RAC_SUCCESS or error code
83
- */
84
- RAC_LLAMACPP_API rac_result_t rac_llm_llamacpp_create(const char* model_path,
85
- const rac_llm_llamacpp_config_t* config,
86
- rac_handle_t* out_handle);
87
-
88
- /**
89
- * Loads a GGUF model into an existing service.
90
- *
91
- * Mirrors Swift's LlamaCPPService.loadModel(path:config:)
92
- *
93
- * @param handle Service handle
94
- * @param model_path Path to the GGUF model file
95
- * @param config LlamaCPP configuration (can be NULL)
96
- * @return RAC_SUCCESS or error code
97
- */
98
- RAC_LLAMACPP_API rac_result_t rac_llm_llamacpp_load_model(rac_handle_t handle,
99
- const char* model_path,
100
- const rac_llm_llamacpp_config_t* config);
101
-
102
- /**
103
- * Unloads the current model.
104
- *
105
- * Mirrors Swift's LlamaCPPService.unloadModel()
106
- *
107
- * @param handle Service handle
108
- * @return RAC_SUCCESS or error code
109
- */
110
- RAC_LLAMACPP_API rac_result_t rac_llm_llamacpp_unload_model(rac_handle_t handle);
111
-
112
- /**
113
- * Checks if a model is loaded.
114
- *
115
- * Mirrors Swift's LlamaCPPService.isModelLoaded
116
- *
117
- * @param handle Service handle
118
- * @return RAC_TRUE if model is loaded, RAC_FALSE otherwise
119
- */
120
- RAC_LLAMACPP_API rac_bool_t rac_llm_llamacpp_is_model_loaded(rac_handle_t handle);
121
-
122
- /**
123
- * Generates text completion.
124
- *
125
- * Mirrors Swift's LlamaCPPService.generate(prompt:config:)
126
- *
127
- * @param handle Service handle
128
- * @param prompt Input prompt text
129
- * @param options Generation options (can be NULL for defaults)
130
- * @param out_result Output: Generation result (caller must free text with rac_free)
131
- * @return RAC_SUCCESS or error code
132
- */
133
- RAC_LLAMACPP_API rac_result_t rac_llm_llamacpp_generate(rac_handle_t handle, const char* prompt,
134
- const rac_llm_options_t* options,
135
- rac_llm_result_t* out_result);
136
-
137
- /**
138
- * Streaming text generation callback.
139
- *
140
- * Mirrors Swift's streaming callback pattern.
141
- *
142
- * @param token Generated token string
143
- * @param is_final Whether this is the final token
144
- * @param user_data User-provided context
145
- * @return RAC_TRUE to continue, RAC_FALSE to stop
146
- */
147
- typedef rac_bool_t (*rac_llm_llamacpp_stream_callback_fn)(const char* token, rac_bool_t is_final,
148
- void* user_data);
149
-
150
- /**
151
- * Generates text with streaming callback.
152
- *
153
- * Mirrors Swift's LlamaCPPService.generateStream(prompt:config:)
154
- *
155
- * @param handle Service handle
156
- * @param prompt Input prompt text
157
- * @param options Generation options
158
- * @param callback Callback for each token
159
- * @param user_data User context passed to callback
160
- * @return RAC_SUCCESS or error code
161
- */
162
- RAC_LLAMACPP_API rac_result_t rac_llm_llamacpp_generate_stream(
163
- rac_handle_t handle, const char* prompt, const rac_llm_options_t* options,
164
- rac_llm_llamacpp_stream_callback_fn callback, void* user_data);
165
-
166
- /**
167
- * Cancels ongoing generation.
168
- *
169
- * Mirrors Swift's LlamaCPPService.cancel()
170
- *
171
- * @param handle Service handle
172
- */
173
- RAC_LLAMACPP_API void rac_llm_llamacpp_cancel(rac_handle_t handle);
174
-
175
- /**
176
- * Gets model information as JSON.
177
- *
178
- * @param handle Service handle
179
- * @param out_json Output: JSON string (caller must free with rac_free)
180
- * @return RAC_SUCCESS or error code
181
- */
182
- RAC_LLAMACPP_API rac_result_t rac_llm_llamacpp_get_model_info(rac_handle_t handle, char** out_json);
183
-
184
- /**
185
- * Destroys a LlamaCPP LLM service.
186
- *
187
- * @param handle Service handle to destroy
188
- */
189
- RAC_LLAMACPP_API void rac_llm_llamacpp_destroy(rac_handle_t handle);
190
-
191
- // =============================================================================
192
- // BACKEND REGISTRATION
193
- // =============================================================================
194
-
195
- /**
196
- * Registers the LlamaCPP backend with the commons module and service registries.
197
- *
198
- * Should be called once during SDK initialization.
199
- * This registers:
200
- * - Module: "llamacpp" with TEXT_GENERATION capability
201
- * - Service provider: LlamaCPP LLM provider
202
- *
203
- * @return RAC_SUCCESS or error code
204
- */
205
- RAC_LLAMACPP_API rac_result_t rac_backend_llamacpp_register(void);
206
-
207
- /**
208
- * Unregisters the LlamaCPP backend.
209
- *
210
- * @return RAC_SUCCESS or error code
211
- */
212
- RAC_LLAMACPP_API rac_result_t rac_backend_llamacpp_unregister(void);
213
-
214
- #ifdef __cplusplus
215
- }
216
- #endif
217
-
218
- #endif /* RAC_LLM_LLAMACPP_H */
@@ -1,99 +0,0 @@
1
- /**
2
- * @file rac_stt_onnx.h
3
- * @brief RunAnywhere Core - ONNX Backend RAC API for STT
4
- *
5
- * Direct RAC API export from runanywhere-core's ONNX STT backend.
6
- * Mirrors Swift's ONNXSTTService implementation pattern.
7
- */
8
-
9
- #ifndef RAC_STT_ONNX_H
10
- #define RAC_STT_ONNX_H
11
-
12
- #include "rac/core/rac_error.h"
13
- #include "rac/core/rac_types.h"
14
- #include "rac/features/stt/rac_stt.h"
15
-
16
- #ifdef __cplusplus
17
- extern "C" {
18
- #endif
19
-
20
- // =============================================================================
21
- // EXPORT MACRO
22
- // =============================================================================
23
-
24
- #if defined(RAC_ONNX_BUILDING)
25
- #if defined(_WIN32)
26
- #define RAC_ONNX_API __declspec(dllexport)
27
- #elif defined(__GNUC__) || defined(__clang__)
28
- #define RAC_ONNX_API __attribute__((visibility("default")))
29
- #else
30
- #define RAC_ONNX_API
31
- #endif
32
- #else
33
- #define RAC_ONNX_API
34
- #endif
35
-
36
- // =============================================================================
37
- // CONFIGURATION
38
- // =============================================================================
39
-
40
- /**
41
- * ONNX STT model types.
42
- */
43
- typedef enum rac_stt_onnx_model_type {
44
- RAC_STT_ONNX_MODEL_WHISPER = 0,
45
- RAC_STT_ONNX_MODEL_ZIPFORMER = 1,
46
- RAC_STT_ONNX_MODEL_PARAFORMER = 2,
47
- RAC_STT_ONNX_MODEL_AUTO = 99
48
- } rac_stt_onnx_model_type_t;
49
-
50
- /**
51
- * ONNX STT configuration.
52
- */
53
- typedef struct rac_stt_onnx_config {
54
- rac_stt_onnx_model_type_t model_type;
55
- int32_t num_threads;
56
- rac_bool_t use_coreml;
57
- } rac_stt_onnx_config_t;
58
-
59
- static const rac_stt_onnx_config_t RAC_STT_ONNX_CONFIG_DEFAULT = {
60
- .model_type = RAC_STT_ONNX_MODEL_AUTO, .num_threads = 0, .use_coreml = RAC_TRUE};
61
-
62
- // =============================================================================
63
- // ONNX STT API
64
- // =============================================================================
65
-
66
- RAC_ONNX_API rac_result_t rac_stt_onnx_create(const char* model_path,
67
- const rac_stt_onnx_config_t* config,
68
- rac_handle_t* out_handle);
69
-
70
- RAC_ONNX_API rac_result_t rac_stt_onnx_transcribe(rac_handle_t handle, const float* audio_samples,
71
- size_t num_samples,
72
- const rac_stt_options_t* options,
73
- rac_stt_result_t* out_result);
74
-
75
- RAC_ONNX_API rac_bool_t rac_stt_onnx_supports_streaming(rac_handle_t handle);
76
-
77
- RAC_ONNX_API rac_result_t rac_stt_onnx_create_stream(rac_handle_t handle, rac_handle_t* out_stream);
78
-
79
- RAC_ONNX_API rac_result_t rac_stt_onnx_feed_audio(rac_handle_t handle, rac_handle_t stream,
80
- const float* audio_samples, size_t num_samples);
81
-
82
- RAC_ONNX_API rac_bool_t rac_stt_onnx_stream_is_ready(rac_handle_t handle, rac_handle_t stream);
83
-
84
- RAC_ONNX_API rac_result_t rac_stt_onnx_decode_stream(rac_handle_t handle, rac_handle_t stream,
85
- char** out_text);
86
-
87
- RAC_ONNX_API void rac_stt_onnx_input_finished(rac_handle_t handle, rac_handle_t stream);
88
-
89
- RAC_ONNX_API rac_bool_t rac_stt_onnx_is_endpoint(rac_handle_t handle, rac_handle_t stream);
90
-
91
- RAC_ONNX_API void rac_stt_onnx_destroy_stream(rac_handle_t handle, rac_handle_t stream);
92
-
93
- RAC_ONNX_API void rac_stt_onnx_destroy(rac_handle_t handle);
94
-
95
- #ifdef __cplusplus
96
- }
97
- #endif
98
-
99
- #endif /* RAC_STT_ONNX_H */
@@ -1,153 +0,0 @@
1
- /**
2
- * @file rac_stt_whispercpp.h
3
- * @brief RunAnywhere Core - WhisperCPP Backend for STT
4
- *
5
- * RAC API for WhisperCPP-based speech-to-text.
6
- * Provides high-quality transcription using whisper.cpp.
7
- *
8
- * NOTE: WhisperCPP and LlamaCPP both use GGML, which can cause symbol
9
- * conflicts if linked together. Use ONNX Whisper for STT when also
10
- * using LlamaCPP for LLM, or build with symbol prefixing.
11
- */
12
-
13
- #ifndef RAC_STT_WHISPERCPP_H
14
- #define RAC_STT_WHISPERCPP_H
15
-
16
- #include "rac/core/rac_error.h"
17
- #include "rac/core/rac_types.h"
18
- #include "rac/features/stt/rac_stt.h"
19
-
20
- #ifdef __cplusplus
21
- extern "C" {
22
- #endif
23
-
24
- // =============================================================================
25
- // EXPORT MACRO
26
- // =============================================================================
27
-
28
- #if defined(RAC_WHISPERCPP_BUILDING)
29
- #if defined(_WIN32)
30
- #define RAC_WHISPERCPP_API __declspec(dllexport)
31
- #elif defined(__GNUC__) || defined(__clang__)
32
- #define RAC_WHISPERCPP_API __attribute__((visibility("default")))
33
- #else
34
- #define RAC_WHISPERCPP_API
35
- #endif
36
- #else
37
- #define RAC_WHISPERCPP_API
38
- #endif
39
-
40
- // =============================================================================
41
- // CONFIGURATION
42
- // =============================================================================
43
-
44
- /**
45
- * WhisperCPP-specific configuration.
46
- */
47
- typedef struct rac_stt_whispercpp_config {
48
- /** Number of threads (0 = auto) */
49
- int32_t num_threads;
50
-
51
- /** Enable GPU acceleration (Metal on Apple) */
52
- rac_bool_t use_gpu;
53
-
54
- /** Enable CoreML acceleration (Apple only) */
55
- rac_bool_t use_coreml;
56
-
57
- /** Language code for transcription (NULL = auto-detect) */
58
- const char* language;
59
-
60
- /** Translate to English (when source is non-English) */
61
- rac_bool_t translate;
62
- } rac_stt_whispercpp_config_t;
63
-
64
- /**
65
- * Default WhisperCPP configuration.
66
- */
67
- static const rac_stt_whispercpp_config_t RAC_STT_WHISPERCPP_CONFIG_DEFAULT = {
68
- .num_threads = 0,
69
- .use_gpu = RAC_TRUE,
70
- .use_coreml = RAC_TRUE,
71
- .language = NULL,
72
- .translate = RAC_FALSE};
73
-
74
- // =============================================================================
75
- // WHISPERCPP STT API
76
- // =============================================================================
77
-
78
- /**
79
- * Creates a WhisperCPP STT service.
80
- *
81
- * @param model_path Path to the Whisper GGML model file (.bin)
82
- * @param config WhisperCPP-specific configuration (can be NULL for defaults)
83
- * @param out_handle Output: Handle to the created service
84
- * @return RAC_SUCCESS or error code
85
- */
86
- RAC_WHISPERCPP_API rac_result_t rac_stt_whispercpp_create(const char* model_path,
87
- const rac_stt_whispercpp_config_t* config,
88
- rac_handle_t* out_handle);
89
-
90
- /**
91
- * Transcribes audio data.
92
- *
93
- * @param handle Service handle
94
- * @param audio_samples Float32 PCM samples (16kHz mono)
95
- * @param num_samples Number of samples
96
- * @param options STT options (can be NULL for defaults)
97
- * @param out_result Output: Transcription result
98
- * @return RAC_SUCCESS or error code
99
- */
100
- RAC_WHISPERCPP_API rac_result_t rac_stt_whispercpp_transcribe(rac_handle_t handle,
101
- const float* audio_samples,
102
- size_t num_samples,
103
- const rac_stt_options_t* options,
104
- rac_stt_result_t* out_result);
105
-
106
- /**
107
- * Gets detected language after transcription.
108
- *
109
- * @param handle Service handle
110
- * @param out_language Output: Language code (caller must free)
111
- * @return RAC_SUCCESS or error code
112
- */
113
- RAC_WHISPERCPP_API rac_result_t rac_stt_whispercpp_get_language(rac_handle_t handle,
114
- char** out_language);
115
-
116
- /**
117
- * Checks if model is loaded and ready.
118
- *
119
- * @param handle Service handle
120
- * @return RAC_TRUE if ready
121
- */
122
- RAC_WHISPERCPP_API rac_bool_t rac_stt_whispercpp_is_ready(rac_handle_t handle);
123
-
124
- /**
125
- * Destroys a WhisperCPP STT service.
126
- *
127
- * @param handle Service handle to destroy
128
- */
129
- RAC_WHISPERCPP_API void rac_stt_whispercpp_destroy(rac_handle_t handle);
130
-
131
- // =============================================================================
132
- // BACKEND REGISTRATION
133
- // =============================================================================
134
-
135
- /**
136
- * Registers the WhisperCPP backend with the commons module and service registries.
137
- *
138
- * @return RAC_SUCCESS or error code
139
- */
140
- RAC_WHISPERCPP_API rac_result_t rac_backend_whispercpp_register(void);
141
-
142
- /**
143
- * Unregisters the WhisperCPP backend.
144
- *
145
- * @return RAC_SUCCESS or error code
146
- */
147
- RAC_WHISPERCPP_API rac_result_t rac_backend_whispercpp_unregister(void);
148
-
149
- #ifdef __cplusplus
150
- }
151
- #endif
152
-
153
- #endif /* RAC_STT_WHISPERCPP_H */
@@ -1,71 +0,0 @@
1
- /**
2
- * @file rac_tts_onnx.h
3
- * @brief RunAnywhere Core - ONNX Backend RAC API for TTS
4
- *
5
- * Direct RAC API export from runanywhere-core's ONNX TTS backend.
6
- */
7
-
8
- #ifndef RAC_TTS_ONNX_H
9
- #define RAC_TTS_ONNX_H
10
-
11
- #include "rac/core/rac_error.h"
12
- #include "rac/core/rac_types.h"
13
- #include "rac/features/tts/rac_tts.h"
14
-
15
- #ifdef __cplusplus
16
- extern "C" {
17
- #endif
18
-
19
- // =============================================================================
20
- // EXPORT MACRO
21
- // =============================================================================
22
-
23
- #if defined(RAC_ONNX_BUILDING)
24
- #if defined(_WIN32)
25
- #define RAC_ONNX_API __declspec(dllexport)
26
- #elif defined(__GNUC__) || defined(__clang__)
27
- #define RAC_ONNX_API __attribute__((visibility("default")))
28
- #else
29
- #define RAC_ONNX_API
30
- #endif
31
- #else
32
- #define RAC_ONNX_API
33
- #endif
34
-
35
- // =============================================================================
36
- // CONFIGURATION
37
- // =============================================================================
38
-
39
- typedef struct rac_tts_onnx_config {
40
- int32_t num_threads;
41
- rac_bool_t use_coreml;
42
- int32_t sample_rate;
43
- } rac_tts_onnx_config_t;
44
-
45
- static const rac_tts_onnx_config_t RAC_TTS_ONNX_CONFIG_DEFAULT = {
46
- .num_threads = 0, .use_coreml = RAC_TRUE, .sample_rate = 22050};
47
-
48
- // =============================================================================
49
- // ONNX TTS API
50
- // =============================================================================
51
-
52
- RAC_ONNX_API rac_result_t rac_tts_onnx_create(const char* model_path,
53
- const rac_tts_onnx_config_t* config,
54
- rac_handle_t* out_handle);
55
-
56
- RAC_ONNX_API rac_result_t rac_tts_onnx_synthesize(rac_handle_t handle, const char* text,
57
- const rac_tts_options_t* options,
58
- rac_tts_result_t* out_result);
59
-
60
- RAC_ONNX_API rac_result_t rac_tts_onnx_get_voices(rac_handle_t handle, char*** out_voices,
61
- size_t* out_count);
62
-
63
- RAC_ONNX_API void rac_tts_onnx_stop(rac_handle_t handle);
64
-
65
- RAC_ONNX_API void rac_tts_onnx_destroy(rac_handle_t handle);
66
-
67
- #ifdef __cplusplus
68
- }
69
- #endif
70
-
71
- #endif /* RAC_TTS_ONNX_H */