@mentra/bluetooth-sdk 0.1.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 (278) hide show
  1. package/README.md +278 -0
  2. package/android/build.gradle +167 -0
  3. package/android/lc3Lib/CMakeLists.txt +6 -0
  4. package/android/lc3Lib/build.gradle +109 -0
  5. package/android/lc3Lib/proguard-rules.pro +33 -0
  6. package/android/lc3Lib/src/main/AndroidManifest.xml +2 -0
  7. package/android/lc3Lib/src/main/cpp/CMakeLists.txt +8 -0
  8. package/android/lc3Lib/src/main/cpp/google_opus_stuff/CMakeLists.txt +30 -0
  9. package/android/lc3Lib/src/main/cpp/google_opus_stuff/jni/CMakeLists.txt +7 -0
  10. package/android/lc3Lib/src/main/cpp/google_opus_stuff/jni/ogg_opus_encoder.cc +96 -0
  11. package/android/lc3Lib/src/main/cpp/google_opus_stuff/jni/ogg_opus_encoder.h +53 -0
  12. package/android/lc3Lib/src/main/cpp/google_opus_stuff/libogg/Makefile.am +6 -0
  13. package/android/lc3Lib/src/main/cpp/google_opus_stuff/libogg/config_types.h +26 -0
  14. package/android/lc3Lib/src/main/cpp/google_opus_stuff/libogg/config_types.h.in +26 -0
  15. package/android/lc3Lib/src/main/cpp/google_opus_stuff/libogg/ogg.h +209 -0
  16. package/android/lc3Lib/src/main/cpp/google_opus_stuff/libogg/os_types.h +158 -0
  17. package/android/lc3Lib/src/main/cpp/google_opus_stuff/libopus/opus.h +981 -0
  18. package/android/lc3Lib/src/main/cpp/google_opus_stuff/libopus/opus_custom.h +342 -0
  19. package/android/lc3Lib/src/main/cpp/google_opus_stuff/libopus/opus_defines.h +799 -0
  20. package/android/lc3Lib/src/main/cpp/google_opus_stuff/libopus/opus_multistream.h +660 -0
  21. package/android/lc3Lib/src/main/cpp/google_opus_stuff/libopus/opus_projection.h +568 -0
  22. package/android/lc3Lib/src/main/cpp/google_opus_stuff/libopus/opus_types.h +166 -0
  23. package/android/lc3Lib/src/main/cpp/google_opus_stuff/ogg_opus_encoder.cc +268 -0
  24. package/android/lc3Lib/src/main/cpp/google_opus_stuff/ogg_opus_encoder.h +115 -0
  25. package/android/lc3Lib/src/main/cpp/google_opus_stuff/opus_tools/opus_header.h +59 -0
  26. package/android/lc3Lib/src/main/cpp/liblc3/CMakeLists.txt +38 -0
  27. package/android/lc3Lib/src/main/cpp/liblc3/include/lc3.h +309 -0
  28. package/android/lc3Lib/src/main/cpp/liblc3/include/lc3_private.h +162 -0
  29. package/android/lc3Lib/src/main/cpp/liblc3/include/rnnoise.h +114 -0
  30. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/CMakeLists.txt +19 -0
  31. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/attdet.c +92 -0
  32. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/attdet.h +44 -0
  33. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/bits.c +375 -0
  34. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/bits.h +315 -0
  35. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/bwdet.c +129 -0
  36. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/bwdet.h +69 -0
  37. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/common.h +148 -0
  38. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/energy.c +70 -0
  39. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/energy.h +43 -0
  40. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/fastmath.h +158 -0
  41. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/lc3.c +702 -0
  42. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/ltpf.c +893 -0
  43. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/ltpf.h +111 -0
  44. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/ltpf_arm.h +506 -0
  45. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/ltpf_neon.h +281 -0
  46. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/makefile.mk +35 -0
  47. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/mdct.c +452 -0
  48. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/mdct.h +57 -0
  49. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/mdct_neon.h +296 -0
  50. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/meson.build +46 -0
  51. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/plc.c +61 -0
  52. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/plc.h +57 -0
  53. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/sns.c +880 -0
  54. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/sns.h +103 -0
  55. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/spec.c +904 -0
  56. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/spec.h +119 -0
  57. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/tables.c +3457 -0
  58. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/tables.h +94 -0
  59. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/tns.c +457 -0
  60. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/tns.h +99 -0
  61. package/android/lc3Lib/src/main/cpp/liblc3/liblc3.cpp +159 -0
  62. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/_kiss_fft_guts.h +182 -0
  63. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/arch.h +261 -0
  64. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/celt_lpc.c +279 -0
  65. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/celt_lpc.h +59 -0
  66. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/common.h +48 -0
  67. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/compile.sh +3 -0
  68. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/denoise.c +646 -0
  69. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/kiss_fft.c +601 -0
  70. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/kiss_fft.h +203 -0
  71. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/opus_types.h +159 -0
  72. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/pitch.c +526 -0
  73. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/pitch.h +149 -0
  74. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/rnn.c +178 -0
  75. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/rnn.h +69 -0
  76. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/rnn_data.c +11051 -0
  77. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/rnn_data.h +34 -0
  78. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/rnn_reader.c +168 -0
  79. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/rnn_train.py +66 -0
  80. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/tansig_table.h +45 -0
  81. package/android/lc3Lib/src/main/java/com/mentra/lc3Lib/Lc3Cpp.java +38 -0
  82. package/android/lc3Lib/third_party/CMakeLists.txt +23 -0
  83. package/android/lc3Lib/third_party/CMakeLists_libogg.txt +18 -0
  84. package/android/lc3Lib/third_party/CMakeLists_libopus.txt +18 -0
  85. package/android/lc3Lib/third_party/CMakeLists_opus-tools.txt +23 -0
  86. package/android/lc3Lib/third_party/opus_tools/src/AUTHORS +5 -0
  87. package/android/lc3Lib/third_party/opus_tools/src/CMakeLists.txt +4 -0
  88. package/android/lc3Lib/third_party/opus_tools/src/COPYING +371 -0
  89. package/android/lc3Lib/third_party/opus_tools/src/ChangeLog +3 -0
  90. package/android/lc3Lib/third_party/opus_tools/src/Makefile.am +42 -0
  91. package/android/lc3Lib/third_party/opus_tools/src/Makefile.unix +23 -0
  92. package/android/lc3Lib/third_party/opus_tools/src/NEWS +0 -0
  93. package/android/lc3Lib/third_party/opus_tools/src/README +0 -0
  94. package/android/lc3Lib/third_party/opus_tools/src/autogen.sh +115 -0
  95. package/android/lc3Lib/third_party/opus_tools/src/configure.ac +293 -0
  96. package/android/lc3Lib/third_party/opus_tools/src/src/arch.h +239 -0
  97. package/android/lc3Lib/third_party/opus_tools/src/src/audio-in.c +1046 -0
  98. package/android/lc3Lib/third_party/opus_tools/src/src/diag_range.c +245 -0
  99. package/android/lc3Lib/third_party/opus_tools/src/src/diag_range.h +28 -0
  100. package/android/lc3Lib/third_party/opus_tools/src/src/info_opus.c +320 -0
  101. package/android/lc3Lib/third_party/opus_tools/src/src/info_opus.h +51 -0
  102. package/android/lc3Lib/third_party/opus_tools/src/src/lpc.c +157 -0
  103. package/android/lc3Lib/third_party/opus_tools/src/src/lpc.h +27 -0
  104. package/android/lc3Lib/third_party/opus_tools/src/src/opus_header.c +286 -0
  105. package/android/lc3Lib/third_party/opus_tools/src/src/opus_header.h +59 -0
  106. package/android/lc3Lib/third_party/opus_tools/src/src/opusdec.c +884 -0
  107. package/android/lc3Lib/third_party/opus_tools/src/src/opusenc.c +1021 -0
  108. package/android/lc3Lib/third_party/opus_tools/src/src/opusenc.h +101 -0
  109. package/android/lc3Lib/third_party/opus_tools/src/src/opusinfo.c +639 -0
  110. package/android/lc3Lib/third_party/opus_tools/src/src/opusinfo.h +51 -0
  111. package/android/lc3Lib/third_party/opus_tools/src/src/os_support.h +167 -0
  112. package/android/lc3Lib/third_party/opus_tools/src/src/resample.c +1137 -0
  113. package/android/lc3Lib/third_party/opus_tools/src/src/speex_resampler.h +344 -0
  114. package/android/lc3Lib/third_party/opus_tools/src/src/stack_alloc.h +115 -0
  115. package/android/lc3Lib/third_party/opus_tools/src/src/wav_io.c +125 -0
  116. package/android/lc3Lib/third_party/opus_tools/src/src/wav_io.h +62 -0
  117. package/android/lc3Lib/third_party/opus_tools/src/src/wave_out.c +223 -0
  118. package/android/lc3Lib/third_party/opus_tools/src/src/wave_out.h +60 -0
  119. package/android/settings.gradle +1 -0
  120. package/android/src/main/AndroidManifest.xml +40 -0
  121. package/android/src/main/java/com/mentra/bluetoothsdk/BluetoothSdkModule.kt +528 -0
  122. package/android/src/main/java/com/mentra/bluetoothsdk/Bridge.kt +610 -0
  123. package/android/src/main/java/com/mentra/bluetoothsdk/DeviceManager.kt +1616 -0
  124. package/android/src/main/java/com/mentra/bluetoothsdk/DeviceStore.kt +314 -0
  125. package/android/src/main/java/com/mentra/bluetoothsdk/MentraBluetoothModels.kt +1710 -0
  126. package/android/src/main/java/com/mentra/bluetoothsdk/MentraBluetoothSdk.kt +554 -0
  127. package/android/src/main/java/com/mentra/bluetoothsdk/ObservableStore.kt +68 -0
  128. package/android/src/main/java/com/mentra/bluetoothsdk/controllers/ControllerManager.kt +158 -0
  129. package/android/src/main/java/com/mentra/bluetoothsdk/controllers/R1.kt +934 -0
  130. package/android/src/main/java/com/mentra/bluetoothsdk/services/Foreground.kt +175 -0
  131. package/android/src/main/java/com/mentra/bluetoothsdk/services/PhoneMic.kt +1109 -0
  132. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/G1.java +3974 -0
  133. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/G2.kt +3551 -0
  134. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/Mach1.java +1327 -0
  135. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLive.java +6959 -0
  136. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraNex.kt +1655 -0
  137. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraosBle.java +53675 -0
  138. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/SGCManager.kt +202 -0
  139. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/Simulated.kt +224 -0
  140. package/android/src/main/java/com/mentra/bluetoothsdk/stt/STTTools.kt +340 -0
  141. package/android/src/main/java/com/mentra/bluetoothsdk/stt/SherpaOnnxTranscriber.kt +465 -0
  142. package/android/src/main/java/com/mentra/bluetoothsdk/stt/VadGateSpeechPolicy.kt +221 -0
  143. package/android/src/main/java/com/mentra/bluetoothsdk/utils/AES.java +106 -0
  144. package/android/src/main/java/com/mentra/bluetoothsdk/utils/AudioSessionMonitor.kt +189 -0
  145. package/android/src/main/java/com/mentra/bluetoothsdk/utils/BitmapJavaUtils.java +169 -0
  146. package/android/src/main/java/com/mentra/bluetoothsdk/utils/BlePhotoUploadService.java +179 -0
  147. package/android/src/main/java/com/mentra/bluetoothsdk/utils/Constants.kt +44 -0
  148. package/android/src/main/java/com/mentra/bluetoothsdk/utils/G1Text.kt +436 -0
  149. package/android/src/main/java/com/mentra/bluetoothsdk/utils/IncidentLogBleRelayNaming.java +29 -0
  150. package/android/src/main/java/com/mentra/bluetoothsdk/utils/IncidentLogBleUploadService.java +76 -0
  151. package/android/src/main/java/com/mentra/bluetoothsdk/utils/K900ProtocolUtils.java +791 -0
  152. package/android/src/main/java/com/mentra/bluetoothsdk/utils/MessageChunker.java +186 -0
  153. package/android/src/main/java/com/mentra/bluetoothsdk/utils/NexSGCUtils.kt +589 -0
  154. package/android/src/main/java/com/mentra/bluetoothsdk/utils/PhoneAudioMonitor.kt +303 -0
  155. package/android/src/main/java/com/mentra/bluetoothsdk/utils/SmartGlassesConnectionState.java +9 -0
  156. package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/ByteUtilAudioPlayer.java +655 -0
  157. package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/Lc3Player.java +441 -0
  158. package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/PCMAudioPlayer.java +431 -0
  159. package/android/src/main/res/values/strings.xml +4 -0
  160. package/app.plugin.js +1 -0
  161. package/build/BluetoothSdk.types.d.ts +498 -0
  162. package/build/BluetoothSdk.types.d.ts.map +1 -0
  163. package/build/BluetoothSdk.types.js +23 -0
  164. package/build/BluetoothSdk.types.js.map +1 -0
  165. package/build/BluetoothSdkModule.d.ts +71 -0
  166. package/build/BluetoothSdkModule.d.ts.map +1 -0
  167. package/build/BluetoothSdkModule.js +106 -0
  168. package/build/BluetoothSdkModule.js.map +1 -0
  169. package/build/index.d.ts +3 -0
  170. package/build/index.d.ts.map +1 -0
  171. package/build/index.js +5 -0
  172. package/build/index.js.map +1 -0
  173. package/expo-module.config.json +9 -0
  174. package/ios/BluetoothSdkModule.swift +665 -0
  175. package/ios/MentraBluetoothSDK.podspec +77 -0
  176. package/ios/Packages/CoreObjC/CoreObjC.xcodeproj/project.pbxproj +213 -0
  177. package/ios/Packages/CoreObjC/PcmConverter.h +22 -0
  178. package/ios/Packages/CoreObjC/PcmConverter.m +266 -0
  179. package/ios/Packages/CoreObjC/attdet.c +92 -0
  180. package/ios/Packages/CoreObjC/attdet.h +44 -0
  181. package/ios/Packages/CoreObjC/bits.c +375 -0
  182. package/ios/Packages/CoreObjC/bits.h +315 -0
  183. package/ios/Packages/CoreObjC/bwdet.c +129 -0
  184. package/ios/Packages/CoreObjC/bwdet.h +69 -0
  185. package/ios/Packages/CoreObjC/common.h +151 -0
  186. package/ios/Packages/CoreObjC/energy.c +70 -0
  187. package/ios/Packages/CoreObjC/energy.h +43 -0
  188. package/ios/Packages/CoreObjC/fastmath.h +158 -0
  189. package/ios/Packages/CoreObjC/lc3.c +704 -0
  190. package/ios/Packages/CoreObjC/lc3.h +313 -0
  191. package/ios/Packages/CoreObjC/lc3_cpp.h +283 -0
  192. package/ios/Packages/CoreObjC/lc3_private.h +163 -0
  193. package/ios/Packages/CoreObjC/ltpf.c +905 -0
  194. package/ios/Packages/CoreObjC/ltpf.h +111 -0
  195. package/ios/Packages/CoreObjC/ltpf_arm.h +506 -0
  196. package/ios/Packages/CoreObjC/ltpf_neon.h +281 -0
  197. package/ios/Packages/CoreObjC/makefile.mk +35 -0
  198. package/ios/Packages/CoreObjC/mdct.c +469 -0
  199. package/ios/Packages/CoreObjC/mdct.h +57 -0
  200. package/ios/Packages/CoreObjC/mdct_neon.h +296 -0
  201. package/ios/Packages/CoreObjC/meson.build +61 -0
  202. package/ios/Packages/CoreObjC/plc.c +61 -0
  203. package/ios/Packages/CoreObjC/plc.h +57 -0
  204. package/ios/Packages/CoreObjC/rnnoise.h +114 -0
  205. package/ios/Packages/CoreObjC/sns.c +880 -0
  206. package/ios/Packages/CoreObjC/sns.h +103 -0
  207. package/ios/Packages/CoreObjC/spec.c +907 -0
  208. package/ios/Packages/CoreObjC/spec.h +119 -0
  209. package/ios/Packages/CoreObjC/tables.c +3457 -0
  210. package/ios/Packages/CoreObjC/tables.h +94 -0
  211. package/ios/Packages/CoreObjC/tns.c +457 -0
  212. package/ios/Packages/CoreObjC/tns.h +99 -0
  213. package/ios/Packages/SherpaOnnx/Model/joiner.onnx +0 -0
  214. package/ios/Packages/SherpaOnnx/Model/tokens.txt +502 -0
  215. package/ios/Packages/SherpaOnnx/SherpaOnnx.swift +1659 -0
  216. package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/Headers/cargs.h +162 -0
  217. package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/Headers/sherpa-onnx/c-api/c-api.h +1852 -0
  218. package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/Headers/sherpa-onnx/c-api/cxx-api.h +674 -0
  219. package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/Info.plist +44 -0
  220. package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/ios-arm64/libsherpa-onnx.a +0 -0
  221. package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/ios-arm64/sherpa-onnx.a +0 -0
  222. package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/ios-arm64_x86_64-simulator/libsherpa-onnx.a +0 -0
  223. package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/ios-arm64_x86_64-simulator/sherpa-onnx.a +0 -0
  224. package/ios/Packages/VAD/Common/VAD/VADQuality.swift +41 -0
  225. package/ios/Packages/VAD/Common/VAD/VADState.swift +26 -0
  226. package/ios/Packages/VAD/Common/VAD/VADStrategy.swift +29 -0
  227. package/ios/Packages/VAD/Common/VAD/VADType.swift +14 -0
  228. package/ios/Packages/VAD/Data/Configuration.swift +68 -0
  229. package/ios/Packages/VAD/Data/FrameSize.swift +39 -0
  230. package/ios/Packages/VAD/Data/Record.swift +13 -0
  231. package/ios/Packages/VAD/Data/Result.swift +22 -0
  232. package/ios/Packages/VAD/Data/SampleRate.swift +48 -0
  233. package/ios/Packages/VAD/Silero/Model/silero_vad.onnx +0 -0
  234. package/ios/Packages/VAD/Silero/SileroVAD.swift +284 -0
  235. package/ios/Packages/VAD/Silero/SileroVADStrategy.swift +64 -0
  236. package/ios/Packages/libbz2/module.modulemap +5 -0
  237. package/ios/Packages/libbz2/shim.h +1 -0
  238. package/ios/Source/Bridge.swift +353 -0
  239. package/ios/Source/Bridging-Header.h +16 -0
  240. package/ios/Source/DeviceManager.swift +1478 -0
  241. package/ios/Source/DeviceStore.swift +295 -0
  242. package/ios/Source/MentraBluetoothSDK.swift +2439 -0
  243. package/ios/Source/ObservableStore.swift +88 -0
  244. package/ios/Source/PrivacyInfo.xcprivacy +23 -0
  245. package/ios/Source/controllers/ControllerManager.swift +187 -0
  246. package/ios/Source/controllers/R1.swift +827 -0
  247. package/ios/Source/services/PhoneMic.swift +662 -0
  248. package/ios/Source/sgcs/Frame.swift +651 -0
  249. package/ios/Source/sgcs/G1.swift +2505 -0
  250. package/ios/Source/sgcs/G2.swift +3730 -0
  251. package/ios/Source/sgcs/Mach1.swift +543 -0
  252. package/ios/Source/sgcs/MentraLive.swift +4708 -0
  253. package/ios/Source/sgcs/MentraNex.swift +2479 -0
  254. package/ios/Source/sgcs/SGCManager.swift +243 -0
  255. package/ios/Source/sgcs/Simulated.swift +270 -0
  256. package/ios/Source/sgcs/mentraos_ble.pb.swift +3811 -0
  257. package/ios/Source/stt/STTTools.swift +154 -0
  258. package/ios/Source/stt/SherpaOnnxTranscriber.swift +401 -0
  259. package/ios/Source/utils/AudioSessionMonitor.swift +283 -0
  260. package/ios/Source/utils/Constants.swift +74 -0
  261. package/ios/Source/utils/Enums.swift +95 -0
  262. package/ios/Source/utils/G1Text.swift +2067 -0
  263. package/ios/Source/utils/JSCExperiment.swift +241 -0
  264. package/ios/Source/utils/MemoryMonitor.swift +44 -0
  265. package/ios/Source/utils/MessageChunker.swift +164 -0
  266. package/ios/Source/utils/Models.swift +135 -0
  267. package/ios/Source/utils/PhoneAudioMonitor.swift +226 -0
  268. package/ios/Source/utils/TarBz2Extractor.swift +206 -0
  269. package/package.json +78 -0
  270. package/plugin/build/index.d.ts +6 -0
  271. package/plugin/build/index.js +12 -0
  272. package/plugin/build/withAndroid.d.ts +4 -0
  273. package/plugin/build/withAndroid.js +80 -0
  274. package/plugin/build/withIos.d.ts +4 -0
  275. package/plugin/build/withIos.js +64 -0
  276. package/src/BluetoothSdk.types.ts +581 -0
  277. package/src/BluetoothSdkModule.ts +259 -0
  278. package/src/index.ts +4 -0
