react-native-executorch 0.7.0-nightly-b4770df-20260205 → 0.7.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 (296) hide show
  1. package/common/rnexecutorch/ErrorCodes.h +15 -30
  2. package/common/rnexecutorch/host_objects/ModelHostObject.h +5 -0
  3. package/common/rnexecutorch/models/llm/LLM.cpp +7 -0
  4. package/common/rnexecutorch/models/llm/LLM.h +1 -0
  5. package/lib/module/constants/llmDefaults.js +31 -0
  6. package/lib/module/constants/llmDefaults.js.map +1 -1
  7. package/lib/module/constants/modelUrls.js +220 -0
  8. package/lib/module/constants/modelUrls.js.map +1 -1
  9. package/lib/module/constants/ocr/models.js +255 -73
  10. package/lib/module/constants/ocr/models.js.map +1 -1
  11. package/lib/module/constants/ocr/symbols.js +4 -0
  12. package/lib/module/constants/ocr/symbols.js.map +1 -1
  13. package/lib/module/constants/tts/models.js +6 -2
  14. package/lib/module/constants/tts/models.js.map +1 -1
  15. package/lib/module/constants/tts/voices.js +27 -3
  16. package/lib/module/constants/tts/voices.js.map +1 -1
  17. package/lib/module/constants/versions.js +2 -2
  18. package/lib/module/controllers/LLMController.js +9 -0
  19. package/lib/module/controllers/LLMController.js.map +1 -1
  20. package/lib/module/errors/ErrorCodes.js +54 -0
  21. package/lib/module/errors/ErrorCodes.js.map +1 -1
  22. package/lib/module/errors/errorUtils.js +30 -6
  23. package/lib/module/errors/errorUtils.js.map +1 -1
  24. package/lib/module/hooks/computer_vision/useClassification.js +7 -0
  25. package/lib/module/hooks/computer_vision/useClassification.js.map +1 -1
  26. package/lib/module/hooks/computer_vision/useImageEmbeddings.js +8 -0
  27. package/lib/module/hooks/computer_vision/useImageEmbeddings.js.map +1 -1
  28. package/lib/module/hooks/computer_vision/useImageSegmentation.js +7 -0
  29. package/lib/module/hooks/computer_vision/useImageSegmentation.js.map +1 -1
  30. package/lib/module/hooks/computer_vision/useOCR.js +7 -0
  31. package/lib/module/hooks/computer_vision/useOCR.js.map +1 -1
  32. package/lib/module/hooks/computer_vision/useObjectDetection.js +7 -0
  33. package/lib/module/hooks/computer_vision/useObjectDetection.js.map +1 -1
  34. package/lib/module/hooks/computer_vision/useStyleTransfer.js +7 -0
  35. package/lib/module/hooks/computer_vision/useStyleTransfer.js.map +1 -1
  36. package/lib/module/hooks/computer_vision/useTextToImage.js +7 -0
  37. package/lib/module/hooks/computer_vision/useTextToImage.js.map +1 -1
  38. package/lib/module/hooks/computer_vision/useVerticalOCR.js +7 -0
  39. package/lib/module/hooks/computer_vision/useVerticalOCR.js.map +1 -1
  40. package/lib/module/hooks/general/useExecutorchModule.js +8 -0
  41. package/lib/module/hooks/general/useExecutorchModule.js.map +1 -1
  42. package/lib/module/hooks/natural_language_processing/useLLM.js +11 -3
  43. package/lib/module/hooks/natural_language_processing/useLLM.js.map +1 -1
  44. package/lib/module/hooks/natural_language_processing/useSpeechToText.js +8 -0
  45. package/lib/module/hooks/natural_language_processing/useSpeechToText.js.map +1 -1
  46. package/lib/module/hooks/natural_language_processing/useTextEmbeddings.js +7 -0
  47. package/lib/module/hooks/natural_language_processing/useTextEmbeddings.js.map +1 -1
  48. package/lib/module/hooks/natural_language_processing/useTextToSpeech.js +8 -0
  49. package/lib/module/hooks/natural_language_processing/useTextToSpeech.js.map +1 -1
  50. package/lib/module/hooks/natural_language_processing/useTokenizer.js +7 -0
  51. package/lib/module/hooks/natural_language_processing/useTokenizer.js.map +1 -1
  52. package/lib/module/hooks/natural_language_processing/useVAD.js +7 -0
  53. package/lib/module/hooks/natural_language_processing/useVAD.js.map +1 -1
  54. package/lib/module/hooks/useModule.js +12 -0
  55. package/lib/module/hooks/useModule.js.map +1 -1
  56. package/lib/module/index.js +10 -1
  57. package/lib/module/index.js.map +1 -1
  58. package/lib/module/modules/BaseModule.js +22 -0
  59. package/lib/module/modules/BaseModule.js.map +1 -1
  60. package/lib/module/modules/computer_vision/ClassificationModule.js +20 -0
  61. package/lib/module/modules/computer_vision/ClassificationModule.js.map +1 -1
  62. package/lib/module/modules/computer_vision/ImageEmbeddingsModule.js +19 -0
  63. package/lib/module/modules/computer_vision/ImageEmbeddingsModule.js.map +1 -1
  64. package/lib/module/modules/computer_vision/ImageSegmentationModule.js +22 -0
  65. package/lib/module/modules/computer_vision/ImageSegmentationModule.js.map +1 -1
  66. package/lib/module/modules/computer_vision/OCRModule.js +26 -0
  67. package/lib/module/modules/computer_vision/OCRModule.js.map +1 -1
  68. package/lib/module/modules/computer_vision/ObjectDetectionModule.js +22 -0
  69. package/lib/module/modules/computer_vision/ObjectDetectionModule.js.map +1 -1
  70. package/lib/module/modules/computer_vision/StyleTransferModule.js +20 -0
  71. package/lib/module/modules/computer_vision/StyleTransferModule.js.map +1 -1
  72. package/lib/module/modules/computer_vision/TextToImageModule.js +33 -0
  73. package/lib/module/modules/computer_vision/TextToImageModule.js.map +1 -1
  74. package/lib/module/modules/computer_vision/VerticalOCRModule.js +27 -0
  75. package/lib/module/modules/computer_vision/VerticalOCRModule.js.map +1 -1
  76. package/lib/module/modules/general/ExecutorchModule.js +21 -0
  77. package/lib/module/modules/general/ExecutorchModule.js.map +1 -1
  78. package/lib/module/modules/natural_language_processing/LLMModule.js +104 -0
  79. package/lib/module/modules/natural_language_processing/LLMModule.js.map +1 -1
  80. package/lib/module/modules/natural_language_processing/SpeechToTextModule.js +67 -21
  81. package/lib/module/modules/natural_language_processing/SpeechToTextModule.js.map +1 -1
  82. package/lib/module/modules/natural_language_processing/TextEmbeddingsModule.js +21 -0
  83. package/lib/module/modules/natural_language_processing/TextEmbeddingsModule.js.map +1 -1
  84. package/lib/module/modules/natural_language_processing/TextToSpeechModule.js +40 -0
  85. package/lib/module/modules/natural_language_processing/TextToSpeechModule.js.map +1 -1
  86. package/lib/module/modules/natural_language_processing/TokenizerModule.js +54 -2
  87. package/lib/module/modules/natural_language_processing/TokenizerModule.js.map +1 -1
  88. package/lib/module/modules/natural_language_processing/VADModule.js +20 -0
  89. package/lib/module/modules/natural_language_processing/VADModule.js.map +1 -1
  90. package/lib/module/types/classification.js +4 -0
  91. package/lib/module/types/classification.js.map +1 -0
  92. package/lib/module/types/common.js +96 -0
  93. package/lib/module/types/common.js.map +1 -1
  94. package/lib/module/types/executorchModule.js +4 -0
  95. package/lib/module/types/executorchModule.js.map +1 -0
  96. package/lib/module/types/imageEmbeddings.js +4 -0
  97. package/lib/module/types/imageEmbeddings.js.map +1 -0
  98. package/lib/module/types/imageSegmentation.js +22 -1
  99. package/lib/module/types/imageSegmentation.js.map +1 -1
  100. package/lib/module/types/llm.js +80 -2
  101. package/lib/module/types/llm.js.map +1 -1
  102. package/lib/module/types/objectDetection.js +42 -2
  103. package/lib/module/types/objectDetection.js.map +1 -1
  104. package/lib/module/types/styleTransfer.js +4 -0
  105. package/lib/module/types/styleTransfer.js.map +1 -0
  106. package/lib/module/types/textEmbeddings.js +4 -0
  107. package/lib/module/types/textEmbeddings.js.map +1 -0
  108. package/lib/module/types/tokenizer.js +4 -0
  109. package/lib/module/types/tokenizer.js.map +1 -0
  110. package/lib/module/types/tti.js +4 -0
  111. package/lib/module/types/tti.js.map +1 -0
  112. package/lib/module/types/vad.js +2 -0
  113. package/lib/module/utils/ResourceFetcher.js +63 -0
  114. package/lib/module/utils/ResourceFetcher.js.map +1 -1
  115. package/lib/module/utils/llm.js +24 -1
  116. package/lib/module/utils/llm.js.map +1 -1
  117. package/lib/typescript/constants/llmDefaults.d.ts +27 -0
  118. package/lib/typescript/constants/llmDefaults.d.ts.map +1 -1
  119. package/lib/typescript/constants/modelUrls.d.ts +165 -0
  120. package/lib/typescript/constants/modelUrls.d.ts.map +1 -1
  121. package/lib/typescript/constants/ocr/models.d.ts +189 -315
  122. package/lib/typescript/constants/ocr/models.d.ts.map +1 -1
  123. package/lib/typescript/constants/ocr/symbols.d.ts +3 -0
  124. package/lib/typescript/constants/ocr/symbols.d.ts.map +1 -1
  125. package/lib/typescript/constants/tts/models.d.ts +4 -0
  126. package/lib/typescript/constants/tts/models.d.ts.map +1 -1
  127. package/lib/typescript/constants/tts/voices.d.ts +24 -0
  128. package/lib/typescript/constants/tts/voices.d.ts.map +1 -1
  129. package/lib/typescript/constants/versions.d.ts +2 -2
  130. package/lib/typescript/controllers/LLMController.d.ts +2 -0
  131. package/lib/typescript/controllers/LLMController.d.ts.map +1 -1
  132. package/lib/typescript/errors/ErrorCodes.d.ts +54 -0
  133. package/lib/typescript/errors/ErrorCodes.d.ts.map +1 -1
  134. package/lib/typescript/errors/errorUtils.d.ts +9 -0
  135. package/lib/typescript/errors/errorUtils.d.ts.map +1 -1
  136. package/lib/typescript/hooks/computer_vision/useClassification.d.ts +9 -15
  137. package/lib/typescript/hooks/computer_vision/useClassification.d.ts.map +1 -1
  138. package/lib/typescript/hooks/computer_vision/useImageEmbeddings.d.ts +9 -15
  139. package/lib/typescript/hooks/computer_vision/useImageEmbeddings.d.ts.map +1 -1
  140. package/lib/typescript/hooks/computer_vision/useImageSegmentation.d.ts +9 -38
  141. package/lib/typescript/hooks/computer_vision/useImageSegmentation.d.ts.map +1 -1
  142. package/lib/typescript/hooks/computer_vision/useOCR.d.ts +9 -19
  143. package/lib/typescript/hooks/computer_vision/useOCR.d.ts.map +1 -1
  144. package/lib/typescript/hooks/computer_vision/useObjectDetection.d.ts +9 -15
  145. package/lib/typescript/hooks/computer_vision/useObjectDetection.d.ts.map +1 -1
  146. package/lib/typescript/hooks/computer_vision/useStyleTransfer.d.ts +9 -15
  147. package/lib/typescript/hooks/computer_vision/useStyleTransfer.d.ts.map +1 -1
  148. package/lib/typescript/hooks/computer_vision/useTextToImage.d.ts +9 -22
  149. package/lib/typescript/hooks/computer_vision/useTextToImage.d.ts.map +1 -1
  150. package/lib/typescript/hooks/computer_vision/useVerticalOCR.d.ts +9 -20
  151. package/lib/typescript/hooks/computer_vision/useVerticalOCR.d.ts.map +1 -1
  152. package/lib/typescript/hooks/general/useExecutorchModule.d.ts +9 -13
  153. package/lib/typescript/hooks/general/useExecutorchModule.d.ts.map +1 -1
  154. package/lib/typescript/hooks/natural_language_processing/useLLM.d.ts +9 -10
  155. package/lib/typescript/hooks/natural_language_processing/useLLM.d.ts.map +1 -1
  156. package/lib/typescript/hooks/natural_language_processing/useSpeechToText.d.ts +9 -19
  157. package/lib/typescript/hooks/natural_language_processing/useSpeechToText.d.ts.map +1 -1
  158. package/lib/typescript/hooks/natural_language_processing/useTextEmbeddings.d.ts +9 -16
  159. package/lib/typescript/hooks/natural_language_processing/useTextEmbeddings.d.ts.map +1 -1
  160. package/lib/typescript/hooks/natural_language_processing/useTextToSpeech.d.ts +9 -15
  161. package/lib/typescript/hooks/natural_language_processing/useTextToSpeech.d.ts.map +1 -1
  162. package/lib/typescript/hooks/natural_language_processing/useTokenizer.d.ts +9 -18
  163. package/lib/typescript/hooks/natural_language_processing/useTokenizer.d.ts.map +1 -1
  164. package/lib/typescript/hooks/natural_language_processing/useVAD.d.ts +9 -15
  165. package/lib/typescript/hooks/natural_language_processing/useVAD.d.ts.map +1 -1
  166. package/lib/typescript/hooks/useModule.d.ts +12 -0
  167. package/lib/typescript/hooks/useModule.d.ts.map +1 -1
  168. package/lib/typescript/index.d.ts +10 -1
  169. package/lib/typescript/index.d.ts.map +1 -1
  170. package/lib/typescript/modules/BaseModule.d.ts +20 -0
  171. package/lib/typescript/modules/BaseModule.d.ts.map +1 -1
  172. package/lib/typescript/modules/computer_vision/ClassificationModule.d.ts +21 -1
  173. package/lib/typescript/modules/computer_vision/ClassificationModule.d.ts.map +1 -1
  174. package/lib/typescript/modules/computer_vision/ImageEmbeddingsModule.d.ts +17 -0
  175. package/lib/typescript/modules/computer_vision/ImageEmbeddingsModule.d.ts.map +1 -1
  176. package/lib/typescript/modules/computer_vision/ImageSegmentationModule.d.ts +21 -3
  177. package/lib/typescript/modules/computer_vision/ImageSegmentationModule.d.ts.map +1 -1
  178. package/lib/typescript/modules/computer_vision/OCRModule.d.ts +25 -2
  179. package/lib/typescript/modules/computer_vision/OCRModule.d.ts.map +1 -1
  180. package/lib/typescript/modules/computer_vision/ObjectDetectionModule.d.ts +20 -0
  181. package/lib/typescript/modules/computer_vision/ObjectDetectionModule.d.ts.map +1 -1
  182. package/lib/typescript/modules/computer_vision/StyleTransferModule.d.ts +18 -0
  183. package/lib/typescript/modules/computer_vision/StyleTransferModule.d.ts.map +1 -1
  184. package/lib/typescript/modules/computer_vision/TextToImageModule.d.ts +29 -0
  185. package/lib/typescript/modules/computer_vision/TextToImageModule.d.ts.map +1 -1
  186. package/lib/typescript/modules/computer_vision/VerticalOCRModule.d.ts +26 -2
  187. package/lib/typescript/modules/computer_vision/VerticalOCRModule.d.ts.map +1 -1
  188. package/lib/typescript/modules/general/ExecutorchModule.d.ts +19 -0
  189. package/lib/typescript/modules/general/ExecutorchModule.d.ts.map +1 -1
  190. package/lib/typescript/modules/natural_language_processing/LLMModule.d.ts +97 -7
  191. package/lib/typescript/modules/natural_language_processing/LLMModule.d.ts.map +1 -1
  192. package/lib/typescript/modules/natural_language_processing/SpeechToTextModule.d.ts +62 -4
  193. package/lib/typescript/modules/natural_language_processing/SpeechToTextModule.d.ts.map +1 -1
  194. package/lib/typescript/modules/natural_language_processing/TextEmbeddingsModule.d.ts +19 -0
  195. package/lib/typescript/modules/natural_language_processing/TextEmbeddingsModule.d.ts.map +1 -1
  196. package/lib/typescript/modules/natural_language_processing/TextToSpeechModule.d.ts +37 -2
  197. package/lib/typescript/modules/natural_language_processing/TextToSpeechModule.d.ts.map +1 -1
  198. package/lib/typescript/modules/natural_language_processing/TokenizerModule.d.ts +47 -2
  199. package/lib/typescript/modules/natural_language_processing/TokenizerModule.d.ts.map +1 -1
  200. package/lib/typescript/modules/natural_language_processing/VADModule.d.ts +18 -0
  201. package/lib/typescript/modules/natural_language_processing/VADModule.d.ts.map +1 -1
  202. package/lib/typescript/types/classification.d.ts +50 -0
  203. package/lib/typescript/types/classification.d.ts.map +1 -0
  204. package/lib/typescript/types/common.d.ts +92 -0
  205. package/lib/typescript/types/common.d.ts.map +1 -1
  206. package/lib/typescript/types/executorchModule.d.ts +45 -0
  207. package/lib/typescript/types/executorchModule.d.ts.map +1 -0
  208. package/lib/typescript/types/imageEmbeddings.d.ts +48 -0
  209. package/lib/typescript/types/imageEmbeddings.d.ts.map +1 -0
  210. package/lib/typescript/types/imageSegmentation.d.ts +55 -0
  211. package/lib/typescript/types/imageSegmentation.d.ts.map +1 -1
  212. package/lib/typescript/types/llm.d.ts +193 -5
  213. package/lib/typescript/types/llm.d.ts.map +1 -1
  214. package/lib/typescript/types/objectDetection.d.ts +71 -2
  215. package/lib/typescript/types/objectDetection.d.ts.map +1 -1
  216. package/lib/typescript/types/ocr.d.ts +97 -2
  217. package/lib/typescript/types/ocr.d.ts.map +1 -1
  218. package/lib/typescript/types/stt.d.ts +114 -0
  219. package/lib/typescript/types/stt.d.ts.map +1 -1
  220. package/lib/typescript/types/styleTransfer.d.ts +48 -0
  221. package/lib/typescript/types/styleTransfer.d.ts.map +1 -0
  222. package/lib/typescript/types/textEmbeddings.d.ts +53 -0
  223. package/lib/typescript/types/textEmbeddings.d.ts.map +1 -0
  224. package/lib/typescript/types/tokenizer.d.ts +75 -0
  225. package/lib/typescript/types/tokenizer.d.ts.map +1 -0
  226. package/lib/typescript/types/tti.d.ts +74 -0
  227. package/lib/typescript/types/tti.d.ts.map +1 -0
  228. package/lib/typescript/types/tts.d.ts +77 -0
  229. package/lib/typescript/types/tts.d.ts.map +1 -1
  230. package/lib/typescript/types/vad.d.ts +53 -0
  231. package/lib/typescript/types/vad.d.ts.map +1 -1
  232. package/lib/typescript/utils/ResourceFetcher.d.ts +55 -0
  233. package/lib/typescript/utils/ResourceFetcher.d.ts.map +1 -1
  234. package/lib/typescript/utils/llm.d.ts +22 -0
  235. package/lib/typescript/utils/llm.d.ts.map +1 -1
  236. package/package.json +1 -1
  237. package/src/constants/llmDefaults.ts +27 -0
  238. package/src/constants/modelUrls.ts +166 -0
  239. package/src/constants/ocr/models.ts +192 -266
  240. package/src/constants/ocr/symbols.ts +3 -0
  241. package/src/constants/tts/models.ts +6 -2
  242. package/src/constants/tts/voices.ts +27 -3
  243. package/src/constants/versions.ts +2 -2
  244. package/src/controllers/LLMController.ts +15 -0
  245. package/src/errors/ErrorCodes.ts +54 -0
  246. package/src/errors/errorUtils.ts +37 -17
  247. package/src/hooks/computer_vision/useClassification.ts +15 -7
  248. package/src/hooks/computer_vision/useImageEmbeddings.ts +15 -7
  249. package/src/hooks/computer_vision/useImageSegmentation.ts +15 -7
  250. package/src/hooks/computer_vision/useOCR.ts +9 -21
  251. package/src/hooks/computer_vision/useObjectDetection.ts +15 -7
  252. package/src/hooks/computer_vision/useStyleTransfer.ts +15 -7
  253. package/src/hooks/computer_vision/useTextToImage.ts +9 -26
  254. package/src/hooks/computer_vision/useVerticalOCR.ts +9 -19
  255. package/src/hooks/general/useExecutorchModule.ts +12 -7
  256. package/src/hooks/natural_language_processing/useLLM.ts +24 -28
  257. package/src/hooks/natural_language_processing/useSpeechToText.ts +13 -5
  258. package/src/hooks/natural_language_processing/useTextEmbeddings.ts +15 -10
  259. package/src/hooks/natural_language_processing/useTextToSpeech.ts +10 -6
  260. package/src/hooks/natural_language_processing/useTokenizer.ts +10 -6
  261. package/src/hooks/natural_language_processing/useVAD.ts +9 -7
  262. package/src/hooks/useModule.ts +15 -0
  263. package/src/index.ts +10 -5
  264. package/src/modules/BaseModule.ts +20 -0
  265. package/src/modules/computer_vision/ClassificationModule.ts +19 -1
  266. package/src/modules/computer_vision/ImageEmbeddingsModule.ts +17 -0
  267. package/src/modules/computer_vision/ImageSegmentationModule.ts +21 -1
  268. package/src/modules/computer_vision/OCRModule.ts +25 -2
  269. package/src/modules/computer_vision/ObjectDetectionModule.ts +20 -0
  270. package/src/modules/computer_vision/StyleTransferModule.ts +18 -0
  271. package/src/modules/computer_vision/TextToImageModule.ts +29 -0
  272. package/src/modules/computer_vision/VerticalOCRModule.ts +26 -2
  273. package/src/modules/general/ExecutorchModule.ts +19 -0
  274. package/src/modules/natural_language_processing/LLMModule.ts +104 -18
  275. package/src/modules/natural_language_processing/SpeechToTextModule.ts +63 -39
  276. package/src/modules/natural_language_processing/TextEmbeddingsModule.ts +19 -0
  277. package/src/modules/natural_language_processing/TextToSpeechModule.ts +43 -2
  278. package/src/modules/natural_language_processing/TokenizerModule.ts +51 -3
  279. package/src/modules/natural_language_processing/VADModule.ts +18 -0
  280. package/src/types/classification.ts +51 -0
  281. package/src/types/common.ts +93 -0
  282. package/src/types/executorchModule.ts +50 -0
  283. package/src/types/imageEmbeddings.ts +51 -0
  284. package/src/types/imageSegmentation.ts +64 -1
  285. package/src/types/llm.ts +208 -11
  286. package/src/types/objectDetection.ts +79 -1
  287. package/src/types/ocr.ts +107 -2
  288. package/src/types/stt.ts +136 -1
  289. package/src/types/styleTransfer.ts +51 -0
  290. package/src/types/textEmbeddings.ts +58 -0
  291. package/src/types/tokenizer.ts +86 -0
  292. package/src/types/tti.ts +87 -0
  293. package/src/types/tts.ts +85 -2
  294. package/src/types/vad.ts +58 -0
  295. package/src/utils/ResourceFetcher.ts +55 -0
  296. package/src/utils/llm.ts +22 -1