@@ -0,0 +1,1852 @@
1
+ // sherpa-onnx/c-api/c-api.h
2
+ //
3
+ // Copyright (c) 2023 Xiaomi Corporation
4
+
5
+ // C API for sherpa-onnx
6
+ //
7
+ // Please refer to
8
+ // https://github.com/k2-fsa/sherpa-onnx/blob/master/c-api-examples/decode-file-c-api.c
9
+ // for usages.
10
+ //
11
+
12
+ #ifndef SHERPA_ONNX_C_API_C_API_H_
13
+ #define SHERPA_ONNX_C_API_C_API_H_
14
+
15
+ #include <stdint.h>
16
+
17
+ #ifdef __cplusplus
18
+ extern "C" {
19
+ #endif
20
+
21
+ // See https://github.com/pytorch/pytorch/blob/main/c10/macros/Export.h
22
+ // We will set SHERPA_ONNX_BUILD_SHARED_LIBS and SHERPA_ONNX_BUILD_MAIN_LIB in
23
+ // CMakeLists.txt
24
+
25
+ #if defined(__GNUC__)
26
+ #pragma GCC diagnostic push
27
+ #pragma GCC diagnostic ignored "-Wattributes"
28
+ #endif
29
+
30
+ #if defined(_WIN32)
31
+ #if defined(SHERPA_ONNX_BUILD_SHARED_LIBS)
32
+ #define SHERPA_ONNX_EXPORT __declspec(dllexport)
33
+ #define SHERPA_ONNX_IMPORT __declspec(dllimport)
34
+ #else
35
+ #define SHERPA_ONNX_EXPORT
36
+ #define SHERPA_ONNX_IMPORT
37
+ #endif
38
+ #else // WIN32
39
+ #define SHERPA_ONNX_EXPORT __attribute__((visibility("default")))
40
+
41
+ #define SHERPA_ONNX_IMPORT SHERPA_ONNX_EXPORT
42
+ #endif // WIN32
43
+
44
+ #if defined(SHERPA_ONNX_BUILD_MAIN_LIB)
45
+ #define SHERPA_ONNX_API SHERPA_ONNX_EXPORT
46
+ #else
47
+ #define SHERPA_ONNX_API SHERPA_ONNX_IMPORT
48
+ #endif
49
+
50
+ // Please don't free the returned pointer.
51
+ // Please don't modify the memory pointed by the returned pointer.
52
+ //
53
+ // The memory pointed by the returned pointer is statically allocated.
54
+ //
55
+ // Example return value: "1.12.1"
56
+ SHERPA_ONNX_API const char *SherpaOnnxGetVersionStr();
57
+
58
+ // Please don't free the returned pointer.
59
+ // Please don't modify the memory pointed by the returned pointer.
60
+ //
61
+ // The memory pointed by the returned pointer is statically allocated.
62
+ //
63
+ // Example return value: "6982b86c"
64
+ SHERPA_ONNX_API const char *SherpaOnnxGetGitSha1();
65
+
66
+ // Please don't free the returned pointer.
67
+ // Please don't modify the memory pointed by the returned pointer.
68
+ //
69
+ // The memory pointed by the returned pointer is statically allocated.
70
+ //
71
+ // Example return value: "Fri Jun 20 11:22:52 2025"
72
+ SHERPA_ONNX_API const char *SherpaOnnxGetGitDate();
73
+
74
+ // return 1 if the given file exists; return 0 otherwise
75
+ SHERPA_ONNX_API int32_t SherpaOnnxFileExists(const char *filename);
76
+
77
+ /// Please refer to
78
+ /// https://k2-fsa.github.io/sherpa/onnx/pretrained_models/index.html
79
+ /// to download pre-trained models. That is, you can find encoder-xxx.onnx
80
+ /// decoder-xxx.onnx, joiner-xxx.onnx, and tokens.txt for this struct
81
+ /// from there.
82
+ SHERPA_ONNX_API typedef struct SherpaOnnxOnlineTransducerModelConfig {
83
+ const char *encoder;
84
+ const char *decoder;
85
+ const char *joiner;
86
+ } SherpaOnnxOnlineTransducerModelConfig;
87
+
88
+ // please visit
89
+ // https://k2-fsa.github.io/sherpa/onnx/pretrained_models/online-paraformer/index.html
90
+ // to download pre-trained streaming paraformer models
91
+ SHERPA_ONNX_API typedef struct SherpaOnnxOnlineParaformerModelConfig {
92
+ const char *encoder;
93
+ const char *decoder;
94
+ } SherpaOnnxOnlineParaformerModelConfig;
95
+
96
+ // Please visit
97
+ // https://k2-fsa.github.io/sherpa/onnx/pretrained_models/online-ctc/zipformer-ctc-models.html#
98
+ // to download pre-trained streaming zipformer2 ctc models
99
+ SHERPA_ONNX_API typedef struct SherpaOnnxOnlineZipformer2CtcModelConfig {
100
+ const char *model;
101
+ } SherpaOnnxOnlineZipformer2CtcModelConfig;
102
+
103
+ SHERPA_ONNX_API typedef struct SherpaOnnxOnlineNemoCtcModelConfig {
104
+ const char *model;
105
+ } SherpaOnnxOnlineNemoCtcModelConfig;
106
+
107
+ SHERPA_ONNX_API typedef struct SherpaOnnxOnlineModelConfig {
108
+ SherpaOnnxOnlineTransducerModelConfig transducer;
109
+ SherpaOnnxOnlineParaformerModelConfig paraformer;
110
+ SherpaOnnxOnlineZipformer2CtcModelConfig zipformer2_ctc;
111
+ const char *tokens;
112
+ int32_t num_threads;
113
+ const char *provider;
114
+ int32_t debug; // true to print debug information of the model
115
+ const char *model_type;
116
+ // Valid values:
117
+ // - cjkchar
118
+ // - bpe
119
+ // - cjkchar+bpe
120
+ const char *modeling_unit;
121
+ const char *bpe_vocab;
122
+ /// if non-null, loading the tokens from the buffer instead of from the
123
+ /// "tokens" file
124
+ const char *tokens_buf;
125
+ /// byte size excluding the trailing '\0'
126
+ int32_t tokens_buf_size;
127
+ SherpaOnnxOnlineNemoCtcModelConfig nemo_ctc;
128
+ } SherpaOnnxOnlineModelConfig;
129
+
130
+ /// It expects 16 kHz 16-bit single channel wave format.
131
+ SHERPA_ONNX_API typedef struct SherpaOnnxFeatureConfig {
132
+ /// Sample rate of the input data. MUST match the one expected
133
+ /// by the model. For instance, it should be 16000 for models provided
134
+ /// by us.
135
+ int32_t sample_rate;
136
+
137
+ /// Feature dimension of the model.
138
+ /// For instance, it should be 80 for models provided by us.
139
+ int32_t feature_dim;
140
+ } SherpaOnnxFeatureConfig;
141
+
142
+ SHERPA_ONNX_API typedef struct SherpaOnnxOnlineCtcFstDecoderConfig {
143
+ const char *graph;
144
+ int32_t max_active;
145
+ } SherpaOnnxOnlineCtcFstDecoderConfig;
146
+
147
+ SHERPA_ONNX_API typedef struct SherpaOnnxHomophoneReplacerConfig {
148
+ const char *dict_dir;
149
+ const char *lexicon;
150
+ const char *rule_fsts;
151
+ } SherpaOnnxHomophoneReplacerConfig;
152
+
153
+ SHERPA_ONNX_API typedef struct SherpaOnnxOnlineRecognizerConfig {
154
+ SherpaOnnxFeatureConfig feat_config;
155
+ SherpaOnnxOnlineModelConfig model_config;
156
+
157
+ /// Possible values are: greedy_search, modified_beam_search
158
+ const char *decoding_method;
159
+
160
+ /// Used only when decoding_method is modified_beam_search
161
+ /// Example value: 4
162
+ int32_t max_active_paths;
163
+
164
+ /// 0 to disable endpoint detection.
165
+ /// A non-zero value to enable endpoint detection.
166
+ int32_t enable_endpoint;
167
+
168
+ /// An endpoint is detected if trailing silence in seconds is larger than
169
+ /// this value even if nothing has been decoded.
170
+ /// Used only when enable_endpoint is not 0.
171
+ float rule1_min_trailing_silence;
172
+
173
+ /// An endpoint is detected if trailing silence in seconds is larger than
174
+ /// this value after something that is not blank has been decoded.
175
+ /// Used only when enable_endpoint is not 0.
176
+ float rule2_min_trailing_silence;
177
+
178
+ /// An endpoint is detected if the utterance in seconds is larger than
179
+ /// this value.
180
+ /// Used only when enable_endpoint is not 0.
181
+ float rule3_min_utterance_length;
182
+
183
+ /// Path to the hotwords.
184
+ const char *hotwords_file;
185
+
186
+ /// Bonus score for each token in hotwords.
187
+ float hotwords_score;
188
+
189
+ SherpaOnnxOnlineCtcFstDecoderConfig ctc_fst_decoder_config;
190
+ const char *rule_fsts;
191
+ const char *rule_fars;
192
+ float blank_penalty;
193
+
194
+ /// if non-nullptr, loading the hotwords from the buffered string directly in
195
+ const char *hotwords_buf;
196
+ /// byte size excluding the tailing '\0'
197
+ int32_t hotwords_buf_size;
198
+ SherpaOnnxHomophoneReplacerConfig hr;
199
+ } SherpaOnnxOnlineRecognizerConfig;
200
+
201
+ SHERPA_ONNX_API typedef struct SherpaOnnxOnlineRecognizerResult {
202
+ // Recognized text
203
+ const char *text;
204
+
205
+ // Pointer to continuous memory which holds string based tokens
206
+ // which are separated by \0
207
+ const char *tokens;
208
+
209
+ // a pointer array containing the address of the first item in tokens
210
+ const char *const *tokens_arr;
211
+
212
+ // Pointer to continuous memory which holds timestamps
213
+ //
214
+ // Caution: If timestamp information is not available, this pointer is NULL.
215
+ // Please check whether it is NULL before you access it; otherwise, you would
216
+ // get segmentation fault.
217
+ float *timestamps;
218
+
219
+ // The number of tokens/timestamps in above pointer
220
+ int32_t count;
221
+
222
+ /** Return a json string.
223
+ *
224
+ * The returned string contains:
225
+ * {
226
+ * "text": "The recognition result",
227
+ * "tokens": [x, x, x],
228
+ * "timestamps": [x, x, x],
229
+ * "segment": x,
230
+ * "start_time": x,
231
+ * "is_final": true|false
232
+ * }
233
+ */
234
+ const char *json;
235
+ } SherpaOnnxOnlineRecognizerResult;
236
+
237
+ /// Note: OnlineRecognizer here means StreamingRecognizer.
238
+ /// It does not need to access the Internet during recognition.
239
+ /// Everything is run locally.
240
+ SHERPA_ONNX_API typedef struct SherpaOnnxOnlineRecognizer
241
+ SherpaOnnxOnlineRecognizer;
242
+ SHERPA_ONNX_API typedef struct SherpaOnnxOnlineStream SherpaOnnxOnlineStream;
243
+
244
+ /// @param config Config for the recognizer.
245
+ /// @return Return a pointer to the recognizer. The user has to invoke
246
+ // SherpaOnnxDestroyOnlineRecognizer() to free it to avoid memory leak.
247
+ SHERPA_ONNX_API const SherpaOnnxOnlineRecognizer *
248
+ SherpaOnnxCreateOnlineRecognizer(
249
+ const SherpaOnnxOnlineRecognizerConfig *config);
250
+
251
+ /// Free a pointer returned by SherpaOnnxCreateOnlineRecognizer()
252
+ ///
253
+ /// @param p A pointer returned by SherpaOnnxCreateOnlineRecognizer()
254
+ SHERPA_ONNX_API void SherpaOnnxDestroyOnlineRecognizer(
255
+ const SherpaOnnxOnlineRecognizer *recognizer);
256
+
257
+ /// Create an online stream for accepting wave samples.
258
+ ///
259
+ /// @param recognizer A pointer returned by SherpaOnnxCreateOnlineRecognizer()
260
+ /// @return Return a pointer to an OnlineStream. The user has to invoke
261
+ /// SherpaOnnxDestroyOnlineStream() to free it to avoid memory leak.
262
+ SHERPA_ONNX_API const SherpaOnnxOnlineStream *SherpaOnnxCreateOnlineStream(
263
+ const SherpaOnnxOnlineRecognizer *recognizer);
264
+
265
+ /// Create an online stream for accepting wave samples with the specified hot
266
+ /// words.
267
+ ///
268
+ /// @param recognizer A pointer returned by SherpaOnnxCreateOnlineRecognizer()
269
+ /// @return Return a pointer to an OnlineStream. The user has to invoke
270
+ /// SherpaOnnxDestroyOnlineStream() to free it to avoid memory leak.
271
+ SHERPA_ONNX_API const SherpaOnnxOnlineStream *
272
+ SherpaOnnxCreateOnlineStreamWithHotwords(
273
+ const SherpaOnnxOnlineRecognizer *recognizer, const char *hotwords);
274
+
275
+ /// Destroy an online stream.
276
+ ///
277
+ /// @param stream A pointer returned by SherpaOnnxCreateOnlineStream()
278
+ SHERPA_ONNX_API void SherpaOnnxDestroyOnlineStream(
279
+ const SherpaOnnxOnlineStream *stream);
280
+
281
+ /// Accept input audio samples and compute the features.
282
+ /// The user has to invoke SherpaOnnxDecodeOnlineStream() to run the neural
283
+ /// network and decoding.
284
+ ///
285
+ /// @param stream A pointer returned by SherpaOnnxCreateOnlineStream().
286
+ /// @param sample_rate Sample rate of the input samples. If it is different
287
+ /// from config.feat_config.sample_rate, we will do
288
+ /// resampling inside sherpa-onnx.
289
+ /// @param samples A pointer to a 1-D array containing audio samples.
290
+ /// The range of samples has to be normalized to [-1, 1].
291
+ /// @param n Number of elements in the samples array.
292
+ SHERPA_ONNX_API void SherpaOnnxOnlineStreamAcceptWaveform(
293
+ const SherpaOnnxOnlineStream *stream, int32_t sample_rate,
294
+ const float *samples, int32_t n);
295
+
296
+ /// Return 1 if there are enough number of feature frames for decoding.
297
+ /// Return 0 otherwise.
298
+ ///
299
+ /// @param recognizer A pointer returned by SherpaOnnxCreateOnlineRecognizer
300
+ /// @param stream A pointer returned by SherpaOnnxCreateOnlineStream
301
+ SHERPA_ONNX_API int32_t
302
+ SherpaOnnxIsOnlineStreamReady(const SherpaOnnxOnlineRecognizer *recognizer,
303
+ const SherpaOnnxOnlineStream *stream);
304
+
305
+ /// Call this function to run the neural network model and decoding.
306
+ //
307
+ /// Precondition for this function: SherpaOnnxIsOnlineStreamReady() MUST
308
+ /// return 1.
309
+ ///
310
+ /// Usage example:
311
+ ///
312
+ /// while (SherpaOnnxIsOnlineStreamReady(recognizer, stream)) {
313
+ /// SherpaOnnxDecodeOnlineStream(recognizer, stream);
314
+ /// }
315
+ ///
316
+ SHERPA_ONNX_API void SherpaOnnxDecodeOnlineStream(
317
+ const SherpaOnnxOnlineRecognizer *recognizer,
318
+ const SherpaOnnxOnlineStream *stream);
319
+
320
+ /// This function is similar to SherpaOnnxDecodeOnlineStream(). It decodes
321
+ /// multiple OnlineStream in parallel.
322
+ ///
323
+ /// Caution: The caller has to ensure each OnlineStream is ready, i.e.,
324
+ /// SherpaOnnxIsOnlineStreamReady() for that stream should return 1.
325
+ ///
326
+ /// @param recognizer A pointer returned by SherpaOnnxCreateOnlineRecognizer()
327
+ /// @param streams A pointer array containing pointers returned by
328
+ /// SherpaOnnxCreateOnlineRecognizer()
329
+ /// @param n Number of elements in the given streams array.
330
+ SHERPA_ONNX_API void SherpaOnnxDecodeMultipleOnlineStreams(
331
+ const SherpaOnnxOnlineRecognizer *recognizer,
332
+ const SherpaOnnxOnlineStream **streams, int32_t n);
333
+
334
+ /// Get the decoding results so far for an OnlineStream.
335
+ ///
336
+ /// @param recognizer A pointer returned by SherpaOnnxCreateOnlineRecognizer().
337
+ /// @param stream A pointer returned by SherpaOnnxCreateOnlineStream().
338
+ /// @return A pointer containing the result. The user has to invoke
339
+ /// SherpaOnnxDestroyOnlineRecognizerResult() to free the returned
340
+ /// pointer to avoid memory leak.
341
+ SHERPA_ONNX_API const SherpaOnnxOnlineRecognizerResult *
342
+ SherpaOnnxGetOnlineStreamResult(const SherpaOnnxOnlineRecognizer *recognizer,
343
+ const SherpaOnnxOnlineStream *stream);
344
+
345
+ /// Destroy the pointer returned by SherpaOnnxGetOnlineStreamResult().
346
+ ///
347
+ /// @param r A pointer returned by SherpaOnnxGetOnlineStreamResult()
348
+ SHERPA_ONNX_API void SherpaOnnxDestroyOnlineRecognizerResult(
349
+ const SherpaOnnxOnlineRecognizerResult *r);
350
+
351
+ /// Return the result as a json string.
352
+ /// The user has to invoke
353
+ /// SherpaOnnxDestroyOnlineStreamResultJson()
354
+ /// to free the returned pointer to avoid memory leak
355
+ SHERPA_ONNX_API const char *SherpaOnnxGetOnlineStreamResultAsJson(
356
+ const SherpaOnnxOnlineRecognizer *recognizer,
357
+ const SherpaOnnxOnlineStream *stream);
358
+
359
+ SHERPA_ONNX_API void SherpaOnnxDestroyOnlineStreamResultJson(const char *s);
360
+
361
+ /// SherpaOnnxOnlineStreamReset an OnlineStream , which clears the neural
362
+ /// network model state and the state for decoding.
363
+ ///
364
+ /// @param recognizer A pointer returned by SherpaOnnxCreateOnlineRecognizer().
365
+ /// @param stream A pointer returned by SherpaOnnxCreateOnlineStream
366
+ SHERPA_ONNX_API void SherpaOnnxOnlineStreamReset(
367
+ const SherpaOnnxOnlineRecognizer *recognizer,
368
+ const SherpaOnnxOnlineStream *stream);
369
+
370
+ /// Signal that no more audio samples would be available.
371
+ /// After this call, you cannot call SherpaOnnxOnlineStreamAcceptWaveform() any
372
+ /// more.
373
+ ///
374
+ /// @param stream A pointer returned by SherpaOnnxCreateOnlineStream()
375
+ SHERPA_ONNX_API void SherpaOnnxOnlineStreamInputFinished(
376
+ const SherpaOnnxOnlineStream *stream);
377
+
378
+ /// Return 1 if an endpoint has been detected.
379
+ ///
380
+ /// @param recognizer A pointer returned by SherpaOnnxCreateOnlineRecognizer()
381
+ /// @param stream A pointer returned by SherpaOnnxCreateOnlineStream()
382
+ /// @return Return 1 if an endpoint is detected. Return 0 otherwise.
383
+ SHERPA_ONNX_API int32_t
384
+ SherpaOnnxOnlineStreamIsEndpoint(const SherpaOnnxOnlineRecognizer *recognizer,
385
+ const SherpaOnnxOnlineStream *stream);
386
+
387
+ // for displaying results on Linux/macOS.
388
+ SHERPA_ONNX_API typedef struct SherpaOnnxDisplay SherpaOnnxDisplay;
389
+
390
+ /// Create a display object. Must be freed using SherpaOnnxDestroyDisplay to
391
+ /// avoid memory leak.
392
+ SHERPA_ONNX_API const SherpaOnnxDisplay *SherpaOnnxCreateDisplay(
393
+ int32_t max_word_per_line);
394
+
395
+ SHERPA_ONNX_API void SherpaOnnxDestroyDisplay(const SherpaOnnxDisplay *display);
396
+
397
+ /// Print the result.
398
+ SHERPA_ONNX_API void SherpaOnnxPrint(const SherpaOnnxDisplay *display,
399
+ int32_t idx, const char *s);
400
+ // ============================================================
401
+ // For offline ASR (i.e., non-streaming ASR)
402
+ // ============================================================
403
+
404
+ /// Please refer to
405
+ /// https://k2-fsa.github.io/sherpa/onnx/pretrained_models/index.html
406
+ /// to download pre-trained models. That is, you can find encoder-xxx.onnx
407
+ /// decoder-xxx.onnx, and joiner-xxx.onnx for this struct
408
+ /// from there.
409
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineTransducerModelConfig {
410
+ const char *encoder;
411
+ const char *decoder;
412
+ const char *joiner;
413
+ } SherpaOnnxOfflineTransducerModelConfig;
414
+
415
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineParaformerModelConfig {
416
+ const char *model;
417
+ } SherpaOnnxOfflineParaformerModelConfig;
418
+
419
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineNemoEncDecCtcModelConfig {
420
+ const char *model;
421
+ } SherpaOnnxOfflineNemoEncDecCtcModelConfig;
422
+
423
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineWhisperModelConfig {
424
+ const char *encoder;
425
+ const char *decoder;
426
+ const char *language;
427
+ const char *task;
428
+ int32_t tail_paddings;
429
+ } SherpaOnnxOfflineWhisperModelConfig;
430
+
431
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineCanaryModelConfig {
432
+ const char *encoder;
433
+ const char *decoder;
434
+ const char *src_lang;
435
+ const char *tgt_lang;
436
+ int32_t use_pnc;
437
+ } SherpaOnnxOfflineCanaryModelConfig;
438
+
439
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineFireRedAsrModelConfig {
440
+ const char *encoder;
441
+ const char *decoder;
442
+ } SherpaOnnxOfflineFireRedAsrModelConfig;
443
+
444
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineMoonshineModelConfig {
445
+ const char *preprocessor;
446
+ const char *encoder;
447
+ const char *uncached_decoder;
448
+ const char *cached_decoder;
449
+ } SherpaOnnxOfflineMoonshineModelConfig;
450
+
451
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineTdnnModelConfig {
452
+ const char *model;
453
+ } SherpaOnnxOfflineTdnnModelConfig;
454
+
455
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineLMConfig {
456
+ const char *model;
457
+ float scale;
458
+ } SherpaOnnxOfflineLMConfig;
459
+
460
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineSenseVoiceModelConfig {
461
+ const char *model;
462
+ const char *language;
463
+ int32_t use_itn;
464
+ } SherpaOnnxOfflineSenseVoiceModelConfig;
465
+
466
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineDolphinModelConfig {
467
+ const char *model;
468
+ } SherpaOnnxOfflineDolphinModelConfig;
469
+
470
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineZipformerCtcModelConfig {
471
+ const char *model;
472
+ } SherpaOnnxOfflineZipformerCtcModelConfig;
473
+
474
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineModelConfig {
475
+ SherpaOnnxOfflineTransducerModelConfig transducer;
476
+ SherpaOnnxOfflineParaformerModelConfig paraformer;
477
+ SherpaOnnxOfflineNemoEncDecCtcModelConfig nemo_ctc;
478
+ SherpaOnnxOfflineWhisperModelConfig whisper;
479
+ SherpaOnnxOfflineTdnnModelConfig tdnn;
480
+
481
+ const char *tokens;
482
+ int32_t num_threads;
483
+ int32_t debug;
484
+ const char *provider;
485
+ const char *model_type;
486
+ // Valid values:
487
+ // - cjkchar
488
+ // - bpe
489
+ // - cjkchar+bpe
490
+ const char *modeling_unit;
491
+ const char *bpe_vocab;
492
+ const char *telespeech_ctc;
493
+ SherpaOnnxOfflineSenseVoiceModelConfig sense_voice;
494
+ SherpaOnnxOfflineMoonshineModelConfig moonshine;
495
+ SherpaOnnxOfflineFireRedAsrModelConfig fire_red_asr;
496
+ SherpaOnnxOfflineDolphinModelConfig dolphin;
497
+ SherpaOnnxOfflineZipformerCtcModelConfig zipformer_ctc;
498
+ SherpaOnnxOfflineCanaryModelConfig canary;
499
+ } SherpaOnnxOfflineModelConfig;
500
+
501
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineRecognizerConfig {
502
+ SherpaOnnxFeatureConfig feat_config;
503
+ SherpaOnnxOfflineModelConfig model_config;
504
+ SherpaOnnxOfflineLMConfig lm_config;
505
+
506
+ const char *decoding_method;
507
+ int32_t max_active_paths;
508
+
509
+ /// Path to the hotwords.
510
+ const char *hotwords_file;
511
+
512
+ /// Bonus score for each token in hotwords.
513
+ float hotwords_score;
514
+ const char *rule_fsts;
515
+ const char *rule_fars;
516
+ float blank_penalty;
517
+
518
+ SherpaOnnxHomophoneReplacerConfig hr;
519
+ } SherpaOnnxOfflineRecognizerConfig;
520
+
521
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineRecognizer
522
+ SherpaOnnxOfflineRecognizer;
523
+
524
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineStream SherpaOnnxOfflineStream;
525
+
526
+ /// @param config Config for the recognizer.
527
+ /// @return Return a pointer to the recognizer. The user has to invoke
528
+ // SherpaOnnxDestroyOfflineRecognizer() to free it to avoid memory
529
+ // leak.
530
+ SHERPA_ONNX_API const SherpaOnnxOfflineRecognizer *
531
+ SherpaOnnxCreateOfflineRecognizer(
532
+ const SherpaOnnxOfflineRecognizerConfig *config);
533
+
534
+ /// @param config Config for the recognizer.
535
+ SHERPA_ONNX_API void SherpaOnnxOfflineRecognizerSetConfig(
536
+ const SherpaOnnxOfflineRecognizer *recognizer,
537
+ const SherpaOnnxOfflineRecognizerConfig *config);
538
+
539
+ /// Free a pointer returned by SherpaOnnxCreateOfflineRecognizer()
540
+ ///
541
+ /// @param p A pointer returned by SherpaOnnxCreateOfflineRecognizer()
542
+ SHERPA_ONNX_API void SherpaOnnxDestroyOfflineRecognizer(
543
+ const SherpaOnnxOfflineRecognizer *recognizer);
544
+
545
+ /// Create an offline stream for accepting wave samples.
546
+ ///
547
+ /// @param recognizer A pointer returned by SherpaOnnxCreateOfflineRecognizer()
548
+ /// @return Return a pointer to an OfflineStream. The user has to invoke
549
+ /// SherpaOnnxDestroyOfflineStream() to free it to avoid memory leak.
550
+ SHERPA_ONNX_API const SherpaOnnxOfflineStream *SherpaOnnxCreateOfflineStream(
551
+ const SherpaOnnxOfflineRecognizer *recognizer);
552
+
553
+ /// Create an offline stream for accepting wave samples with the specified hot
554
+ /// words.
555
+ ///
556
+ /// @param recognizer A pointer returned by SherpaOnnxCreateOfflineRecognizer()
557
+ /// @return Return a pointer to an OfflineStream. The user has to invoke
558
+ /// SherpaOnnxDestroyOfflineStream() to free it to avoid memory leak.
559
+ SHERPA_ONNX_API const SherpaOnnxOfflineStream *
560
+ SherpaOnnxCreateOfflineStreamWithHotwords(
561
+ const SherpaOnnxOfflineRecognizer *recognizer, const char *hotwords);
562
+
563
+ /// Destroy an offline stream.
564
+ ///
565
+ /// @param stream A pointer returned by SherpaOnnxCreateOfflineStream()
566
+ SHERPA_ONNX_API void SherpaOnnxDestroyOfflineStream(
567
+ const SherpaOnnxOfflineStream *stream);
568
+
569
+ /// Accept input audio samples and compute the features.
570
+ /// The user has to invoke SherpaOnnxDecodeOfflineStream() to run the neural
571
+ /// network and decoding.
572
+ ///
573
+ /// @param stream A pointer returned by SherpaOnnxCreateOfflineStream().
574
+ /// @param sample_rate Sample rate of the input samples. If it is different
575
+ /// from config.feat_config.sample_rate, we will do
576
+ /// resampling inside sherpa-onnx.
577
+ /// @param samples A pointer to a 1-D array containing audio samples.
578
+ /// The range of samples has to be normalized to [-1, 1].
579
+ /// @param n Number of elements in the samples array.
580
+ ///
581
+ /// @caution: For each offline stream, please invoke this function only once!
582
+ SHERPA_ONNX_API void SherpaOnnxAcceptWaveformOffline(
583
+ const SherpaOnnxOfflineStream *stream, int32_t sample_rate,
584
+ const float *samples, int32_t n);
585
+ /// Decode an offline stream.
586
+ ///
587
+ /// We assume you have invoked SherpaOnnxAcceptWaveformOffline() for the given
588
+ /// stream before calling this function.
589
+ ///
590
+ /// @param recognizer A pointer returned by SherpaOnnxCreateOfflineRecognizer().
591
+ /// @param stream A pointer returned by SherpaOnnxCreateOfflineStream()
592
+ SHERPA_ONNX_API void SherpaOnnxDecodeOfflineStream(
593
+ const SherpaOnnxOfflineRecognizer *recognizer,
594
+ const SherpaOnnxOfflineStream *stream);
595
+
596
+ /// Decode a list offline streams in parallel.
597
+ ///
598
+ /// We assume you have invoked SherpaOnnxAcceptWaveformOffline() for each stream
599
+ /// before calling this function.
600
+ ///
601
+ /// @param recognizer A pointer returned by SherpaOnnxCreateOfflineRecognizer().
602
+ /// @param streams A pointer pointer array containing pointers returned
603
+ /// by SherpaOnnxCreateOfflineStream().
604
+ /// @param n Number of entries in the given streams.
605
+ SHERPA_ONNX_API void SherpaOnnxDecodeMultipleOfflineStreams(
606
+ const SherpaOnnxOfflineRecognizer *recognizer,
607
+ const SherpaOnnxOfflineStream **streams, int32_t n);
608
+
609
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineRecognizerResult {
610
+ const char *text;
611
+
612
+ // Pointer to continuous memory which holds timestamps
613
+ //
614
+ // It is NULL if the model does not support timestamps
615
+ float *timestamps;
616
+
617
+ // number of entries in timestamps
618
+ int32_t count;
619
+
620
+ // Pointer to continuous memory which holds string based tokens
621
+ // which are separated by \0
622
+ const char *tokens;
623
+
624
+ // a pointer array containing the address of the first item in tokens
625
+ const char *const *tokens_arr;
626
+
627
+ /** Return a json string.
628
+ *
629
+ * The returned string contains:
630
+ * {
631
+ * "text": "The recognition result",
632
+ * "tokens": [x, x, x],
633
+ * "timestamps": [x, x, x],
634
+ * "segment": x,
635
+ * "start_time": x,
636
+ * "is_final": true|false
637
+ * }
638
+ */
639
+ const char *json;
640
+
641
+ // return recognized language
642
+ const char *lang;
643
+
644
+ // return emotion.
645
+ const char *emotion;
646
+
647
+ // return event.
648
+ const char *event;
649
+ } SherpaOnnxOfflineRecognizerResult;
650
+
651
+ /// Get the result of the offline stream.
652
+ ///
653
+ /// We assume you have called SherpaOnnxDecodeOfflineStream() or
654
+ /// SherpaOnnxDecodeMultipleOfflineStreams() with the given stream before
655
+ /// calling this function.
656
+ ///
657
+ /// @param stream A pointer returned by SherpaOnnxCreateOfflineStream().
658
+ /// @return Return a pointer to the result. The user has to invoke
659
+ /// SherpaOnnxDestroyOnlineRecognizerResult() to free the returned
660
+ /// pointer to avoid memory leak.
661
+ SHERPA_ONNX_API const SherpaOnnxOfflineRecognizerResult *
662
+ SherpaOnnxGetOfflineStreamResult(const SherpaOnnxOfflineStream *stream);
663
+
664
+ /// Destroy the pointer returned by SherpaOnnxGetOfflineStreamResult().
665
+ ///
666
+ /// @param r A pointer returned by SherpaOnnxGetOfflineStreamResult()
667
+ SHERPA_ONNX_API void SherpaOnnxDestroyOfflineRecognizerResult(
668
+ const SherpaOnnxOfflineRecognizerResult *r);
669
+
670
+ /// Return the result as a json string.
671
+ /// The user has to use SherpaOnnxDestroyOfflineStreamResultJson()
672
+ /// to free the returned pointer to avoid memory leak
673
+ SHERPA_ONNX_API const char *SherpaOnnxGetOfflineStreamResultAsJson(
674
+ const SherpaOnnxOfflineStream *stream);
675
+
676
+ SHERPA_ONNX_API void SherpaOnnxDestroyOfflineStreamResultJson(const char *s);
677
+
678
+ // ============================================================
679
+ // For Keyword Spotter
680
+ // ============================================================
681
+ SHERPA_ONNX_API typedef struct SherpaOnnxKeywordResult {
682
+ /// The triggered keyword.
683
+ /// For English, it consists of space separated words.
684
+ /// For Chinese, it consists of Chinese words without spaces.
685
+ /// Example 1: "hello world"
686
+ /// Example 2: "你好世界"
687
+ const char *keyword;
688
+
689
+ /// Decoded results at the token level.
690
+ /// For instance, for BPE-based models it consists of a list of BPE tokens.
691
+ const char *tokens;
692
+
693
+ const char *const *tokens_arr;
694
+
695
+ int32_t count;
696
+
697
+ /// timestamps.size() == tokens.size()
698
+ /// timestamps[i] records the time in seconds when tokens[i] is decoded.
699
+ float *timestamps;
700
+
701
+ /// Starting time of this segment.
702
+ /// When an endpoint is detected, it will change
703
+ float start_time;
704
+
705
+ /** Return a json string.
706
+ *
707
+ * The returned string contains:
708
+ * {
709
+ * "keyword": "The triggered keyword",
710
+ * "tokens": [x, x, x],
711
+ * "timestamps": [x, x, x],
712
+ * "start_time": x,
713
+ * }
714
+ */
715
+ const char *json;
716
+ } SherpaOnnxKeywordResult;
717
+
718
+ SHERPA_ONNX_API typedef struct SherpaOnnxKeywordSpotterConfig {
719
+ SherpaOnnxFeatureConfig feat_config;
720
+ SherpaOnnxOnlineModelConfig model_config;
721
+ int32_t max_active_paths;
722
+ int32_t num_trailing_blanks;
723
+ float keywords_score;
724
+ float keywords_threshold;
725
+ const char *keywords_file;
726
+ /// if non-null, loading the keywords from the buffer instead of from the
727
+ /// keywords_file
728
+ const char *keywords_buf;
729
+ /// byte size excluding the trailing '\0'
730
+ int32_t keywords_buf_size;
731
+ } SherpaOnnxKeywordSpotterConfig;
732
+
733
+ SHERPA_ONNX_API typedef struct SherpaOnnxKeywordSpotter
734
+ SherpaOnnxKeywordSpotter;
735
+
736
+ /// @param config Config for the keyword spotter.
737
+ /// @return Return a pointer to the spotter. The user has to invoke
738
+ /// SherpaOnnxDestroyKeywordSpotter() to free it to avoid memory leak.
739
+ SHERPA_ONNX_API const SherpaOnnxKeywordSpotter *SherpaOnnxCreateKeywordSpotter(
740
+ const SherpaOnnxKeywordSpotterConfig *config);
741
+
742
+ /// Free a pointer returned by SherpaOnnxCreateKeywordSpotter()
743
+ ///
744
+ /// @param p A pointer returned by SherpaOnnxCreateKeywordSpotter()
745
+ SHERPA_ONNX_API void SherpaOnnxDestroyKeywordSpotter(
746
+ const SherpaOnnxKeywordSpotter *spotter);
747
+
748
+ /// Create an online stream for accepting wave samples.
749
+ ///
750
+ /// @param spotter A pointer returned by SherpaOnnxCreateKeywordSpotter()
751
+ /// @return Return a pointer to an OnlineStream. The user has to invoke
752
+ /// SherpaOnnxDestroyOnlineStream() to free it to avoid memory leak.
753
+ SHERPA_ONNX_API const SherpaOnnxOnlineStream *SherpaOnnxCreateKeywordStream(
754
+ const SherpaOnnxKeywordSpotter *spotter);
755
+
756
+ /// Create an online stream for accepting wave samples with the specified hot
757
+ /// words.
758
+ ///
759
+ /// @param spotter A pointer returned by SherpaOnnxCreateKeywordSpotter()
760
+ /// @param keywords A pointer points to the keywords that you set
761
+ /// @return Return a pointer to an OnlineStream. The user has to invoke
762
+ /// SherpaOnnxDestroyOnlineStream() to free it to avoid memory leak.
763
+ SHERPA_ONNX_API const SherpaOnnxOnlineStream *
764
+ SherpaOnnxCreateKeywordStreamWithKeywords(
765
+ const SherpaOnnxKeywordSpotter *spotter, const char *keywords);
766
+
767
+ /// Return 1 if there are enough number of feature frames for decoding.
768
+ /// Return 0 otherwise.
769
+ ///
770
+ /// @param spotter A pointer returned by SherpaOnnxCreateKeywordSpotter
771
+ /// @param stream A pointer returned by SherpaOnnxCreateKeywordStream
772
+ SHERPA_ONNX_API int32_t
773
+ SherpaOnnxIsKeywordStreamReady(const SherpaOnnxKeywordSpotter *spotter,
774
+ const SherpaOnnxOnlineStream *stream);
775
+
776
+ /// Call this function to run the neural network model and decoding.
777
+ //
778
+ /// Precondition for this function: SherpaOnnxIsKeywordStreamReady() MUST
779
+ /// return 1.
780
+ SHERPA_ONNX_API void SherpaOnnxDecodeKeywordStream(
781
+ const SherpaOnnxKeywordSpotter *spotter,
782
+ const SherpaOnnxOnlineStream *stream);
783
+
784
+ /// Please call it right after a keyword is detected
785
+ SHERPA_ONNX_API void SherpaOnnxResetKeywordStream(
786
+ const SherpaOnnxKeywordSpotter *spotter,
787
+ const SherpaOnnxOnlineStream *stream);
788
+
789
+ /// This function is similar to SherpaOnnxDecodeKeywordStream(). It decodes
790
+ /// multiple OnlineStream in parallel.
791
+ ///
792
+ /// Caution: The caller has to ensure each OnlineStream is ready, i.e.,
793
+ /// SherpaOnnxIsKeywordStreamReady() for that stream should return 1.
794
+ ///
795
+ /// @param spotter A pointer returned by SherpaOnnxCreateKeywordSpotter()
796
+ /// @param streams A pointer array containing pointers returned by
797
+ /// SherpaOnnxCreateKeywordStream()
798
+ /// @param n Number of elements in the given streams array.
799
+ SHERPA_ONNX_API void SherpaOnnxDecodeMultipleKeywordStreams(
800
+ const SherpaOnnxKeywordSpotter *spotter,
801
+ const SherpaOnnxOnlineStream **streams, int32_t n);
802
+
803
+ /// Get the decoding results so far for an OnlineStream.
804
+ ///
805
+ /// @param spotter A pointer returned by SherpaOnnxCreateKeywordSpotter().
806
+ /// @param stream A pointer returned by SherpaOnnxCreateKeywordStream().
807
+ /// @return A pointer containing the result. The user has to invoke
808
+ /// SherpaOnnxDestroyKeywordResult() to free the returned pointer to
809
+ /// avoid memory leak.
810
+ SHERPA_ONNX_API const SherpaOnnxKeywordResult *SherpaOnnxGetKeywordResult(
811
+ const SherpaOnnxKeywordSpotter *spotter,
812
+ const SherpaOnnxOnlineStream *stream);
813
+
814
+ /// Destroy the pointer returned by SherpaOnnxGetKeywordResult().
815
+ ///
816
+ /// @param r A pointer returned by SherpaOnnxGetKeywordResult()
817
+ SHERPA_ONNX_API void SherpaOnnxDestroyKeywordResult(
818
+ const SherpaOnnxKeywordResult *r);
819
+
820
+ // the user has to call SherpaOnnxFreeKeywordResultJson() to free the returned
821
+ // pointer to avoid memory leak
822
+ SHERPA_ONNX_API const char *SherpaOnnxGetKeywordResultAsJson(
823
+ const SherpaOnnxKeywordSpotter *spotter,
824
+ const SherpaOnnxOnlineStream *stream);
825
+
826
+ SHERPA_ONNX_API void SherpaOnnxFreeKeywordResultJson(const char *s);
827
+
828
+ // ============================================================
829
+ // For VAD
830
+ // ============================================================
831
+
832
+ SHERPA_ONNX_API typedef struct SherpaOnnxSileroVadModelConfig {
833
+ // Path to the silero VAD model
834
+ const char *model;
835
+
836
+ // threshold to classify a segment as speech
837
+ //
838
+ // If the predicted probability of a segment is larger than this
839
+ // value, then it is classified as speech.
840
+ float threshold;
841
+
842
+ // in seconds
843
+ float min_silence_duration;
844
+
845
+ // in seconds
846
+ float min_speech_duration;
847
+
848
+ int32_t window_size;
849
+
850
+ // If a speech segment is longer than this value, then we increase
851
+ // the threshold to 0.9. After finishing detecting the segment,
852
+ // the threshold value is reset to its original value.
853
+ float max_speech_duration;
854
+ } SherpaOnnxSileroVadModelConfig;
855
+
856
+ SHERPA_ONNX_API typedef struct SherpaOnnxTenVadModelConfig {
857
+ // Path to the ten-vad model
858
+ const char *model;
859
+
860
+ // threshold to classify a segment as speech
861
+ //
862
+ // If the predicted probability of a segment is larger than this
863
+ // value, then it is classified as speech.
864
+ float threshold;
865
+
866
+ // in seconds
867
+ float min_silence_duration;
868
+
869
+ // in seconds
870
+ float min_speech_duration;
871
+
872
+ int32_t window_size;
873
+
874
+ // If a speech segment is longer than this value, then we increase
875
+ // the threshold to 0.9. After finishing detecting the segment,
876
+ // the threshold value is reset to its original value.
877
+ float max_speech_duration;
878
+ } SherpaOnnxTenVadModelConfig;
879
+
880
+ SHERPA_ONNX_API typedef struct SherpaOnnxVadModelConfig {
881
+ SherpaOnnxSileroVadModelConfig silero_vad;
882
+
883
+ int32_t sample_rate;
884
+ int32_t num_threads;
885
+ const char *provider;
886
+ int32_t debug;
887
+ SherpaOnnxTenVadModelConfig ten_vad;
888
+ } SherpaOnnxVadModelConfig;
889
+
890
+ SHERPA_ONNX_API typedef struct SherpaOnnxCircularBuffer
891
+ SherpaOnnxCircularBuffer;
892
+
893
+ // Return an instance of circular buffer. The user has to use
894
+ // SherpaOnnxDestroyCircularBuffer() to free the returned pointer to avoid
895
+ // memory leak.
896
+ SHERPA_ONNX_API const SherpaOnnxCircularBuffer *SherpaOnnxCreateCircularBuffer(
897
+ int32_t capacity);
898
+
899
+ // Free the pointer returned by SherpaOnnxCreateCircularBuffer()
900
+ SHERPA_ONNX_API void SherpaOnnxDestroyCircularBuffer(
901
+ const SherpaOnnxCircularBuffer *buffer);
902
+
903
+ SHERPA_ONNX_API void SherpaOnnxCircularBufferPush(
904
+ const SherpaOnnxCircularBuffer *buffer, const float *p, int32_t n);
905
+
906
+ // Return n samples starting at the given index.
907
+ //
908
+ // Return a pointer to an array containing n samples starting at start_index.
909
+ // The user has to use SherpaOnnxCircularBufferFree() to free the returned
910
+ // pointer to avoid memory leak.
911
+ SHERPA_ONNX_API const float *SherpaOnnxCircularBufferGet(
912
+ const SherpaOnnxCircularBuffer *buffer, int32_t start_index, int32_t n);
913
+
914
+ // Free the pointer returned by SherpaOnnxCircularBufferGet().
915
+ SHERPA_ONNX_API void SherpaOnnxCircularBufferFree(const float *p);
916
+
917
+ // Remove n elements from the buffer
918
+ SHERPA_ONNX_API void SherpaOnnxCircularBufferPop(
919
+ const SherpaOnnxCircularBuffer *buffer, int32_t n);
920
+
921
+ // Return number of elements in the buffer.
922
+ SHERPA_ONNX_API int32_t
923
+ SherpaOnnxCircularBufferSize(const SherpaOnnxCircularBuffer *buffer);
924
+
925
+ // Return the head of the buffer. It's always non-decreasing until you
926
+ // invoke SherpaOnnxCircularBufferReset() which resets head to 0.
927
+ SHERPA_ONNX_API int32_t
928
+ SherpaOnnxCircularBufferHead(const SherpaOnnxCircularBuffer *buffer);
929
+
930
+ // Clear all elements in the buffer
931
+ SHERPA_ONNX_API void SherpaOnnxCircularBufferReset(
932
+ const SherpaOnnxCircularBuffer *buffer);
933
+
934
+ SHERPA_ONNX_API typedef struct SherpaOnnxSpeechSegment {
935
+ // The start index in samples of this segment
936
+ int32_t start;
937
+
938
+ // pointer to the array containing the samples
939
+ float *samples;
940
+
941
+ // number of samples in this segment
942
+ int32_t n;
943
+ } SherpaOnnxSpeechSegment;
944
+
945
+ typedef struct SherpaOnnxVoiceActivityDetector SherpaOnnxVoiceActivityDetector;
946
+
947
+ // Return an instance of VoiceActivityDetector.
948
+ // The user has to use SherpaOnnxDestroyVoiceActivityDetector() to free
949
+ // the returned pointer to avoid memory leak.
950
+ SHERPA_ONNX_API const SherpaOnnxVoiceActivityDetector *
951
+ SherpaOnnxCreateVoiceActivityDetector(const SherpaOnnxVadModelConfig *config,
952
+ float buffer_size_in_seconds);
953
+
954
+ SHERPA_ONNX_API void SherpaOnnxDestroyVoiceActivityDetector(
955
+ const SherpaOnnxVoiceActivityDetector *p);
956
+
957
+ SHERPA_ONNX_API void SherpaOnnxVoiceActivityDetectorAcceptWaveform(
958
+ const SherpaOnnxVoiceActivityDetector *p, const float *samples, int32_t n);
959
+
960
+ // Return 1 if there are no speech segments available.
961
+ // Return 0 if there are speech segments.
962
+ SHERPA_ONNX_API int32_t
963
+ SherpaOnnxVoiceActivityDetectorEmpty(const SherpaOnnxVoiceActivityDetector *p);
964
+
965
+ // Return 1 if there is voice detected.
966
+ // Return 0 if voice is silent.
967
+ SHERPA_ONNX_API int32_t SherpaOnnxVoiceActivityDetectorDetected(
968
+ const SherpaOnnxVoiceActivityDetector *p);
969
+
970
+ // Return the first speech segment.
971
+ // It throws if SherpaOnnxVoiceActivityDetectorEmpty() returns 1.
972
+ SHERPA_ONNX_API void SherpaOnnxVoiceActivityDetectorPop(
973
+ const SherpaOnnxVoiceActivityDetector *p);
974
+
975
+ // Clear current speech segments.
976
+ SHERPA_ONNX_API void SherpaOnnxVoiceActivityDetectorClear(
977
+ const SherpaOnnxVoiceActivityDetector *p);
978
+
979
+ // Return the first speech segment.
980
+ // The user has to use SherpaOnnxDestroySpeechSegment() to free the returned
981
+ // pointer to avoid memory leak.
982
+ SHERPA_ONNX_API const SherpaOnnxSpeechSegment *
983
+ SherpaOnnxVoiceActivityDetectorFront(const SherpaOnnxVoiceActivityDetector *p);
984
+
985
+ // Free the pointer returned SherpaOnnxVoiceActivityDetectorFront().
986
+ SHERPA_ONNX_API void SherpaOnnxDestroySpeechSegment(
987
+ const SherpaOnnxSpeechSegment *p);
988
+
989
+ // Re-initialize the voice activity detector.
990
+ SHERPA_ONNX_API void SherpaOnnxVoiceActivityDetectorReset(
991
+ const SherpaOnnxVoiceActivityDetector *p);
992
+
993
+ SHERPA_ONNX_API void SherpaOnnxVoiceActivityDetectorFlush(
994
+ const SherpaOnnxVoiceActivityDetector *p);
995
+
996
+ // ============================================================
997
+ // For offline Text-to-Speech (i.e., non-streaming TTS)
998
+ // ============================================================
999
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineTtsVitsModelConfig {
1000
+ const char *model;
1001
+ const char *lexicon;
1002
+ const char *tokens;
1003
+ const char *data_dir;
1004
+
1005
+ float noise_scale;
1006
+ float noise_scale_w;
1007
+ float length_scale; // < 1, faster in speech speed; > 1, slower in speed
1008
+ const char *dict_dir;
1009
+ } SherpaOnnxOfflineTtsVitsModelConfig;
1010
+
1011
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineTtsMatchaModelConfig {
1012
+ const char *acoustic_model;
1013
+ const char *vocoder;
1014
+ const char *lexicon;
1015
+ const char *tokens;
1016
+ const char *data_dir;
1017
+
1018
+ float noise_scale;
1019
+ float length_scale; // < 1, faster in speech speed; > 1, slower in speed
1020
+ const char *dict_dir;
1021
+ } SherpaOnnxOfflineTtsMatchaModelConfig;
1022
+
1023
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineTtsKokoroModelConfig {
1024
+ const char *model;
1025
+ const char *voices;
1026
+ const char *tokens;
1027
+ const char *data_dir;
1028
+
1029
+ float length_scale; // < 1, faster in speech speed; > 1, slower in speed
1030
+ const char *dict_dir;
1031
+ const char *lexicon;
1032
+ const char *lang;
1033
+ } SherpaOnnxOfflineTtsKokoroModelConfig;
1034
+
1035
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineTtsKittenModelConfig {
1036
+ const char *model;
1037
+ const char *voices;
1038
+ const char *tokens;
1039
+ const char *data_dir;
1040
+
1041
+ float length_scale; // < 1, faster in speech speed; > 1, slower in speed
1042
+ } SherpaOnnxOfflineTtsKittenModelConfig;
1043
+
1044
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineTtsModelConfig {
1045
+ SherpaOnnxOfflineTtsVitsModelConfig vits;
1046
+ int32_t num_threads;
1047
+ int32_t debug;
1048
+ const char *provider;
1049
+ SherpaOnnxOfflineTtsMatchaModelConfig matcha;
1050
+ SherpaOnnxOfflineTtsKokoroModelConfig kokoro;
1051
+ SherpaOnnxOfflineTtsKittenModelConfig kitten;
1052
+ } SherpaOnnxOfflineTtsModelConfig;
1053
+
1054
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineTtsConfig {
1055
+ SherpaOnnxOfflineTtsModelConfig model;
1056
+ const char *rule_fsts;
1057
+ int32_t max_num_sentences;
1058
+ const char *rule_fars;
1059
+ float silence_scale;
1060
+ } SherpaOnnxOfflineTtsConfig;
1061
+
1062
+ SHERPA_ONNX_API typedef struct SherpaOnnxGeneratedAudio {
1063
+ const float *samples; // in the range [-1, 1]
1064
+ int32_t n; // number of samples
1065
+ int32_t sample_rate;
1066
+ } SherpaOnnxGeneratedAudio;
1067
+
1068
+ // If the callback returns 0, then it stops generating
1069
+ // If the callback returns 1, then it keeps generating
1070
+ typedef int32_t (*SherpaOnnxGeneratedAudioCallback)(const float *samples,
1071
+ int32_t n);
1072
+
1073
+ typedef int32_t (*SherpaOnnxGeneratedAudioCallbackWithArg)(const float *samples,
1074
+ int32_t n,
1075
+ void *arg);
1076
+
1077
+ typedef int32_t (*SherpaOnnxGeneratedAudioProgressCallback)(
1078
+ const float *samples, int32_t n, float p);
1079
+
1080
+ typedef int32_t (*SherpaOnnxGeneratedAudioProgressCallbackWithArg)(
1081
+ const float *samples, int32_t n, float p, void *arg);
1082
+
1083
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineTts SherpaOnnxOfflineTts;
1084
+
1085
+ // Create an instance of offline TTS. The user has to use DestroyOfflineTts()
1086
+ // to free the returned pointer to avoid memory leak.
1087
+ SHERPA_ONNX_API const SherpaOnnxOfflineTts *SherpaOnnxCreateOfflineTts(
1088
+ const SherpaOnnxOfflineTtsConfig *config);
1089
+
1090
+ // Free the pointer returned by SherpaOnnxCreateOfflineTts()
1091
+ SHERPA_ONNX_API void SherpaOnnxDestroyOfflineTts(
1092
+ const SherpaOnnxOfflineTts *tts);
1093
+
1094
+ // Return the sample rate of the current TTS object
1095
+ SHERPA_ONNX_API int32_t
1096
+ SherpaOnnxOfflineTtsSampleRate(const SherpaOnnxOfflineTts *tts);
1097
+
1098
+ // Return the number of speakers of the current TTS object
1099
+ SHERPA_ONNX_API int32_t
1100
+ SherpaOnnxOfflineTtsNumSpeakers(const SherpaOnnxOfflineTts *tts);
1101
+
1102
+ // Generate audio from the given text and speaker id (sid).
1103
+ // The user has to use SherpaOnnxDestroyOfflineTtsGeneratedAudio() to free the
1104
+ // returned pointer to avoid memory leak.
1105
+ SHERPA_ONNX_API const SherpaOnnxGeneratedAudio *SherpaOnnxOfflineTtsGenerate(
1106
+ const SherpaOnnxOfflineTts *tts, const char *text, int32_t sid,
1107
+ float speed);
1108
+
1109
+ // callback is called whenever SherpaOnnxOfflineTtsConfig.max_num_sentences
1110
+ // sentences have been processed. The pointer passed to the callback
1111
+ // is freed once the callback is returned. So the caller should not keep
1112
+ // a reference to it.
1113
+ SHERPA_ONNX_API const SherpaOnnxGeneratedAudio *
1114
+ SherpaOnnxOfflineTtsGenerateWithCallback(
1115
+ const SherpaOnnxOfflineTts *tts, const char *text, int32_t sid, float speed,
1116
+ SherpaOnnxGeneratedAudioCallback callback);
1117
+
1118
+ SHERPA_ONNX_API
1119
+ const SherpaOnnxGeneratedAudio *
1120
+ SherpaOnnxOfflineTtsGenerateWithProgressCallback(
1121
+ const SherpaOnnxOfflineTts *tts, const char *text, int32_t sid, float speed,
1122
+ SherpaOnnxGeneratedAudioProgressCallback callback);
1123
+
1124
+ SHERPA_ONNX_API
1125
+ const SherpaOnnxGeneratedAudio *
1126
+ SherpaOnnxOfflineTtsGenerateWithProgressCallbackWithArg(
1127
+ const SherpaOnnxOfflineTts *tts, const char *text, int32_t sid, float speed,
1128
+ SherpaOnnxGeneratedAudioProgressCallbackWithArg callback, void *arg);
1129
+
1130
+ // Same as SherpaOnnxGeneratedAudioCallback but you can pass an additional
1131
+ // `void* arg` to the callback.
1132
+ SHERPA_ONNX_API const SherpaOnnxGeneratedAudio *
1133
+ SherpaOnnxOfflineTtsGenerateWithCallbackWithArg(
1134
+ const SherpaOnnxOfflineTts *tts, const char *text, int32_t sid, float speed,
1135
+ SherpaOnnxGeneratedAudioCallbackWithArg callback, void *arg);
1136
+
1137
+ SHERPA_ONNX_API void SherpaOnnxDestroyOfflineTtsGeneratedAudio(
1138
+ const SherpaOnnxGeneratedAudio *p);
1139
+
1140
+ // Write the generated audio to a wave file.
1141
+ // The saved wave file contains a single channel and has 16-bit samples.
1142
+ //
1143
+ // Return 1 if the write succeeded; return 0 on failure.
1144
+ SHERPA_ONNX_API int32_t SherpaOnnxWriteWave(const float *samples, int32_t n,
1145
+ int32_t sample_rate,
1146
+ const char *filename);
1147
+
1148
+ // the amount of bytes needed to store a wave file which contains a
1149
+ // single channel and has 16-bit samples.
1150
+ SHERPA_ONNX_API int64_t SherpaOnnxWaveFileSize(int32_t n_samples);
1151
+
1152
+ // Similar to SherpaOnnxWriteWave , it writes wave to allocated buffer;
1153
+ //
1154
+ // in some case (http tts api return wave binary file, server do not need to
1155
+ // write wave to fs)
1156
+ SHERPA_ONNX_API void SherpaOnnxWriteWaveToBuffer(const float *samples,
1157
+ int32_t n, int32_t sample_rate,
1158
+ char *buffer);
1159
+
1160
+ SHERPA_ONNX_API typedef struct SherpaOnnxWave {
1161
+ // samples normalized to the range [-1, 1]
1162
+ const float *samples;
1163
+ int32_t sample_rate;
1164
+ int32_t num_samples;
1165
+ } SherpaOnnxWave;
1166
+
1167
+ // Return a NULL pointer on error. It supports only standard WAVE file.
1168
+ // Each sample should be 16-bit. It supports only single channel..
1169
+ //
1170
+ // If the returned pointer is not NULL, the user has to invoke
1171
+ // SherpaOnnxFreeWave() to free the returned pointer to avoid memory leak.
1172
+ SHERPA_ONNX_API const SherpaOnnxWave *SherpaOnnxReadWave(const char *filename);
1173
+
1174
+ // Similar to SherpaOnnxReadWave(), it has read the content of `filename`
1175
+ // into the array `data`.
1176
+ //
1177
+ // If the returned pointer is not NULL, the user has to invoke
1178
+ // SherpaOnnxFreeWave() to free the returned pointer to avoid memory leak.
1179
+ SHERPA_ONNX_API const SherpaOnnxWave *SherpaOnnxReadWaveFromBinaryData(
1180
+ const char *data, int32_t n);
1181
+
1182
+ SHERPA_ONNX_API void SherpaOnnxFreeWave(const SherpaOnnxWave *wave);
1183
+
1184
+ // ============================================================
1185
+ // For spoken language identification
1186
+ // ============================================================
1187
+
1188
+ SHERPA_ONNX_API typedef struct
1189
+ SherpaOnnxSpokenLanguageIdentificationWhisperConfig {
1190
+ const char *encoder;
1191
+ const char *decoder;
1192
+ int32_t tail_paddings;
1193
+ } SherpaOnnxSpokenLanguageIdentificationWhisperConfig;
1194
+
1195
+ SHERPA_ONNX_API typedef struct SherpaOnnxSpokenLanguageIdentificationConfig {
1196
+ SherpaOnnxSpokenLanguageIdentificationWhisperConfig whisper;
1197
+ int32_t num_threads;
1198
+ int32_t debug;
1199
+ const char *provider;
1200
+ } SherpaOnnxSpokenLanguageIdentificationConfig;
1201
+
1202
+ SHERPA_ONNX_API typedef struct SherpaOnnxSpokenLanguageIdentification
1203
+ SherpaOnnxSpokenLanguageIdentification;
1204
+
1205
+ // Create an instance of SpokenLanguageIdentification.
1206
+ // The user has to invoke SherpaOnnxDestroySpokenLanguageIdentification()
1207
+ // to free the returned pointer to avoid memory leak.
1208
+ SHERPA_ONNX_API const SherpaOnnxSpokenLanguageIdentification *
1209
+ SherpaOnnxCreateSpokenLanguageIdentification(
1210
+ const SherpaOnnxSpokenLanguageIdentificationConfig *config);
1211
+
1212
+ SHERPA_ONNX_API void SherpaOnnxDestroySpokenLanguageIdentification(
1213
+ const SherpaOnnxSpokenLanguageIdentification *slid);
1214
+
1215
+ // The user has to invoke SherpaOnnxDestroyOfflineStream()
1216
+ // to free the returned pointer to avoid memory leak
1217
+ SHERPA_ONNX_API SherpaOnnxOfflineStream *
1218
+ SherpaOnnxSpokenLanguageIdentificationCreateOfflineStream(
1219
+ const SherpaOnnxSpokenLanguageIdentification *slid);
1220
+
1221
+ SHERPA_ONNX_API typedef struct SherpaOnnxSpokenLanguageIdentificationResult {
1222
+ // en for English
1223
+ // de for German
1224
+ // zh for Chinese
1225
+ // es for Spanish
1226
+ // ...
1227
+ const char *lang;
1228
+ } SherpaOnnxSpokenLanguageIdentificationResult;
1229
+
1230
+ // The user has to invoke SherpaOnnxDestroySpokenLanguageIdentificationResult()
1231
+ // to free the returned pointer to avoid memory leak
1232
+ SHERPA_ONNX_API const SherpaOnnxSpokenLanguageIdentificationResult *
1233
+ SherpaOnnxSpokenLanguageIdentificationCompute(
1234
+ const SherpaOnnxSpokenLanguageIdentification *slid,
1235
+ const SherpaOnnxOfflineStream *s);
1236
+
1237
+ SHERPA_ONNX_API void SherpaOnnxDestroySpokenLanguageIdentificationResult(
1238
+ const SherpaOnnxSpokenLanguageIdentificationResult *r);
1239
+
1240
+ // ============================================================
1241
+ // For speaker embedding extraction
1242
+ // ============================================================
1243
+ SHERPA_ONNX_API typedef struct SherpaOnnxSpeakerEmbeddingExtractorConfig {
1244
+ const char *model;
1245
+ int32_t num_threads;
1246
+ int32_t debug;
1247
+ const char *provider;
1248
+ } SherpaOnnxSpeakerEmbeddingExtractorConfig;
1249
+
1250
+ SHERPA_ONNX_API typedef struct SherpaOnnxSpeakerEmbeddingExtractor
1251
+ SherpaOnnxSpeakerEmbeddingExtractor;
1252
+
1253
+ // The user has to invoke SherpaOnnxDestroySpeakerEmbeddingExtractor()
1254
+ // to free the returned pointer to avoid memory leak
1255
+ SHERPA_ONNX_API const SherpaOnnxSpeakerEmbeddingExtractor *
1256
+ SherpaOnnxCreateSpeakerEmbeddingExtractor(
1257
+ const SherpaOnnxSpeakerEmbeddingExtractorConfig *config);
1258
+
1259
+ SHERPA_ONNX_API void SherpaOnnxDestroySpeakerEmbeddingExtractor(
1260
+ const SherpaOnnxSpeakerEmbeddingExtractor *p);
1261
+
1262
+ SHERPA_ONNX_API int32_t SherpaOnnxSpeakerEmbeddingExtractorDim(
1263
+ const SherpaOnnxSpeakerEmbeddingExtractor *p);
1264
+
1265
+ // The user has to invoke SherpaOnnxDestroyOnlineStream() to free the returned
1266
+ // pointer to avoid memory leak
1267
+ SHERPA_ONNX_API const SherpaOnnxOnlineStream *
1268
+ SherpaOnnxSpeakerEmbeddingExtractorCreateStream(
1269
+ const SherpaOnnxSpeakerEmbeddingExtractor *p);
1270
+
1271
+ // Return 1 if the stream has enough feature frames for computing embeddings.
1272
+ // Return 0 otherwise.
1273
+ SHERPA_ONNX_API int32_t SherpaOnnxSpeakerEmbeddingExtractorIsReady(
1274
+ const SherpaOnnxSpeakerEmbeddingExtractor *p,
1275
+ const SherpaOnnxOnlineStream *s);
1276
+
1277
+ // Compute the embedding of the stream.
1278
+ //
1279
+ // @return Return a pointer pointing to an array containing the embedding.
1280
+ // The length of the array is `dim` as returned by
1281
+ // SherpaOnnxSpeakerEmbeddingExtractorDim(p)
1282
+ //
1283
+ // The user has to invoke SherpaOnnxSpeakerEmbeddingExtractorDestroyEmbedding()
1284
+ // to free the returned pointer to avoid memory leak.
1285
+ SHERPA_ONNX_API const float *
1286
+ SherpaOnnxSpeakerEmbeddingExtractorComputeEmbedding(
1287
+ const SherpaOnnxSpeakerEmbeddingExtractor *p,
1288
+ const SherpaOnnxOnlineStream *s);
1289
+
1290
+ SHERPA_ONNX_API void SherpaOnnxSpeakerEmbeddingExtractorDestroyEmbedding(
1291
+ const float *v);
1292
+
1293
+ SHERPA_ONNX_API typedef struct SherpaOnnxSpeakerEmbeddingManager
1294
+ SherpaOnnxSpeakerEmbeddingManager;
1295
+
1296
+ // The user has to invoke SherpaOnnxDestroySpeakerEmbeddingManager()
1297
+ // to free the returned pointer to avoid memory leak
1298
+ SHERPA_ONNX_API const SherpaOnnxSpeakerEmbeddingManager *
1299
+ SherpaOnnxCreateSpeakerEmbeddingManager(int32_t dim);
1300
+
1301
+ SHERPA_ONNX_API void SherpaOnnxDestroySpeakerEmbeddingManager(
1302
+ const SherpaOnnxSpeakerEmbeddingManager *p);
1303
+
1304
+ // Register the embedding of a user
1305
+ //
1306
+ // @param name The name of the user
1307
+ // @param p Pointer to an array containing the embeddings. The length of the
1308
+ // array must be equal to `dim` used to construct the manager `p`.
1309
+ //
1310
+ // @return Return 1 if added successfully. Return 0 on error
1311
+ SHERPA_ONNX_API int32_t
1312
+ SherpaOnnxSpeakerEmbeddingManagerAdd(const SherpaOnnxSpeakerEmbeddingManager *p,
1313
+ const char *name, const float *v);
1314
+
1315
+ // @param v Pointer to an array of embeddings. If there are n embeddings, then
1316
+ // v[0] is the pointer to the 0-th array containing the embeddings
1317
+ // v[1] is the pointer to the 1-st array containing the embeddings
1318
+ // v[n-1] is the pointer to the last array containing the embeddings
1319
+ // v[n] is a NULL pointer
1320
+ // @return Return 1 if added successfully. Return 0 on error
1321
+ SHERPA_ONNX_API int32_t SherpaOnnxSpeakerEmbeddingManagerAddList(
1322
+ const SherpaOnnxSpeakerEmbeddingManager *p, const char *name,
1323
+ const float **v);
1324
+
1325
+ // Similar to SherpaOnnxSpeakerEmbeddingManagerAddList() but the memory
1326
+ // is flattened.
1327
+ //
1328
+ // The length of the input array should be `n * dim`.
1329
+ //
1330
+ // @return Return 1 if added successfully. Return 0 on error
1331
+ SHERPA_ONNX_API int32_t SherpaOnnxSpeakerEmbeddingManagerAddListFlattened(
1332
+ const SherpaOnnxSpeakerEmbeddingManager *p, const char *name,
1333
+ const float *v, int32_t n);
1334
+
1335
+ // Remove a user.
1336
+ // @param naem The name of the user to remove.
1337
+ // @return Return 1 if removed successfully; return 0 on error.
1338
+ //
1339
+ // Note if the user does not exist, it also returns 0.
1340
+ SHERPA_ONNX_API int32_t SherpaOnnxSpeakerEmbeddingManagerRemove(
1341
+ const SherpaOnnxSpeakerEmbeddingManager *p, const char *name);
1342
+
1343
+ // Search if an existing users' embedding matches the given one.
1344
+ //
1345
+ // @param p Pointer to an array containing the embedding. The dim
1346
+ // of the array must equal to `dim` used to construct the manager `p`.
1347
+ // @param threshold A value between 0 and 1. If the similarity score exceeds
1348
+ // this threshold, we say a match is found.
1349
+ // @return Returns the name of the user if found. Return NULL if not found.
1350
+ // If not NULL, the caller has to invoke
1351
+ // SherpaOnnxSpeakerEmbeddingManagerFreeSearch() to free the returned
1352
+ // pointer to avoid memory leak.
1353
+ SHERPA_ONNX_API const char *SherpaOnnxSpeakerEmbeddingManagerSearch(
1354
+ const SherpaOnnxSpeakerEmbeddingManager *p, const float *v,
1355
+ float threshold);
1356
+
1357
+ SHERPA_ONNX_API void SherpaOnnxSpeakerEmbeddingManagerFreeSearch(
1358
+ const char *name);
1359
+
1360
+ SHERPA_ONNX_API typedef struct SherpaOnnxSpeakerEmbeddingManagerSpeakerMatch {
1361
+ float score;
1362
+ const char *name;
1363
+ } SherpaOnnxSpeakerEmbeddingManagerSpeakerMatch;
1364
+
1365
+ SHERPA_ONNX_API typedef struct
1366
+ SherpaOnnxSpeakerEmbeddingManagerBestMatchesResult {
1367
+ const SherpaOnnxSpeakerEmbeddingManagerSpeakerMatch *matches;
1368
+ int32_t count;
1369
+ } SherpaOnnxSpeakerEmbeddingManagerBestMatchesResult;
1370
+
1371
+ // Get the best matching speakers whose embeddings match the given
1372
+ // embedding.
1373
+ //
1374
+ // @param p Pointer to the SherpaOnnxSpeakerEmbeddingManager instance.
1375
+ // @param v Pointer to an array containing the embedding vector.
1376
+ // @param threshold Minimum similarity score required for a match (between 0 and
1377
+ // 1).
1378
+ // @param n Number of best matches to retrieve.
1379
+ // @return Returns a pointer to
1380
+ // SherpaOnnxSpeakerEmbeddingManagerBestMatchesResult
1381
+ // containing the best matches found. Returns NULL if no matches are
1382
+ // found. The caller is responsible for freeing the returned pointer
1383
+ // using SherpaOnnxSpeakerEmbeddingManagerFreeBestMatches() to
1384
+ // avoid memory leaks.
1385
+ SHERPA_ONNX_API const SherpaOnnxSpeakerEmbeddingManagerBestMatchesResult *
1386
+ SherpaOnnxSpeakerEmbeddingManagerGetBestMatches(
1387
+ const SherpaOnnxSpeakerEmbeddingManager *p, const float *v, float threshold,
1388
+ int32_t n);
1389
+
1390
+ SHERPA_ONNX_API void SherpaOnnxSpeakerEmbeddingManagerFreeBestMatches(
1391
+ const SherpaOnnxSpeakerEmbeddingManagerBestMatchesResult *r);
1392
+
1393
+ // Check whether the input embedding matches the embedding of the input
1394
+ // speaker.
1395
+ //
1396
+ // It is for speaker verification.
1397
+ //
1398
+ // @param name The target speaker name.
1399
+ // @param p The input embedding to check.
1400
+ // @param threshold A value between 0 and 1.
1401
+ // @return Return 1 if it matches. Otherwise, it returns 0.
1402
+ SHERPA_ONNX_API int32_t SherpaOnnxSpeakerEmbeddingManagerVerify(
1403
+ const SherpaOnnxSpeakerEmbeddingManager *p, const char *name,
1404
+ const float *v, float threshold);
1405
+
1406
+ // Return 1 if the user with the name is in the manager.
1407
+ // Return 0 if the user does not exist.
1408
+ SHERPA_ONNX_API int32_t SherpaOnnxSpeakerEmbeddingManagerContains(
1409
+ const SherpaOnnxSpeakerEmbeddingManager *p, const char *name);
1410
+
1411
+ // Return number of speakers in the manager.
1412
+ SHERPA_ONNX_API int32_t SherpaOnnxSpeakerEmbeddingManagerNumSpeakers(
1413
+ const SherpaOnnxSpeakerEmbeddingManager *p);
1414
+
1415
+ // Return the name of all speakers in the manager.
1416
+ //
1417
+ // @return Return an array of pointers `ans`. If there are n speakers, then
1418
+ // - ans[0] contains the name of the 0-th speaker
1419
+ // - ans[1] contains the name of the 1-st speaker
1420
+ // - ans[n-1] contains the name of the last speaker
1421
+ // - ans[n] is NULL
1422
+ // If there are no users at all, then ans[0] is NULL. In any case,
1423
+ // `ans` is not NULL.
1424
+ //
1425
+ // Each name is NULL-terminated
1426
+ //
1427
+ // The caller has to invoke SherpaOnnxSpeakerEmbeddingManagerFreeAllSpeakers()
1428
+ // to free the returned pointer to avoid memory leak.
1429
+ SHERPA_ONNX_API const char *const *
1430
+ SherpaOnnxSpeakerEmbeddingManagerGetAllSpeakers(
1431
+ const SherpaOnnxSpeakerEmbeddingManager *p);
1432
+
1433
+ SHERPA_ONNX_API void SherpaOnnxSpeakerEmbeddingManagerFreeAllSpeakers(
1434
+ const char *const *names);
1435
+
1436
+ // ============================================================
1437
+ // For audio tagging
1438
+ // ============================================================
1439
+ SHERPA_ONNX_API typedef struct
1440
+ SherpaOnnxOfflineZipformerAudioTaggingModelConfig {
1441
+ const char *model;
1442
+ } SherpaOnnxOfflineZipformerAudioTaggingModelConfig;
1443
+
1444
+ SHERPA_ONNX_API typedef struct SherpaOnnxAudioTaggingModelConfig {
1445
+ SherpaOnnxOfflineZipformerAudioTaggingModelConfig zipformer;
1446
+ const char *ced;
1447
+ int32_t num_threads;
1448
+ int32_t debug; // true to print debug information of the model
1449
+ const char *provider;
1450
+ } SherpaOnnxAudioTaggingModelConfig;
1451
+
1452
+ SHERPA_ONNX_API typedef struct SherpaOnnxAudioTaggingConfig {
1453
+ SherpaOnnxAudioTaggingModelConfig model;
1454
+ const char *labels;
1455
+ int32_t top_k;
1456
+ } SherpaOnnxAudioTaggingConfig;
1457
+
1458
+ SHERPA_ONNX_API typedef struct SherpaOnnxAudioEvent {
1459
+ const char *name;
1460
+ int32_t index;
1461
+ float prob;
1462
+ } SherpaOnnxAudioEvent;
1463
+
1464
+ SHERPA_ONNX_API typedef struct SherpaOnnxAudioTagging SherpaOnnxAudioTagging;
1465
+
1466
+ // The user has to invoke
1467
+ // SherpaOnnxDestroyAudioTagging()
1468
+ // to free the returned pointer to avoid memory leak
1469
+ SHERPA_ONNX_API const SherpaOnnxAudioTagging *SherpaOnnxCreateAudioTagging(
1470
+ const SherpaOnnxAudioTaggingConfig *config);
1471
+
1472
+ SHERPA_ONNX_API void SherpaOnnxDestroyAudioTagging(
1473
+ const SherpaOnnxAudioTagging *tagger);
1474
+
1475
+ // The user has to invoke SherpaOnnxDestroyOfflineStream()
1476
+ // to free the returned pointer to avoid memory leak
1477
+ SHERPA_ONNX_API const SherpaOnnxOfflineStream *
1478
+ SherpaOnnxAudioTaggingCreateOfflineStream(const SherpaOnnxAudioTagging *tagger);
1479
+
1480
+ // Return an array of pointers. The length of the array is top_k + 1.
1481
+ // If top_k is -1, then config.top_k is used, where config is the config
1482
+ // used to create the input tagger.
1483
+ //
1484
+ // The ans[0]->prob has the largest probability among the array elements
1485
+ // The last element of the array is a null pointer
1486
+ //
1487
+ // The user has to use SherpaOnnxAudioTaggingFreeResults()
1488
+ // to free the returned pointer to avoid memory leak
1489
+ SHERPA_ONNX_API const SherpaOnnxAudioEvent *const *
1490
+ SherpaOnnxAudioTaggingCompute(const SherpaOnnxAudioTagging *tagger,
1491
+ const SherpaOnnxOfflineStream *s, int32_t top_k);
1492
+
1493
+ SHERPA_ONNX_API void SherpaOnnxAudioTaggingFreeResults(
1494
+ const SherpaOnnxAudioEvent *const *p);
1495
+
1496
+ // ============================================================
1497
+ // For punctuation
1498
+ // ============================================================
1499
+
1500
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflinePunctuationModelConfig {
1501
+ const char *ct_transformer;
1502
+ int32_t num_threads;
1503
+ int32_t debug; // true to print debug information of the model
1504
+ const char *provider;
1505
+ } SherpaOnnxOfflinePunctuationModelConfig;
1506
+
1507
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflinePunctuationConfig {
1508
+ SherpaOnnxOfflinePunctuationModelConfig model;
1509
+ } SherpaOnnxOfflinePunctuationConfig;
1510
+
1511
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflinePunctuation
1512
+ SherpaOnnxOfflinePunctuation;
1513
+
1514
+ // The user has to invoke SherpaOnnxDestroyOfflinePunctuation()
1515
+ // to free the returned pointer to avoid memory leak
1516
+ SHERPA_ONNX_API const SherpaOnnxOfflinePunctuation *
1517
+ SherpaOnnxCreateOfflinePunctuation(
1518
+ const SherpaOnnxOfflinePunctuationConfig *config);
1519
+
1520
+ SHERPA_ONNX_API void SherpaOnnxDestroyOfflinePunctuation(
1521
+ const SherpaOnnxOfflinePunctuation *punct);
1522
+
1523
+ // Add punctuations to the input text.
1524
+ // The user has to invoke SherpaOfflinePunctuationFreeText()
1525
+ // to free the returned pointer to avoid memory leak
1526
+ SHERPA_ONNX_API const char *SherpaOfflinePunctuationAddPunct(
1527
+ const SherpaOnnxOfflinePunctuation *punct, const char *text);
1528
+
1529
+ SHERPA_ONNX_API void SherpaOfflinePunctuationFreeText(const char *text);
1530
+
1531
+ SHERPA_ONNX_API typedef struct SherpaOnnxOnlinePunctuationModelConfig {
1532
+ const char *cnn_bilstm;
1533
+ const char *bpe_vocab;
1534
+ int32_t num_threads;
1535
+ int32_t debug;
1536
+ const char *provider;
1537
+ } SherpaOnnxOnlinePunctuationModelConfig;
1538
+
1539
+ SHERPA_ONNX_API typedef struct SherpaOnnxOnlinePunctuationConfig {
1540
+ SherpaOnnxOnlinePunctuationModelConfig model;
1541
+ } SherpaOnnxOnlinePunctuationConfig;
1542
+
1543
+ SHERPA_ONNX_API typedef struct SherpaOnnxOnlinePunctuation
1544
+ SherpaOnnxOnlinePunctuation;
1545
+
1546
+ // Create an online punctuation processor. The user has to invoke
1547
+ // SherpaOnnxDestroyOnlinePunctuation() to free the returned pointer
1548
+ // to avoid memory leak
1549
+ SHERPA_ONNX_API const SherpaOnnxOnlinePunctuation *
1550
+ SherpaOnnxCreateOnlinePunctuation(
1551
+ const SherpaOnnxOnlinePunctuationConfig *config);
1552
+
1553
+ // Free a pointer returned by SherpaOnnxCreateOnlinePunctuation()
1554
+ SHERPA_ONNX_API void SherpaOnnxDestroyOnlinePunctuation(
1555
+ const SherpaOnnxOnlinePunctuation *punctuation);
1556
+
1557
+ // Add punctuations to the input text. The user has to invoke
1558
+ // SherpaOnnxOnlinePunctuationFreeText() to free the returned pointer
1559
+ // to avoid memory leak
1560
+ SHERPA_ONNX_API const char *SherpaOnnxOnlinePunctuationAddPunct(
1561
+ const SherpaOnnxOnlinePunctuation *punctuation, const char *text);
1562
+
1563
+ // Free a pointer returned by SherpaOnnxOnlinePunctuationAddPunct()
1564
+ SHERPA_ONNX_API void SherpaOnnxOnlinePunctuationFreeText(const char *text);
1565
+
1566
+ // for resampling
1567
+ SHERPA_ONNX_API typedef struct SherpaOnnxLinearResampler
1568
+ SherpaOnnxLinearResampler;
1569
+
1570
+ /*
1571
+ float min_freq = min(sampling_rate_in_hz, samp_rate_out_hz);
1572
+ float lowpass_cutoff = 0.99 * 0.5 * min_freq;
1573
+ int32_t lowpass_filter_width = 6;
1574
+
1575
+ You can set filter_cutoff_hz to lowpass_cutoff
1576
+ sand set num_zeros to lowpass_filter_width
1577
+ */
1578
+ // The user has to invoke SherpaOnnxDestroyLinearResampler()
1579
+ // to free the returned pointer to avoid memory leak
1580
+ SHERPA_ONNX_API const SherpaOnnxLinearResampler *
1581
+ SherpaOnnxCreateLinearResampler(int32_t samp_rate_in_hz,
1582
+ int32_t samp_rate_out_hz,
1583
+ float filter_cutoff_hz, int32_t num_zeros);
1584
+
1585
+ SHERPA_ONNX_API void SherpaOnnxDestroyLinearResampler(
1586
+ const SherpaOnnxLinearResampler *p);
1587
+
1588
+ SHERPA_ONNX_API void SherpaOnnxLinearResamplerReset(
1589
+ const SherpaOnnxLinearResampler *p);
1590
+
1591
+ typedef struct SherpaOnnxResampleOut {
1592
+ const float *samples;
1593
+ int32_t n;
1594
+ } SherpaOnnxResampleOut;
1595
+ // The user has to invoke SherpaOnnxLinearResamplerResampleFree()
1596
+ // to free the returned pointer to avoid memory leak.
1597
+ //
1598
+ // If this is the last segment, you can set flush to 1; otherwise, please
1599
+ // set flush to 0
1600
+ SHERPA_ONNX_API const SherpaOnnxResampleOut *SherpaOnnxLinearResamplerResample(
1601
+ const SherpaOnnxLinearResampler *p, const float *input, int32_t input_dim,
1602
+ int32_t flush);
1603
+
1604
+ SHERPA_ONNX_API void SherpaOnnxLinearResamplerResampleFree(
1605
+ const SherpaOnnxResampleOut *p);
1606
+
1607
+ SHERPA_ONNX_API int32_t SherpaOnnxLinearResamplerResampleGetInputSampleRate(
1608
+ const SherpaOnnxLinearResampler *p);
1609
+
1610
+ SHERPA_ONNX_API int32_t SherpaOnnxLinearResamplerResampleGetOutputSampleRate(
1611
+ const SherpaOnnxLinearResampler *p);
1612
+
1613
+ // =========================================================================
1614
+ // For offline speaker diarization (i.e., non-streaming speaker diarization)
1615
+ // =========================================================================
1616
+ SHERPA_ONNX_API typedef struct
1617
+ SherpaOnnxOfflineSpeakerSegmentationPyannoteModelConfig {
1618
+ const char *model;
1619
+ } SherpaOnnxOfflineSpeakerSegmentationPyannoteModelConfig;
1620
+
1621
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineSpeakerSegmentationModelConfig {
1622
+ SherpaOnnxOfflineSpeakerSegmentationPyannoteModelConfig pyannote;
1623
+ int32_t num_threads; // 1
1624
+ int32_t debug; // false
1625
+ const char *provider; // "cpu"
1626
+ } SherpaOnnxOfflineSpeakerSegmentationModelConfig;
1627
+
1628
+ SHERPA_ONNX_API typedef struct SherpaOnnxFastClusteringConfig {
1629
+ // If greater than 0, then threshold is ignored.
1630
+ //
1631
+ // We strongly recommend that you set it if you know the number of clusters
1632
+ // in advance
1633
+ int32_t num_clusters;
1634
+
1635
+ // distance threshold.
1636
+ //
1637
+ // The smaller, the more clusters it will generate.
1638
+ // The larger, the fewer clusters it will generate.
1639
+ float threshold;
1640
+ } SherpaOnnxFastClusteringConfig;
1641
+
1642
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineSpeakerDiarizationConfig {
1643
+ SherpaOnnxOfflineSpeakerSegmentationModelConfig segmentation;
1644
+ SherpaOnnxSpeakerEmbeddingExtractorConfig embedding;
1645
+ SherpaOnnxFastClusteringConfig clustering;
1646
+
1647
+ // if a segment is less than this value, then it is discarded
1648
+ float min_duration_on; // in seconds
1649
+
1650
+ // if the gap between to segments of the same speaker is less than this value,
1651
+ // then these two segments are merged into a single segment.
1652
+ // We do this recursively.
1653
+ float min_duration_off; // in seconds
1654
+ } SherpaOnnxOfflineSpeakerDiarizationConfig;
1655
+
1656
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineSpeakerDiarization
1657
+ SherpaOnnxOfflineSpeakerDiarization;
1658
+
1659
+ // The users has to invoke SherpaOnnxDestroyOfflineSpeakerDiarization()
1660
+ // to free the returned pointer to avoid memory leak
1661
+ SHERPA_ONNX_API const SherpaOnnxOfflineSpeakerDiarization *
1662
+ SherpaOnnxCreateOfflineSpeakerDiarization(
1663
+ const SherpaOnnxOfflineSpeakerDiarizationConfig *config);
1664
+
1665
+ // Free the pointer returned by SherpaOnnxCreateOfflineSpeakerDiarization()
1666
+ SHERPA_ONNX_API void SherpaOnnxDestroyOfflineSpeakerDiarization(
1667
+ const SherpaOnnxOfflineSpeakerDiarization *sd);
1668
+
1669
+ // Expected sample rate of the input audio samples
1670
+ SHERPA_ONNX_API int32_t SherpaOnnxOfflineSpeakerDiarizationGetSampleRate(
1671
+ const SherpaOnnxOfflineSpeakerDiarization *sd);
1672
+
1673
+ // Only config->clustering is used. All other fields are ignored
1674
+ SHERPA_ONNX_API void SherpaOnnxOfflineSpeakerDiarizationSetConfig(
1675
+ const SherpaOnnxOfflineSpeakerDiarization *sd,
1676
+ const SherpaOnnxOfflineSpeakerDiarizationConfig *config);
1677
+
1678
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineSpeakerDiarizationResult
1679
+ SherpaOnnxOfflineSpeakerDiarizationResult;
1680
+
1681
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineSpeakerDiarizationSegment {
1682
+ float start;
1683
+ float end;
1684
+ int32_t speaker;
1685
+ } SherpaOnnxOfflineSpeakerDiarizationSegment;
1686
+
1687
+ SHERPA_ONNX_API int32_t SherpaOnnxOfflineSpeakerDiarizationResultGetNumSpeakers(
1688
+ const SherpaOnnxOfflineSpeakerDiarizationResult *r);
1689
+
1690
+ SHERPA_ONNX_API int32_t SherpaOnnxOfflineSpeakerDiarizationResultGetNumSegments(
1691
+ const SherpaOnnxOfflineSpeakerDiarizationResult *r);
1692
+
1693
+ // The user has to invoke SherpaOnnxOfflineSpeakerDiarizationDestroySegment()
1694
+ // to free the returned pointer to avoid memory leak.
1695
+ //
1696
+ // The returned pointer is the start address of an array.
1697
+ // Number of entries in the array equals to the value
1698
+ // returned by SherpaOnnxOfflineSpeakerDiarizationResultGetNumSegments()
1699
+ SHERPA_ONNX_API const SherpaOnnxOfflineSpeakerDiarizationSegment *
1700
+ SherpaOnnxOfflineSpeakerDiarizationResultSortByStartTime(
1701
+ const SherpaOnnxOfflineSpeakerDiarizationResult *r);
1702
+
1703
+ SHERPA_ONNX_API void SherpaOnnxOfflineSpeakerDiarizationDestroySegment(
1704
+ const SherpaOnnxOfflineSpeakerDiarizationSegment *s);
1705
+
1706
+ typedef int32_t (*SherpaOnnxOfflineSpeakerDiarizationProgressCallback)(
1707
+ int32_t num_processed_chunks, int32_t num_total_chunks, void *arg);
1708
+
1709
+ typedef int32_t (*SherpaOnnxOfflineSpeakerDiarizationProgressCallbackNoArg)(
1710
+ int32_t num_processed_chunks, int32_t num_total_chunks);
1711
+
1712
+ // The user has to invoke SherpaOnnxOfflineSpeakerDiarizationDestroyResult()
1713
+ // to free the returned pointer to avoid memory leak.
1714
+ SHERPA_ONNX_API const SherpaOnnxOfflineSpeakerDiarizationResult *
1715
+ SherpaOnnxOfflineSpeakerDiarizationProcess(
1716
+ const SherpaOnnxOfflineSpeakerDiarization *sd, const float *samples,
1717
+ int32_t n);
1718
+
1719
+ // The user has to invoke SherpaOnnxOfflineSpeakerDiarizationDestroyResult()
1720
+ // to free the returned pointer to avoid memory leak.
1721
+ SHERPA_ONNX_API const SherpaOnnxOfflineSpeakerDiarizationResult *
1722
+ SherpaOnnxOfflineSpeakerDiarizationProcessWithCallback(
1723
+ const SherpaOnnxOfflineSpeakerDiarization *sd, const float *samples,
1724
+ int32_t n, SherpaOnnxOfflineSpeakerDiarizationProgressCallback callback,
1725
+ void *arg);
1726
+
1727
+ SHERPA_ONNX_API const SherpaOnnxOfflineSpeakerDiarizationResult *
1728
+ SherpaOnnxOfflineSpeakerDiarizationProcessWithCallbackNoArg(
1729
+ const SherpaOnnxOfflineSpeakerDiarization *sd, const float *samples,
1730
+ int32_t n,
1731
+ SherpaOnnxOfflineSpeakerDiarizationProgressCallbackNoArg callback);
1732
+
1733
+ SHERPA_ONNX_API void SherpaOnnxOfflineSpeakerDiarizationDestroyResult(
1734
+ const SherpaOnnxOfflineSpeakerDiarizationResult *r);
1735
+
1736
+ // =========================================================================
1737
+ // For offline speech enhancement
1738
+ // =========================================================================
1739
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineSpeechDenoiserGtcrnModelConfig {
1740
+ const char *model;
1741
+ } SherpaOnnxOfflineSpeechDenoiserGtcrnModelConfig;
1742
+
1743
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineSpeechDenoiserModelConfig {
1744
+ SherpaOnnxOfflineSpeechDenoiserGtcrnModelConfig gtcrn;
1745
+ int32_t num_threads;
1746
+ int32_t debug; // true to print debug information of the model
1747
+ const char *provider;
1748
+ } SherpaOnnxOfflineSpeechDenoiserModelConfig;
1749
+
1750
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineSpeechDenoiserConfig {
1751
+ SherpaOnnxOfflineSpeechDenoiserModelConfig model;
1752
+ } SherpaOnnxOfflineSpeechDenoiserConfig;
1753
+
1754
+ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineSpeechDenoiser
1755
+ SherpaOnnxOfflineSpeechDenoiser;
1756
+
1757
+ // The users has to invoke SherpaOnnxDestroyOfflineSpeechDenoiser()
1758
+ // to free the returned pointer to avoid memory leak
1759
+ SHERPA_ONNX_API const SherpaOnnxOfflineSpeechDenoiser *
1760
+ SherpaOnnxCreateOfflineSpeechDenoiser(
1761
+ const SherpaOnnxOfflineSpeechDenoiserConfig *config);
1762
+
1763
+ // Free the pointer returned by SherpaOnnxCreateOfflineSpeechDenoiser()
1764
+ SHERPA_ONNX_API void SherpaOnnxDestroyOfflineSpeechDenoiser(
1765
+ const SherpaOnnxOfflineSpeechDenoiser *sd);
1766
+
1767
+ SHERPA_ONNX_API int32_t SherpaOnnxOfflineSpeechDenoiserGetSampleRate(
1768
+ const SherpaOnnxOfflineSpeechDenoiser *sd);
1769
+
1770
+ SHERPA_ONNX_API typedef struct SherpaOnnxDenoisedAudio {
1771
+ const float *samples; // in the range [-1, 1]
1772
+ int32_t n; // number of samples
1773
+ int32_t sample_rate;
1774
+ } SherpaOnnxDenoisedAudio;
1775
+
1776
+ // Run speech denosing on input samples
1777
+ // @param samples A 1-D array containing the input audio samples. Each sample
1778
+ // should be in the range [-1, 1].
1779
+ // @param n Number of samples
1780
+ // @param sample_rate Sample rate of the input samples
1781
+ //
1782
+ // The user MUST use SherpaOnnxDestroyDenoisedAudio() to free the returned
1783
+ // pointer to avoid memory leak.
1784
+ SHERPA_ONNX_API const SherpaOnnxDenoisedAudio *
1785
+ SherpaOnnxOfflineSpeechDenoiserRun(const SherpaOnnxOfflineSpeechDenoiser *sd,
1786
+ const float *samples, int32_t n,
1787
+ int32_t sample_rate);
1788
+
1789
+ SHERPA_ONNX_API void SherpaOnnxDestroyDenoisedAudio(
1790
+ const SherpaOnnxDenoisedAudio *p);
1791
+
1792
+ #ifdef __OHOS__
1793
+
1794
+ // It is for HarmonyOS
1795
+ typedef struct NativeResourceManager NativeResourceManager;
1796
+
1797
+ SHERPA_ONNX_API const SherpaOnnxOfflineSpeechDenoiser *
1798
+ SherpaOnnxCreateOfflineSpeechDenoiserOHOS(
1799
+ const SherpaOnnxOfflineSpeechDenoiserConfig *config,
1800
+ NativeResourceManager *mgr);
1801
+
1802
+ /// @param config Config for the recognizer.
1803
+ /// @return Return a pointer to the recognizer. The user has to invoke
1804
+ // SherpaOnnxDestroyOnlineRecognizer() to free it to avoid memory leak.
1805
+ SHERPA_ONNX_API const SherpaOnnxOnlineRecognizer *
1806
+ SherpaOnnxCreateOnlineRecognizerOHOS(
1807
+ const SherpaOnnxOnlineRecognizerConfig *config, NativeResourceManager *mgr);
1808
+
1809
+ /// @param config Config for the recognizer.
1810
+ /// @return Return a pointer to the recognizer. The user has to invoke
1811
+ // SherpaOnnxDestroyOfflineRecognizer() to free it to avoid memory
1812
+ // leak.
1813
+ SHERPA_ONNX_API const SherpaOnnxOfflineRecognizer *
1814
+ SherpaOnnxCreateOfflineRecognizerOHOS(
1815
+ const SherpaOnnxOfflineRecognizerConfig *config,
1816
+ NativeResourceManager *mgr);
1817
+
1818
+ // Return an instance of VoiceActivityDetector.
1819
+ // The user has to use SherpaOnnxDestroyVoiceActivityDetector() to free
1820
+ // the returned pointer to avoid memory leak.
1821
+ SHERPA_ONNX_API const SherpaOnnxVoiceActivityDetector *
1822
+ SherpaOnnxCreateVoiceActivityDetectorOHOS(
1823
+ const SherpaOnnxVadModelConfig *config, float buffer_size_in_seconds,
1824
+ NativeResourceManager *mgr);
1825
+
1826
+ SHERPA_ONNX_API const SherpaOnnxOfflineTts *SherpaOnnxCreateOfflineTtsOHOS(
1827
+ const SherpaOnnxOfflineTtsConfig *config, NativeResourceManager *mgr);
1828
+
1829
+ SHERPA_ONNX_API const SherpaOnnxSpeakerEmbeddingExtractor *
1830
+ SherpaOnnxCreateSpeakerEmbeddingExtractorOHOS(
1831
+ const SherpaOnnxSpeakerEmbeddingExtractorConfig *config,
1832
+ NativeResourceManager *mgr);
1833
+
1834
+ SHERPA_ONNX_API const SherpaOnnxKeywordSpotter *
1835
+ SherpaOnnxCreateKeywordSpotterOHOS(const SherpaOnnxKeywordSpotterConfig *config,
1836
+ NativeResourceManager *mgr);
1837
+
1838
+ SHERPA_ONNX_API const SherpaOnnxOfflineSpeakerDiarization *
1839
+ SherpaOnnxCreateOfflineSpeakerDiarizationOHOS(
1840
+ const SherpaOnnxOfflineSpeakerDiarizationConfig *config,
1841
+ NativeResourceManager *mgr);
1842
+ #endif
1843
+
1844
+ #if defined(__GNUC__)
1845
+ #pragma GCC diagnostic pop
1846
+ #endif
1847
+
1848
+ #ifdef __cplusplus
1849
+ } /* extern "C" */
1850
+ #endif
1851
+
1852
+ #endif // SHERPA_ONNX_C_API_C_API_H_