@@ -1,16 +1,24 @@
1
1
  import { useEffect, useCallback, useState } from 'react';
2
2
  import { SpeechToTextModule } from '../../modules/natural_language_processing/SpeechToTextModule';
3
- import { DecodingOptions, SpeechToTextModelConfig } from '../../types/stt';
3
+ import {
4
+ DecodingOptions,
5
+ SpeechToTextType,
6
+ SpeechToTextProps,
7
+ } from '../../types/stt';
4
8
  import { RnExecutorchErrorCode } from '../../errors/ErrorCodes';
5
9
  import { RnExecutorchError, parseUnknownError } from '../../errors/errorUtils';
6
10
 
11
+ /**
12
+ * React hook for managing a Speech to Text (STT) instance.
13
+ *
14
+ * @category Hooks
15
+ * @param speechToTextProps - Configuration object containing `model` source and optional `preventLoad` flag.
16
+ * @returns Ready to use Speech to Text model.
17
+ */
7
18
  export const useSpeechToText = ({
8
19
  model,
9
20
  preventLoad = false,
10
- }: {
11
- model: SpeechToTextModelConfig;
12
- preventLoad?: boolean;
13
- }) => {
21
+ }: SpeechToTextProps): SpeechToTextType => {
14
22
  const [error, setError] = useState<null | RnExecutorchError>(null);
15
23
  const [isReady, setIsReady] = useState(false);
16
24
  const [isGenerating, setIsGenerating] = useState(false);
@@ -1,16 +1,21 @@
1
1
  import { TextEmbeddingsModule } from '../../modules/natural_language_processing/TextEmbeddingsModule';
2
- import { ResourceSource } from '../../types/common';
3
2
  import { useModule } from '../useModule';
3
+ import {
4
+ TextEmbeddingsType,
5
+ TextEmbeddingsProps,
6
+ } from '../../types/textEmbeddings';
4
7
 
5
- interface Props {
6
- model: {
7
- modelSource: ResourceSource;
8
- tokenizerSource: ResourceSource;
9
- };
10
- preventLoad?: boolean;
11
- }
12
-
13
- export const useTextEmbeddings = ({ model, preventLoad = false }: Props) =>
8
+ /**
9
+ * React hook for managing a Text Embeddings model instance.
10
+ *
11
+ * @category Hooks
12
+ * @param TextEmbeddingsProps - Configuration object containing `model` source and optional `preventLoad` flag.
13
+ * @returns Ready to use Text Embeddings model.
14
+ */
15
+ export const useTextEmbeddings = ({
16
+ model,
17
+ preventLoad = false,
18
+ }: TextEmbeddingsProps): TextEmbeddingsType =>
14
19
  useModule({
15
20
  module: TextEmbeddingsModule,
16
21
  model,
@@ -1,22 +1,26 @@
1
1
  import { useCallback, useEffect, useState } from 'react';
2
2
  import { TextToSpeechModule } from '../../modules/natural_language_processing/TextToSpeechModule';
3
3
  import {
4
- TextToSpeechConfig,
4
+ TextToSpeechProps,
5
5
  TextToSpeechInput,
6
+ TextToSpeechType,
6
7
  TextToSpeechStreamingInput,
7
8
  } from '../../types/tts';
8
9
  import { RnExecutorchErrorCode } from '../../errors/ErrorCodes';
9
10
  import { RnExecutorchError, parseUnknownError } from '../../errors/errorUtils';
10
11
 
11
- interface Props extends TextToSpeechConfig {
12
- preventLoad?: boolean;
13
- }
14
-
12
+ /**
13
+ * React hook for managing Text to Speech instance.
14
+ *
15
+ * @category Hooks
16
+ * @param TextToSpeechProps - Configuration object containing `model` source, `voice` and optional `preventLoad`.
17
+ * @returns Ready to use Text to Speech model.
18
+ */
15
19
  export const useTextToSpeech = ({
16
20
  model,
17
21
  voice,
18
22
  preventLoad = false,
19
- }: Props) => {
23
+ }: TextToSpeechProps): TextToSpeechType => {
20
24
  const [error, setError] = useState<RnExecutorchError | null>(null);
21
25
  const [isReady, setIsReady] = useState(false);
22
26
  const [isGenerating, setIsGenerating] = useState(false);
@@ -1,16 +1,20 @@
1
1
  import { useEffect, useState } from 'react';
2
2
  import { TokenizerModule } from '../../modules/natural_language_processing/TokenizerModule';
3
- import { ResourceSource } from '../../types/common';
4
3
  import { RnExecutorchErrorCode } from '../../errors/ErrorCodes';
5
4
  import { RnExecutorchError, parseUnknownError } from '../../errors/errorUtils';
5
+ import { TokenizerProps, TokenizerType } from '../../types/tokenizer';
6
6
 
7
+ /**
8
+ * React hook for managing a Tokenizer instance.
9
+ *
10
+ * @category Hooks
11
+ * @param tokenizerProps - Configuration object containing `tokenizer` source and optional `preventLoad` flag.
12
+ * @returns Ready to use Tokenizer model.
13
+ */
7
14
  export const useTokenizer = ({
8
15
  tokenizer,
9
16
  preventLoad = false,
10
- }: {
11
- tokenizer: { tokenizerSource: ResourceSource };
12
- preventLoad?: boolean;
13
- }) => {
17
+ }: TokenizerProps): TokenizerType => {
14
18
  const [error, setError] = useState<null | RnExecutorchError>(null);
15
19
  const [isReady, setIsReady] = useState(false);
16
20
  const [isGenerating, setIsGenerating] = useState(false);
@@ -36,7 +40,7 @@ export const useTokenizer = ({
36
40
  }, [tokenizerInstance, tokenizer.tokenizerSource, preventLoad]);
37
41
 
38
42
  const stateWrapper = <T extends (...args: any[]) => Promise<any>>(fn: T) => {
39
- return (...args: Parameters<T>): Promise<ReturnType<T>> => {
43
+ return (...args: Parameters<T>): Promise<Awaited<ReturnType<T>>> => {
40
44
  if (!isReady)
41
45
  throw new RnExecutorchError(
42
46
  RnExecutorchErrorCode.ModuleNotLoaded,
@@ -1,13 +1,15 @@
1
- import { ResourceSource } from '../../types/common';
2
1
  import { useModule } from '../useModule';
3
2
  import { VADModule } from '../../modules/natural_language_processing/VADModule';
3
+ import { VADType, VADProps } from '../../types/vad';
4
4
 
5
- interface Props {
6
- model: { modelSource: ResourceSource };
7
- preventLoad?: boolean;
8
- }
9
-
10
- export const useVAD = ({ model, preventLoad = false }: Props) =>
5
+ /**
6
+ * React hook for managing a VAD model instance.
7
+ *
8
+ * @category Hooks
9
+ * @param VADProps - Configuration object containing `model` source and optional `preventLoad` flag.
10
+ * @returns Ready to use VAD model.
11
+ */
12
+ export const useVAD = ({ model, preventLoad = false }: VADProps): VADType =>
11
13
  useModule({
12
14
  module: VADModule,
13
15
  model,
@@ -74,9 +74,24 @@ export const useModule = <
74
74
  };
75
75
 
76
76
  return {
77
+ /**
78
+ * Contains the error message if the model failed to load.
79
+ */
77
80
  error,
81
+
82
+ /**
83
+ * Indicates whether the model is ready.
84
+ */
78
85
  isReady,
86
+
87
+ /**
88
+ * Indicates whether the model is currently generating a response.
89
+ */
79
90
  isGenerating,
91
+
92
+ /**
93
+ * Represents the download progress as a value between 0 and 1, indicating the extent of the model file retrieval.
94
+ */
80
95
  downloadProgress,
81
96
  forward,
82
97
  };
package/src/index.ts CHANGED
@@ -104,6 +104,7 @@ export * from './modules/computer_vision/TextToImageModule';
104
104
 
105
105
  export * from './modules/natural_language_processing/LLMModule';
106
106
  export * from './modules/natural_language_processing/SpeechToTextModule';
107
+ export * from './modules/natural_language_processing/TextToSpeechModule';
107
108
  export * from './modules/natural_language_processing/TextEmbeddingsModule';
108
109
  export * from './modules/natural_language_processing/TokenizerModule';
109
110
  export * from './modules/natural_language_processing/VADModule';
@@ -121,11 +122,15 @@ export * from './types/imageSegmentation';
121
122
  export * from './types/llm';
122
123
  export * from './types/vad';
123
124
  export * from './types/common';
124
- export {
125
- SpeechToTextLanguage,
126
- SpeechToTextModelConfig,
127
- DecodingOptions,
128
- } from './types/stt';
125
+ export * from './types/stt';
126
+ export * from './types/textEmbeddings';
127
+ export * from './types/tts';
128
+ export * from './types/tokenizer';
129
+ export * from './types/executorchModule';
130
+ export * from './types/classification';
131
+ export * from './types/imageEmbeddings';
132
+ export * from './types/styleTransfer';
133
+ export * from './types/tti';
129
134
 
130
135
  // constants
131
136
  export * from './constants/modelUrls';
@@ -2,6 +2,9 @@ import { ResourceSource } from '../types/common';
2
2
  import { TensorPtr } from '../types/common';
3
3
 
4
4
  export abstract class BaseModule {
5
+ /**
6
+ * Native module instance
7
+ */
5
8
  nativeModule: any = null;
6
9
 
7
10
  abstract load(
@@ -10,14 +13,31 @@ export abstract class BaseModule {
10
13
  ...args: any[]
11
14
  ): Promise<void>;
12
15
 
16
+ /**
17
+ * Runs the model's forward method with the given input tensors.
18
+ * It returns the output tensors that mimic the structure of output from ExecuTorch.
19
+ *
20
+ * @param inputTensor - Array of input tensors.
21
+ * @returns Array of output tensors.
22
+ */
13
23
  protected async forwardET(inputTensor: TensorPtr[]): Promise<TensorPtr[]> {
14
24
  return await this.nativeModule.forward(inputTensor);
15
25
  }
16
26
 
27
+ /**
28
+ * Gets the input shape for a given method and index.
29
+ *
30
+ * @param methodName method name
31
+ * @param index index of the argument which shape is requested
32
+ * @returns The input shape as an array of numbers.
33
+ */
17
34
  async getInputShape(methodName: string, index: number): Promise<number[]> {
18
35
  return this.nativeModule.getInputShape(methodName, index);
19
36
  }
20
37
 
38
+ /**
39
+ * Unloads the model from memory.
40
+ */
21
41
  delete() {
22
42
  if (this.nativeModule !== null) {
23
43
  this.nativeModule.unload();
@@ -4,7 +4,19 @@ import { BaseModule } from '../BaseModule';
4
4
  import { RnExecutorchErrorCode } from '../../errors/ErrorCodes';
5
5
  import { RnExecutorchError } from '../../errors/errorUtils';
6
6
 
7
+ /**
8
+ * Module for image classification tasks.
9
+ *
10
+ * @category Typescript API
11
+ */
7
12
  export class ClassificationModule extends BaseModule {
13
+ /**
14
+ * Loads the model, where `modelSource` is a string that specifies the location of the model binary.
15
+ * To track the download progress, supply a callback function `onDownloadProgressCallback`.
16
+ *
17
+ * @param model - Object containing `modelSource`.
18
+ * @param onDownloadProgressCallback - Optional callback to monitor download progress.
19
+ */
8
20
  async load(
9
21
  model: { modelSource: ResourceSource },
10
22
  onDownloadProgressCallback: (progress: number) => void = () => {}
@@ -22,7 +34,13 @@ export class ClassificationModule extends BaseModule {
22
34
  this.nativeModule = global.loadClassification(paths[0] || '');
23
35
  }
24
36
 
25
- async forward(imageSource: string) {
37
+ /**
38
+ * Executes the model's forward pass, where `imageSource` can be a fetchable resource or a Base64-encoded string.
39
+ *
40
+ * @param imageSource - The image source to be classified.
41
+ * @returns The classification result.
42
+ */
43
+ async forward(imageSource: string): Promise<{ [category: string]: number }> {
26
44
  if (this.nativeModule == null)
27
45
  throw new RnExecutorchError(
28
46
  RnExecutorchErrorCode.ModuleNotLoaded,
@@ -4,7 +4,18 @@ import { RnExecutorchErrorCode } from '../../errors/ErrorCodes';
4
4
  import { RnExecutorchError } from '../../errors/errorUtils';
5
5
  import { BaseModule } from '../BaseModule';
6
6
 
7
+ /**
8
+ * Module for generating image embeddings from input images.
9
+ *
10
+ * @category Typescript API
11
+ */
7
12
  export class ImageEmbeddingsModule extends BaseModule {
13
+ /**
14
+ * Loads the model, where `modelSource` is a string that specifies the location of the model binary.
15
+ *
16
+ * @param model - Object containing `modelSource`.
17
+ * @param onDownloadProgressCallback - Optional callback to monitor download progress.
18
+ */
8
19
  async load(
9
20
  model: { modelSource: ResourceSource },
10
21
  onDownloadProgressCallback: (progress: number) => void = () => {}
@@ -22,6 +33,12 @@ export class ImageEmbeddingsModule extends BaseModule {
22
33
  this.nativeModule = global.loadImageEmbeddings(paths[0] || '');
23
34
  }
24
35
 
36
+ /**
37
+ * Executes the model's forward pass. Returns an embedding array for a given sentence.
38
+ *
39
+ * @param imageSource - The image source (URI/URL) to image that will be embedded.
40
+ * @returns A Float32Array containing the image embeddings.
41
+ */
25
42
  async forward(imageSource: string): Promise<Float32Array> {
26
43
  if (this.nativeModule == null)
27
44
  throw new RnExecutorchError(
@@ -5,7 +5,19 @@ import { RnExecutorchErrorCode } from '../../errors/ErrorCodes';
5
5
  import { RnExecutorchError } from '../../errors/errorUtils';
6
6
  import { BaseModule } from '../BaseModule';
7
7
 
8
+ /**
9
+ * Module for image segmentation tasks.
10
+ *
11
+ * @category Typescript API
12
+ */
8
13
  export class ImageSegmentationModule extends BaseModule {
14
+ /**
15
+ * Loads the model, where `modelSource` is a string that specifies the location of the model binary.
16
+ * To track the download progress, supply a callback function `onDownloadProgressCallback`.
17
+ *
18
+ * @param model - Object containing `modelSource`.
19
+ * @param onDownloadProgressCallback - Optional callback to monitor download progress.
20
+ */
9
21
  async load(
10
22
  model: { modelSource: ResourceSource },
11
23
  onDownloadProgressCallback: (progress: number) => void = () => {}
@@ -23,11 +35,19 @@ export class ImageSegmentationModule extends BaseModule {
23
35
  this.nativeModule = global.loadImageSegmentation(paths[0] || '');
24
36
  }
25
37
 
38
+ /**
39
+ * Executes the model's forward pass
40
+ *
41
+ * @param imageSource - a fetchable resource or a Base64-encoded string.
42
+ * @param classesOfInterest - an optional list of DeeplabLabel used to indicate additional arrays of probabilities to output (see section "Running the model"). The default is an empty list.
43
+ * @param resize - an optional boolean to indicate whether the output should be resized to the original image dimensions, or left in the size of the model (see section "Running the model"). The default is `false`.
44
+ * @returns A dictionary where keys are `DeeplabLabel` and values are arrays of probabilities for each pixel belonging to the corresponding class.
45
+ */
26
46
  async forward(
27
47
  imageSource: string,
28
48
  classesOfInterest?: DeeplabLabel[],
29
49
  resize?: boolean
30
- ): Promise<{ [key in DeeplabLabel]?: number[] }> {
50
+ ): Promise<Partial<Record<DeeplabLabel, number[]>>> {
31
51
  if (this.nativeModule == null) {
32
52
  throw new RnExecutorchError(
33
53
  RnExecutorchErrorCode.ModuleNotLoaded,
@@ -1,7 +1,12 @@
1
1
  import { OCRController } from '../../controllers/OCRController';
2
2
  import { ResourceSource } from '../../types/common';
3
- import { OCRLanguage } from '../../types/ocr';
3
+ import { OCRDetection, OCRLanguage } from '../../types/ocr';
4
4
 
5
+ /**
6
+ * Module for Optical Character Recognition (OCR) tasks.
7
+ *
8
+ * @category Typescript API
9
+ */
5
10
  export class OCRModule {
6
11
  private controller: OCRController;
7
12
 
@@ -9,6 +14,14 @@ export class OCRModule {
9
14
  this.controller = new OCRController();
10
15
  }
11
16
 
17
+ /**
18
+ * Loads the model, where `detectorSource` is a string that specifies the location of the detector binary,
19
+ * `recognizerSource` is a string that specifies the location of the recognizer binary,
20
+ * and `language` is a parameter that specifies the language of the text to be recognized by the OCR.
21
+ *
22
+ * @param model - Object containing `detectorSource`, `recognizerSource`, and `language`.
23
+ * @param onDownloadProgressCallback - Optional callback to monitor download progress.
24
+ */
12
25
  async load(
13
26
  model: {
14
27
  detectorSource: ResourceSource;
@@ -25,10 +38,20 @@ export class OCRModule {
25
38
  );
26
39
  }
27
40
 
28
- async forward(imageSource: string) {
41
+ /**
42
+ * Executes the model's forward pass, where `imageSource` can be a fetchable resource or a Base64-encoded string.
43
+ *
44
+ * @param imageSource - The image source to be processed.
45
+ * @returns The OCR result as a `OCRDetection[]`.
46
+ */
47
+ async forward(imageSource: string): Promise<OCRDetection[]> {
29
48
  return await this.controller.forward(imageSource);
30
49
  }
31
50
 
51
+ /**
52
+ * Release the memory held by the module. Calling `forward` afterwards is invalid.
53
+ * Note that you cannot delete model while it's generating.
54
+ */
32
55
  delete() {
33
56
  this.controller.delete();
34
57
  }
@@ -5,7 +5,19 @@ import { RnExecutorchErrorCode } from '../../errors/ErrorCodes';
5
5
  import { RnExecutorchError } from '../../errors/errorUtils';
6
6
  import { BaseModule } from '../BaseModule';
7
7
 
8
+ /**
9
+ * Module for object detection tasks.
10
+ *
11
+ * @category Typescript API
12
+ */
8
13
  export class ObjectDetectionModule extends BaseModule {
14
+ /**
15
+ * Loads the model, where `modelSource` is a string that specifies the location of the model binary.
16
+ * To track the download progress, supply a callback function `onDownloadProgressCallback`.
17
+ *
18
+ * @param model - Object containing `modelSource`.
19
+ * @param onDownloadProgressCallback - Optional callback to monitor download progress.
20
+ */
9
21
  async load(
10
22
  model: { modelSource: ResourceSource },
11
23
  onDownloadProgressCallback: (progress: number) => void = () => {}
@@ -23,6 +35,14 @@ export class ObjectDetectionModule extends BaseModule {
23
35
  this.nativeModule = global.loadObjectDetection(paths[0] || '');
24
36
  }
25
37
 
38
+ /**
39
+ * Executes the model's forward pass, where `imageSource` can be a fetchable resource or a Base64-encoded string.
40
+ * `detectionThreshold` can be supplied to alter the sensitivity of the detection.
41
+ *
42
+ * @param imageSource - The image source to be processed.
43
+ * @param detectionThreshold - The threshold for detection sensitivity. Default is 0.7.
44
+ * @returns An array of Detection objects representing detected items in the image.
45
+ */
26
46
  async forward(
27
47
  imageSource: string,
28
48
  detectionThreshold: number = 0.7
@@ -4,7 +4,19 @@ import { RnExecutorchErrorCode } from '../../errors/ErrorCodes';
4
4
  import { RnExecutorchError } from '../../errors/errorUtils';
5
5
  import { BaseModule } from '../BaseModule';
6
6
 
7
+ /**
8
+ * Module for style transfer tasks.
9
+ *
10
+ * @category Typescript API
11
+ */
7
12
  export class StyleTransferModule extends BaseModule {
13
+ /**
14
+ * Loads the model, where `modelSource` is a string that specifies the location of the model binary.
15
+ * To track the download progress, supply a callback function `onDownloadProgressCallback`.
16
+ *
17
+ * @param model - Object containing `modelSource`.
18
+ * @param onDownloadProgressCallback - Optional callback to monitor download progress.
19
+ */
8
20
  async load(
9
21
  model: { modelSource: ResourceSource },
10
22
  onDownloadProgressCallback: (progress: number) => void = () => {}
@@ -22,6 +34,12 @@ export class StyleTransferModule extends BaseModule {
22
34
  this.nativeModule = global.loadStyleTransfer(paths[0] || '');
23
35
  }
24
36
 
37
+ /**
38
+ * Executes the model's forward pass, where `imageSource` can be a fetchable resource or a Base64-encoded string.
39
+ *
40
+ * @param imageSource - The image source to be processed.
41
+ * @returns The stylized image as a Base64-encoded string.
42
+ */
25
43
  async forward(imageSource: string): Promise<string> {
26
44
  if (this.nativeModule == null)
27
45
  throw new RnExecutorchError(
@@ -6,9 +6,19 @@ import { PNG } from 'pngjs/browser';
6
6
  import { RnExecutorchErrorCode } from '../../errors/ErrorCodes';
7
7
  import { RnExecutorchError } from '../../errors/errorUtils';
8
8
 
9
+ /**
10
+ * Module for text-to-image generation tasks.
11
+ *
12
+ * @category Typescript API
13
+ */
9
14
  export class TextToImageModule extends BaseModule {
10
15
  private inferenceCallback: (stepIdx: number) => void;
11
16
 
17
+ /**
18
+ * Creates a new instance of `TextToImageModule` with optional callback on inference step.
19
+ *
20
+ * @param inferenceCallback - Optional callback function that receives the current step index during inference.
21
+ */
12
22
  constructor(inferenceCallback?: (stepIdx: number) => void) {
13
23
  super();
14
24
  this.inferenceCallback = (stepIdx: number) => {
@@ -16,6 +26,12 @@ export class TextToImageModule extends BaseModule {
16
26
  };
17
27
  }
18
28
 
29
+ /**
30
+ * Loads the model from specified resources.
31
+ *
32
+ * @param model - Object containing sources for tokenizer, scheduler, encoder, unet, and decoder.
33
+ * @param onDownloadProgressCallback - Optional callback to monitor download progress.
34
+ */
19
35
  async load(
20
36
  model: {
21
37
  tokenizerSource: ResourceSource;
@@ -71,6 +87,16 @@ export class TextToImageModule extends BaseModule {
71
87
  );
72
88
  }
73
89
 
90
+ /**
91
+ * Runs the model to generate an image described by `input`, and conditioned by `seed`, performing `numSteps` inference steps.
92
+ * The resulting image, with dimensions `imageSize`×`imageSize` pixels, is returned as a base64-encoded string.
93
+ *
94
+ * @param input - The text prompt to generate the image from.
95
+ * @param imageSize - The desired width and height of the output image in pixels.
96
+ * @param numSteps - The number of inference steps to perform.
97
+ * @param seed - An optional seed for random number generation to ensure reproducibility.
98
+ * @returns A Base64-encoded string representing the generated PNG image.
99
+ */
74
100
  async forward(
75
101
  input: string,
76
102
  imageSize: number = 512,
@@ -95,6 +121,9 @@ export class TextToImageModule extends BaseModule {
95
121
  return pngString;
96
122
  }
97
123
 
124
+ /**
125
+ * Interrupts model generation. The model is stopped in the nearest step.
126
+ */
98
127
  public interrupt(): void {
99
128
  this.nativeModule.interrupt();
100
129
  }
@@ -1,7 +1,12 @@
1
1
  import { VerticalOCRController } from '../../controllers/VerticalOCRController';
2
2
  import { ResourceSource } from '../../types/common';
3
- import { OCRLanguage } from '../../types/ocr';
3
+ import { OCRDetection, OCRLanguage } from '../../types/ocr';
4
4
 
5
+ /**
6
+ * Module for Vertical Optical Character Recognition (Vertical OCR) tasks.
7
+ *
8
+ * @category Typescript API
9
+ */
5
10
  export class VerticalOCRModule {
6
11
  private controller: VerticalOCRController;
7
12
 
@@ -9,6 +14,15 @@ export class VerticalOCRModule {
9
14
  this.controller = new VerticalOCRController();
10
15
  }
11
16
 
17
+ /**
18
+ * Loads the model, where `detectorSource` is a string that specifies the location of the detector binary,
19
+ * `recognizerSource` is a string that specifies the location of the recognizer binary,
20
+ * and `language` is a parameter that specifies the language of the text to be recognized by the OCR.
21
+ *
22
+ * @param model - Object containing `detectorSource`, `recognizerSource`, and `language`.
23
+ * @param independentCharacters - Whether to treat characters independently during recognition.
24
+ * @param onDownloadProgressCallback - Optional callback to monitor download progress.
25
+ */
12
26
  async load(
13
27
  model: {
14
28
  detectorSource: ResourceSource;
@@ -27,10 +41,20 @@ export class VerticalOCRModule {
27
41
  );
28
42
  }
29
43
 
30
- async forward(imageSource: string) {
44
+ /**
45
+ * Executes the model's forward pass, where `imageSource` can be a fetchable resource or a Base64-encoded string.
46
+ *
47
+ * @param imageSource - The image source to be processed.
48
+ * @returns The OCR result as a `OCRDetection[]`.
49
+ */
50
+ async forward(imageSource: string): Promise<OCRDetection[]> {
31
51
  return await this.controller.forward(imageSource);
32
52
  }
33
53
 
54
+ /**
55
+ * Release the memory held by the module. Calling `forward` afterwards is invalid.
56
+ * Note that you cannot delete model while it's generating.
57
+ */
34
58
  delete() {
35
59
  this.controller.delete();
36
60
  }
@@ -5,7 +5,19 @@ import { ResourceFetcher } from '../../utils/ResourceFetcher';
5
5
  import { RnExecutorchErrorCode } from '../../errors/ErrorCodes';
6
6
  import { RnExecutorchError } from '../../errors/errorUtils';
7
7
 
8
+ /**
9
+ * General module for executing custom Executorch models.
10
+ *
11
+ * @category Typescript API
12
+ */
8
13
  export class ExecutorchModule extends BaseModule {
14
+ /**
15
+ * Loads the model, where `modelSource` is a string, number, or object that specifies the location of the model binary.
16
+ * Optionally accepts a download progress callback.
17
+ *
18
+ * @param modelSource - Source of the model to be loaded.
19
+ * @param onDownloadProgressCallback - Optional callback to monitor download progress.
20
+ */
9
21
  async load(
10
22
  modelSource: ResourceSource,
11
23
  onDownloadProgressCallback: (progress: number) => void = () => {}
@@ -23,6 +35,13 @@ export class ExecutorchModule extends BaseModule {
23
35
  this.nativeModule = global.loadExecutorchModule(paths[0] || '');
24
36
  }
25
37
 
38
+ /**
39
+ * Executes the model's forward pass, where input is an array of `TensorPtr` objects.
40
+ * If the inference is successful, an array of tensor pointers is returned.
41
+ *
42
+ * @param inputTensor - Array of input tensor pointers.
43
+ * @returns An array of output tensor pointers.
44
+ */
26
45
  async forward(inputTensor: TensorPtr[]): Promise<TensorPtr[]> {
27
46
  return await this.forwardET(inputTensor);
28
47
  }