react-native-executorch 0.3.3 → 0.4.2
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.
- package/README.md +30 -13
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/swmansion/rnexecutorch/ETModule.kt +1 -2
- package/android/src/main/java/com/swmansion/rnexecutorch/ImageSegmentation.kt +58 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/LLM.kt +13 -49
- package/android/src/main/java/com/swmansion/rnexecutorch/RnExecutorchPackage.kt +37 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/StyleTransfer.kt +1 -1
- package/android/src/main/java/com/swmansion/rnexecutorch/TextEmbeddings.kt +51 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/Tokenizer.kt +86 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/models/BaseModel.kt +3 -4
- package/android/src/main/java/com/swmansion/rnexecutorch/models/TextEmbeddings/TextEmbeddingsModel.kt +48 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/models/TextEmbeddings/TextEmbeddingsUtils.kt +37 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/models/classification/ClassificationModel.kt +1 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/models/imageSegmentation/Constants.kt +26 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/models/imageSegmentation/ImageSegmentationModel.kt +142 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/models/ocr/utils/RecognizerUtils.kt +3 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/models/{StyleTransferModel.kt → styleTransfer/StyleTransferModel.kt} +2 -1
- package/android/src/main/java/com/swmansion/rnexecutorch/utils/ArrayUtils.kt +0 -8
- package/android/src/main/java/com/swmansion/rnexecutorch/{models/classification/Utils.kt → utils/Numerical.kt} +1 -1
- package/ios/ExecutorchLib.xcframework/Info.plist +4 -4
- package/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/ExecutorchLib +0 -0
- package/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/Headers/HuggingFaceTokenizer.h +14 -0
- package/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/Headers/LLaMARunner.h +1 -23
- package/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/Info.plist +0 -0
- package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/ExecutorchLib +0 -0
- package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/Headers/HuggingFaceTokenizer.h +14 -0
- package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/Headers/LLaMARunner.h +1 -23
- package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/Info.plist +0 -0
- package/ios/RnExecutorch/Classification.mm +15 -18
- package/ios/RnExecutorch/ETModule.mm +6 -5
- package/ios/RnExecutorch/ImageSegmentation.h +5 -0
- package/ios/RnExecutorch/ImageSegmentation.mm +60 -0
- package/ios/RnExecutorch/LLM.mm +12 -53
- package/ios/RnExecutorch/OCR.mm +39 -43
- package/ios/RnExecutorch/ObjectDetection.mm +20 -20
- package/ios/RnExecutorch/SpeechToText.mm +6 -7
- package/ios/RnExecutorch/StyleTransfer.mm +16 -19
- package/ios/RnExecutorch/TextEmbeddings.h +5 -0
- package/ios/RnExecutorch/TextEmbeddings.mm +62 -0
- package/ios/RnExecutorch/Tokenizer.h +5 -0
- package/ios/RnExecutorch/Tokenizer.mm +83 -0
- package/ios/RnExecutorch/VerticalOCR.mm +36 -36
- package/ios/RnExecutorch/models/BaseModel.h +2 -5
- package/ios/RnExecutorch/models/BaseModel.mm +5 -15
- package/ios/RnExecutorch/models/classification/ClassificationModel.mm +2 -3
- package/ios/RnExecutorch/models/classification/Constants.mm +0 -1
- package/ios/RnExecutorch/models/image_segmentation/Constants.h +4 -0
- package/ios/RnExecutorch/models/image_segmentation/Constants.mm +8 -0
- package/ios/RnExecutorch/models/image_segmentation/ImageSegmentationModel.h +10 -0
- package/ios/RnExecutorch/models/image_segmentation/ImageSegmentationModel.mm +146 -0
- package/ios/RnExecutorch/models/object_detection/SSDLiteLargeModel.mm +1 -2
- package/ios/RnExecutorch/models/ocr/Detector.h +0 -2
- package/ios/RnExecutorch/models/ocr/Detector.mm +2 -1
- package/ios/RnExecutorch/models/ocr/RecognitionHandler.h +5 -4
- package/ios/RnExecutorch/models/ocr/RecognitionHandler.mm +9 -26
- package/ios/RnExecutorch/models/ocr/Recognizer.mm +1 -2
- package/ios/RnExecutorch/models/ocr/VerticalDetector.h +0 -2
- package/ios/RnExecutorch/models/ocr/VerticalDetector.mm +2 -1
- package/ios/RnExecutorch/models/ocr/utils/OCRUtils.mm +0 -1
- package/ios/RnExecutorch/models/stt/Moonshine.mm +1 -6
- package/ios/RnExecutorch/models/stt/SpeechToTextBaseModel.mm +7 -11
- package/ios/RnExecutorch/models/stt/Whisper.mm +0 -5
- package/ios/RnExecutorch/models/{StyleTransferModel.h → style_transfer/StyleTransferModel.h} +1 -1
- package/ios/RnExecutorch/models/{StyleTransferModel.mm → style_transfer/StyleTransferModel.mm} +2 -3
- package/ios/RnExecutorch/models/text_embeddings/TextEmbeddingsModel.h +15 -0
- package/ios/RnExecutorch/models/text_embeddings/TextEmbeddingsModel.mm +45 -0
- package/ios/RnExecutorch/models/text_embeddings/TextEmbeddingsUtils.h +8 -0
- package/ios/RnExecutorch/models/text_embeddings/TextEmbeddingsUtils.mm +49 -0
- package/ios/RnExecutorch/utils/Conversions.h +15 -0
- package/ios/RnExecutorch/utils/ImageProcessor.h +0 -1
- package/ios/RnExecutorch/{models/classification/Utils.h → utils/Numerical.h} +0 -2
- package/ios/RnExecutorch/{models/classification/Utils.mm → utils/Numerical.mm} +0 -2
- package/ios/RnExecutorch/utils/ObjectDetectionUtils.mm +0 -2
- package/ios/RnExecutorch/utils/SFFT.mm +1 -1
- package/ios/RnExecutorch/utils/ScalarType.h +0 -2
- package/lib/module/Error.js +16 -2
- package/lib/module/Error.js.map +1 -1
- package/lib/module/constants/{llamaDefaults.js → llmDefaults.js} +7 -3
- package/lib/module/constants/llmDefaults.js.map +1 -0
- package/lib/module/constants/modelUrls.js +88 -27
- package/lib/module/constants/modelUrls.js.map +1 -1
- package/lib/module/constants/ocr/models.js +290 -0
- package/lib/module/constants/ocr/models.js.map +1 -0
- package/lib/module/constants/ocr/symbols.js +137 -2
- package/lib/module/constants/ocr/symbols.js.map +1 -1
- package/lib/module/constants/sttDefaults.js +50 -25
- package/lib/module/constants/sttDefaults.js.map +1 -1
- package/lib/module/controllers/LLMController.js +205 -0
- package/lib/module/controllers/LLMController.js.map +1 -0
- package/lib/module/controllers/OCRController.js +5 -10
- package/lib/module/controllers/OCRController.js.map +1 -1
- package/lib/module/controllers/SpeechToTextController.js +225 -122
- package/lib/module/controllers/SpeechToTextController.js.map +1 -1
- package/lib/module/controllers/VerticalOCRController.js +6 -10
- package/lib/module/controllers/VerticalOCRController.js.map +1 -1
- package/lib/module/hooks/computer_vision/useClassification.js +8 -23
- package/lib/module/hooks/computer_vision/useClassification.js.map +1 -1
- package/lib/module/hooks/computer_vision/useImageSegmentation.js +13 -0
- package/lib/module/hooks/computer_vision/useImageSegmentation.js.map +1 -0
- package/lib/module/hooks/computer_vision/useOCR.js +11 -6
- package/lib/module/hooks/computer_vision/useOCR.js.map +1 -1
- package/lib/module/hooks/computer_vision/useObjectDetection.js +8 -23
- package/lib/module/hooks/computer_vision/useObjectDetection.js.map +1 -1
- package/lib/module/hooks/computer_vision/useStyleTransfer.js +8 -23
- package/lib/module/hooks/computer_vision/useStyleTransfer.js.map +1 -1
- package/lib/module/hooks/computer_vision/useVerticalOCR.js +10 -7
- package/lib/module/hooks/computer_vision/useVerticalOCR.js.map +1 -1
- package/lib/module/hooks/general/useExecutorchModule.js +8 -36
- package/lib/module/hooks/general/useExecutorchModule.js.map +1 -1
- package/lib/module/hooks/natural_language_processing/useLLM.js +54 -63
- package/lib/module/hooks/natural_language_processing/useLLM.js.map +1 -1
- package/lib/module/hooks/natural_language_processing/useSpeechToText.js +15 -11
- package/lib/module/hooks/natural_language_processing/useSpeechToText.js.map +1 -1
- package/lib/module/hooks/natural_language_processing/useTextEmbeddings.js +14 -0
- package/lib/module/hooks/natural_language_processing/useTextEmbeddings.js.map +1 -0
- package/lib/module/hooks/natural_language_processing/useTokenizer.js +54 -0
- package/lib/module/hooks/natural_language_processing/useTokenizer.js.map +1 -0
- package/lib/module/hooks/useModule.js +18 -62
- package/lib/module/hooks/useModule.js.map +1 -1
- package/lib/module/index.js +16 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/modules/BaseModule.js +9 -10
- package/lib/module/modules/BaseModule.js.map +1 -1
- package/lib/module/modules/computer_vision/ClassificationModule.js +8 -5
- package/lib/module/modules/computer_vision/ClassificationModule.js.map +1 -1
- package/lib/module/modules/computer_vision/ImageSegmentationModule.js +28 -0
- package/lib/module/modules/computer_vision/ImageSegmentationModule.js.map +1 -0
- package/lib/module/modules/computer_vision/ObjectDetectionModule.js +8 -5
- package/lib/module/modules/computer_vision/ObjectDetectionModule.js.map +1 -1
- package/lib/module/modules/computer_vision/StyleTransferModule.js +8 -5
- package/lib/module/modules/computer_vision/StyleTransferModule.js.map +1 -1
- package/lib/module/modules/general/ExecutorchModule.js +8 -5
- package/lib/module/modules/general/ExecutorchModule.js.map +1 -1
- package/lib/module/modules/natural_language_processing/LLMModule.js +46 -27
- package/lib/module/modules/natural_language_processing/LLMModule.js.map +1 -1
- package/lib/module/modules/natural_language_processing/SpeechToTextModule.js +8 -5
- package/lib/module/modules/natural_language_processing/SpeechToTextModule.js.map +1 -1
- package/lib/module/modules/natural_language_processing/TextEmbeddingsModule.js +14 -0
- package/lib/module/modules/natural_language_processing/TextEmbeddingsModule.js.map +1 -0
- package/lib/module/modules/natural_language_processing/TokenizerModule.js +26 -0
- package/lib/module/modules/natural_language_processing/TokenizerModule.js.map +1 -0
- package/lib/module/native/NativeClassification.js.map +1 -1
- package/lib/module/native/NativeImageSegmentation.js +5 -0
- package/lib/module/native/NativeImageSegmentation.js.map +1 -0
- package/lib/module/native/NativeLLM.js.map +1 -1
- package/lib/module/native/NativeTextEmbeddings.js +5 -0
- package/lib/module/native/NativeTextEmbeddings.js.map +1 -0
- package/lib/module/native/NativeTokenizer.js +5 -0
- package/lib/module/native/NativeTokenizer.js.map +1 -0
- package/lib/module/native/RnExecutorchModules.js +18 -113
- package/lib/module/native/RnExecutorchModules.js.map +1 -1
- package/lib/module/types/common.js.map +1 -1
- package/lib/module/types/imageSegmentation.js +29 -0
- package/lib/module/types/imageSegmentation.js.map +1 -0
- package/lib/module/types/llm.js +7 -0
- package/lib/module/types/llm.js.map +1 -0
- package/lib/module/types/{object_detection.js → objectDetection.js} +1 -1
- package/lib/module/types/objectDetection.js.map +1 -0
- package/lib/module/types/ocr.js +2 -0
- package/lib/module/types/stt.js +82 -0
- package/lib/module/types/stt.js.map +1 -0
- package/lib/module/utils/ResourceFetcher.js +156 -0
- package/lib/module/utils/ResourceFetcher.js.map +1 -0
- package/lib/module/utils/llm.js +25 -0
- package/lib/module/utils/llm.js.map +1 -0
- package/lib/module/utils/stt.js +22 -0
- package/lib/module/utils/stt.js.map +1 -0
- package/lib/typescript/Error.d.ts +4 -1
- package/lib/typescript/Error.d.ts.map +1 -1
- package/lib/typescript/constants/{llamaDefaults.d.ts → llmDefaults.d.ts} +5 -5
- package/lib/typescript/constants/llmDefaults.d.ts.map +1 -0
- package/lib/typescript/constants/modelUrls.d.ts +74 -28
- package/lib/typescript/constants/modelUrls.d.ts.map +1 -1
- package/lib/typescript/constants/ocr/models.d.ts +285 -0
- package/lib/typescript/constants/ocr/models.d.ts.map +1 -0
- package/lib/typescript/constants/ocr/symbols.d.ts +73 -1
- package/lib/typescript/constants/ocr/symbols.d.ts.map +1 -1
- package/lib/typescript/constants/sttDefaults.d.ts +8 -13
- package/lib/typescript/constants/sttDefaults.d.ts.map +1 -1
- package/lib/typescript/controllers/LLMController.d.ts +46 -0
- package/lib/typescript/controllers/LLMController.d.ts.map +1 -0
- package/lib/typescript/controllers/OCRController.d.ts.map +1 -1
- package/lib/typescript/controllers/SpeechToTextController.d.ts +30 -16
- package/lib/typescript/controllers/SpeechToTextController.d.ts.map +1 -1
- package/lib/typescript/controllers/VerticalOCRController.d.ts +1 -1
- package/lib/typescript/controllers/VerticalOCRController.d.ts.map +1 -1
- package/lib/typescript/hooks/computer_vision/useClassification.d.ts +5 -5
- package/lib/typescript/hooks/computer_vision/useClassification.d.ts.map +1 -1
- package/lib/typescript/hooks/computer_vision/useImageSegmentation.d.ts +37 -0
- package/lib/typescript/hooks/computer_vision/useImageSegmentation.d.ts.map +1 -0
- package/lib/typescript/hooks/computer_vision/useOCR.d.ts +2 -1
- package/lib/typescript/hooks/computer_vision/useOCR.d.ts.map +1 -1
- package/lib/typescript/hooks/computer_vision/useObjectDetection.d.ts +5 -4
- package/lib/typescript/hooks/computer_vision/useObjectDetection.d.ts.map +1 -1
- package/lib/typescript/hooks/computer_vision/useStyleTransfer.d.ts +4 -2
- package/lib/typescript/hooks/computer_vision/useStyleTransfer.d.ts.map +1 -1
- package/lib/typescript/hooks/computer_vision/useVerticalOCR.d.ts +2 -1
- package/lib/typescript/hooks/computer_vision/useVerticalOCR.d.ts.map +1 -1
- package/lib/typescript/hooks/general/useExecutorchModule.d.ts +5 -6
- package/lib/typescript/hooks/general/useExecutorchModule.d.ts.map +1 -1
- package/lib/typescript/hooks/natural_language_processing/useLLM.d.ts +6 -6
- package/lib/typescript/hooks/natural_language_processing/useLLM.d.ts.map +1 -1
- package/lib/typescript/hooks/natural_language_processing/useSpeechToText.d.ts +7 -3
- package/lib/typescript/hooks/natural_language_processing/useSpeechToText.d.ts.map +1 -1
- package/lib/typescript/hooks/natural_language_processing/useTextEmbeddings.d.ts +13 -0
- package/lib/typescript/hooks/natural_language_processing/useTextEmbeddings.d.ts.map +1 -0
- package/lib/typescript/hooks/natural_language_processing/useTokenizer.d.ts +16 -0
- package/lib/typescript/hooks/natural_language_processing/useTokenizer.d.ts.map +1 -0
- package/lib/typescript/hooks/useModule.d.ts +11 -10
- package/lib/typescript/hooks/useModule.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +15 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/modules/BaseModule.d.ts +4 -5
- package/lib/typescript/modules/BaseModule.d.ts.map +1 -1
- package/lib/typescript/modules/computer_vision/ClassificationModule.d.ts +7 -7
- package/lib/typescript/modules/computer_vision/ClassificationModule.d.ts.map +1 -1
- package/lib/typescript/modules/computer_vision/ImageSegmentationModule.d.ts +32 -0
- package/lib/typescript/modules/computer_vision/ImageSegmentationModule.d.ts.map +1 -0
- package/lib/typescript/modules/computer_vision/ObjectDetectionModule.d.ts +6 -5
- package/lib/typescript/modules/computer_vision/ObjectDetectionModule.d.ts.map +1 -1
- package/lib/typescript/modules/computer_vision/StyleTransferModule.d.ts +6 -5
- package/lib/typescript/modules/computer_vision/StyleTransferModule.d.ts.map +1 -1
- package/lib/typescript/modules/general/ExecutorchModule.d.ts +4 -3
- package/lib/typescript/modules/general/ExecutorchModule.d.ts.map +1 -1
- package/lib/typescript/modules/natural_language_processing/LLMModule.d.ts +19 -5
- package/lib/typescript/modules/natural_language_processing/LLMModule.d.ts.map +1 -1
- package/lib/typescript/modules/natural_language_processing/SpeechToTextModule.d.ts +7 -4
- package/lib/typescript/modules/natural_language_processing/SpeechToTextModule.d.ts.map +1 -1
- package/lib/typescript/modules/natural_language_processing/TextEmbeddingsModule.d.ts +8 -0
- package/lib/typescript/modules/natural_language_processing/TextEmbeddingsModule.d.ts.map +1 -0
- package/lib/typescript/modules/natural_language_processing/TokenizerModule.d.ts +12 -0
- package/lib/typescript/modules/natural_language_processing/TokenizerModule.d.ts.map +1 -0
- package/lib/typescript/native/NativeClassification.d.ts.map +1 -1
- package/lib/typescript/native/NativeImageSegmentation.d.ts +10 -0
- package/lib/typescript/native/NativeImageSegmentation.d.ts.map +1 -0
- package/lib/typescript/native/NativeLLM.d.ts +3 -4
- package/lib/typescript/native/NativeLLM.d.ts.map +1 -1
- package/lib/typescript/native/NativeObjectDetection.d.ts +1 -1
- package/lib/typescript/native/NativeObjectDetection.d.ts.map +1 -1
- package/lib/typescript/native/NativeSpeechToText.d.ts +2 -2
- package/lib/typescript/native/NativeSpeechToText.d.ts.map +1 -1
- package/lib/typescript/native/NativeTextEmbeddings.d.ts +8 -0
- package/lib/typescript/native/NativeTextEmbeddings.d.ts.map +1 -0
- package/lib/typescript/native/NativeTokenizer.d.ts +12 -0
- package/lib/typescript/native/NativeTokenizer.d.ts.map +1 -0
- package/lib/typescript/native/RnExecutorchModules.d.ts +18 -41
- package/lib/typescript/native/RnExecutorchModules.d.ts.map +1 -1
- package/lib/typescript/types/common.d.ts +1 -26
- package/lib/typescript/types/common.d.ts.map +1 -1
- package/lib/typescript/types/imageSegmentation.d.ts +25 -0
- package/lib/typescript/types/imageSegmentation.d.ts.map +1 -0
- package/lib/typescript/types/llm.d.ts +38 -0
- package/lib/typescript/types/llm.d.ts.map +1 -0
- package/lib/typescript/types/{object_detection.d.ts → objectDetection.d.ts} +1 -1
- package/lib/typescript/types/objectDetection.d.ts.map +1 -0
- package/lib/typescript/types/ocr.d.ts +2 -1
- package/lib/typescript/types/ocr.d.ts.map +1 -1
- package/lib/typescript/types/stt.d.ts +91 -0
- package/lib/typescript/types/stt.d.ts.map +1 -0
- package/lib/typescript/utils/ResourceFetcher.d.ts +17 -0
- package/lib/typescript/utils/ResourceFetcher.d.ts.map +1 -0
- package/lib/typescript/utils/llm.d.ts +3 -0
- package/lib/typescript/utils/llm.d.ts.map +1 -0
- package/lib/typescript/utils/stt.d.ts +2 -0
- package/lib/typescript/utils/stt.d.ts.map +1 -0
- package/package.json +13 -49
- package/react-native-executorch.podspec +1 -1
- package/src/Error.ts +16 -3
- package/src/constants/llmDefaults.ts +14 -0
- package/src/constants/modelUrls.ts +146 -39
- package/src/constants/ocr/models.ts +453 -0
- package/src/constants/ocr/symbols.ts +147 -3
- package/src/constants/sttDefaults.ts +55 -37
- package/src/controllers/LLMController.ts +286 -0
- package/src/controllers/OCRController.ts +14 -28
- package/src/controllers/SpeechToTextController.ts +318 -180
- package/src/controllers/VerticalOCRController.ts +17 -32
- package/src/hooks/computer_vision/useClassification.ts +11 -26
- package/src/hooks/computer_vision/useImageSegmentation.ts +18 -0
- package/src/hooks/computer_vision/useOCR.ts +17 -5
- package/src/hooks/computer_vision/useObjectDetection.ts +10 -24
- package/src/hooks/computer_vision/useStyleTransfer.ts +9 -25
- package/src/hooks/computer_vision/useVerticalOCR.ts +11 -4
- package/src/hooks/general/useExecutorchModule.ts +10 -50
- package/src/hooks/natural_language_processing/useLLM.ts +80 -97
- package/src/hooks/natural_language_processing/useSpeechToText.ts +39 -12
- package/src/hooks/natural_language_processing/useTextEmbeddings.ts +18 -0
- package/src/hooks/natural_language_processing/useTokenizer.ts +61 -0
- package/src/hooks/useModule.ts +32 -92
- package/src/index.tsx +16 -2
- package/src/modules/BaseModule.ts +16 -26
- package/src/modules/computer_vision/ClassificationModule.ts +13 -8
- package/src/modules/computer_vision/ImageSegmentationModule.ts +39 -0
- package/src/modules/computer_vision/ObjectDetectionModule.ts +13 -8
- package/src/modules/computer_vision/StyleTransferModule.ts +13 -8
- package/src/modules/general/ExecutorchModule.ts +11 -6
- package/src/modules/natural_language_processing/LLMModule.ts +64 -51
- package/src/modules/natural_language_processing/SpeechToTextModule.ts +25 -10
- package/src/modules/natural_language_processing/TextEmbeddingsModule.ts +18 -0
- package/src/modules/natural_language_processing/TokenizerModule.ts +34 -0
- package/src/native/NativeClassification.ts +0 -1
- package/src/native/NativeImageSegmentation.ts +14 -0
- package/src/native/NativeLLM.ts +3 -10
- package/src/native/NativeObjectDetection.ts +1 -1
- package/src/native/NativeSpeechToText.ts +2 -2
- package/src/native/NativeTextEmbeddings.ts +9 -0
- package/src/native/NativeTokenizer.ts +13 -0
- package/src/native/RnExecutorchModules.ts +54 -234
- package/src/types/common.ts +1 -44
- package/src/types/imageSegmentation.ts +25 -0
- package/src/types/llm.ts +57 -0
- package/src/types/ocr.ts +3 -1
- package/src/types/stt.ts +93 -0
- package/src/utils/ResourceFetcher.ts +196 -0
- package/src/utils/llm.ts +34 -0
- package/src/utils/stt.ts +28 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/utils/llms/ConversationManager.kt +0 -68
- package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/_CodeSignature/CodeResources +0 -124
- package/ios/RnExecutorch/utils/llms/Constants.h +0 -6
- package/ios/RnExecutorch/utils/llms/Constants.mm +0 -23
- package/ios/RnExecutorch/utils/llms/ConversationManager.h +0 -26
- package/ios/RnExecutorch/utils/llms/ConversationManager.mm +0 -71
- package/lib/module/constants/llamaDefaults.js.map +0 -1
- package/lib/module/modules/computer_vision/BaseCVModule.js +0 -14
- package/lib/module/modules/computer_vision/BaseCVModule.js.map +0 -1
- package/lib/module/types/object_detection.js.map +0 -1
- package/lib/module/utils/fetchResource.js +0 -93
- package/lib/module/utils/fetchResource.js.map +0 -1
- package/lib/module/utils/listDownloadedResources.js +0 -13
- package/lib/module/utils/listDownloadedResources.js.map +0 -1
- package/lib/typescript/constants/llamaDefaults.d.ts.map +0 -1
- package/lib/typescript/modules/computer_vision/BaseCVModule.d.ts +0 -9
- package/lib/typescript/modules/computer_vision/BaseCVModule.d.ts.map +0 -1
- package/lib/typescript/types/object_detection.d.ts.map +0 -1
- package/lib/typescript/utils/fetchResource.d.ts +0 -3
- package/lib/typescript/utils/fetchResource.d.ts.map +0 -1
- package/lib/typescript/utils/listDownloadedResources.d.ts +0 -3
- package/lib/typescript/utils/listDownloadedResources.d.ts.map +0 -1
- package/src/constants/llamaDefaults.ts +0 -9
- package/src/modules/computer_vision/BaseCVModule.ts +0 -22
- package/src/utils/fetchResource.ts +0 -106
- package/src/utils/listDownloadedResources.ts +0 -12
- /package/src/types/{object_detection.ts → objectDetection.ts} +0 -0
|
@@ -5,52 +5,62 @@ import {
|
|
|
5
5
|
WHISPER_TINY_ENCODER,
|
|
6
6
|
WHISPER_TINY_DECODER,
|
|
7
7
|
WHISPER_TOKENIZER,
|
|
8
|
+
WHISPER_TINY_MULTILINGUAL_ENCODER,
|
|
9
|
+
WHISPER_TINY_MULTILINGUAL_DECODER,
|
|
10
|
+
WHISPER_TINY_MULTILINGUAL_TOKENIZER,
|
|
8
11
|
} from './modelUrls';
|
|
12
|
+
import { AvailableModels, ModelConfig } from '../types/stt';
|
|
9
13
|
|
|
10
14
|
export const SAMPLE_RATE = 16_000;
|
|
11
15
|
export const SECOND = SAMPLE_RATE;
|
|
12
16
|
export const HAMMING_DIST_THRESHOLD = 1;
|
|
13
17
|
|
|
14
|
-
|
|
18
|
+
const whisperTinyModelConfig = {
|
|
15
19
|
sources: {
|
|
16
|
-
encoder:
|
|
17
|
-
decoder:
|
|
18
|
-
}
|
|
20
|
+
encoder: WHISPER_TINY_ENCODER,
|
|
21
|
+
decoder: WHISPER_TINY_DECODER,
|
|
22
|
+
},
|
|
19
23
|
tokenizer: {
|
|
20
|
-
source:
|
|
21
|
-
|
|
22
|
-
eos:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
24
|
+
source: WHISPER_TOKENIZER,
|
|
25
|
+
bos: 50257, // FIXME: this is a placeholder and needs to be changed
|
|
26
|
+
eos: 50256, // FIXME: this is a placeholder and needs to be changed
|
|
27
|
+
},
|
|
28
|
+
isMultilingual: false,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const moonshineTinyModelConfig = {
|
|
32
|
+
sources: {
|
|
33
|
+
encoder: MOONSHINE_TINY_ENCODER,
|
|
34
|
+
decoder: MOONSHINE_TINY_DECODER,
|
|
35
|
+
},
|
|
36
|
+
tokenizer: {
|
|
37
|
+
source: MOONSHINE_TOKENIZER,
|
|
38
|
+
bos: 1, // FIXME: this is a placeholder and needs to be changed
|
|
39
|
+
eos: 2, // FIXME: this is a placeholder and needs to be changed
|
|
40
|
+
},
|
|
41
|
+
isMultilingual: false,
|
|
42
|
+
};
|
|
26
43
|
|
|
27
|
-
|
|
28
|
-
{
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
source: WHISPER_TOKENIZER,
|
|
48
|
-
sos: 50257,
|
|
49
|
-
eos: 50256,
|
|
50
|
-
specialChar: 'Ġ',
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
};
|
|
44
|
+
const whisperTinyMultilingualModelConfig = {
|
|
45
|
+
sources: {
|
|
46
|
+
encoder: WHISPER_TINY_MULTILINGUAL_ENCODER,
|
|
47
|
+
decoder: WHISPER_TINY_MULTILINGUAL_DECODER,
|
|
48
|
+
},
|
|
49
|
+
tokenizer: {
|
|
50
|
+
source: WHISPER_TINY_MULTILINGUAL_TOKENIZER,
|
|
51
|
+
bos: 50258, // FIXME: this is a placeholder and needs to be changed
|
|
52
|
+
eos: 50257, // FIXME: this is a placeholder and needs to be changed
|
|
53
|
+
},
|
|
54
|
+
isMultilingual: true,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const MODEL_CONFIGS: {
|
|
58
|
+
[key in AvailableModels]: ModelConfig;
|
|
59
|
+
} = {
|
|
60
|
+
moonshine: moonshineTinyModelConfig,
|
|
61
|
+
whisper: whisperTinyModelConfig,
|
|
62
|
+
whisperMultilingual: whisperTinyMultilingualModelConfig,
|
|
63
|
+
};
|
|
54
64
|
|
|
55
65
|
export const MODES = {
|
|
56
66
|
fast: {
|
|
@@ -66,3 +76,11 @@ export const MODES = {
|
|
|
66
76
|
overlapSeconds: 3,
|
|
67
77
|
},
|
|
68
78
|
};
|
|
79
|
+
|
|
80
|
+
export const NUM_TOKENS_TO_TRIM = 3;
|
|
81
|
+
|
|
82
|
+
export enum STREAMING_ACTION {
|
|
83
|
+
START,
|
|
84
|
+
DATA,
|
|
85
|
+
STOP,
|
|
86
|
+
}
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { EventSubscription } from 'react-native';
|
|
2
|
+
import { ResourceSource } from '../types/common';
|
|
3
|
+
import { ResourceFetcher } from '../utils/ResourceFetcher';
|
|
4
|
+
import { ETError, getError } from '../Error';
|
|
5
|
+
import { Template } from '@huggingface/jinja';
|
|
6
|
+
import { DEFAULT_CHAT_CONFIG } from '../constants/llmDefaults';
|
|
7
|
+
import { readAsStringAsync } from 'expo-file-system';
|
|
8
|
+
import {
|
|
9
|
+
ChatConfig,
|
|
10
|
+
LLMTool,
|
|
11
|
+
Message,
|
|
12
|
+
SPECIAL_TOKENS,
|
|
13
|
+
ToolsConfig,
|
|
14
|
+
} from '../types/llm';
|
|
15
|
+
import { LLMNativeModule } from '../native/RnExecutorchModules';
|
|
16
|
+
import { parseToolCall } from '../utils/llm';
|
|
17
|
+
|
|
18
|
+
export class LLMController {
|
|
19
|
+
private nativeModule: typeof LLMNativeModule;
|
|
20
|
+
private chatConfig: ChatConfig = DEFAULT_CHAT_CONFIG;
|
|
21
|
+
private toolsConfig: ToolsConfig | undefined;
|
|
22
|
+
private tokenizerConfig: any;
|
|
23
|
+
private onToken: EventSubscription | null = null;
|
|
24
|
+
private _response = '';
|
|
25
|
+
private _isReady = false;
|
|
26
|
+
private _isGenerating = false;
|
|
27
|
+
private _messageHistory: Message[] = [];
|
|
28
|
+
|
|
29
|
+
// User callbacks
|
|
30
|
+
private responseCallback: (response: string) => void;
|
|
31
|
+
private messageHistoryCallback: (messageHistory: Message[]) => void;
|
|
32
|
+
private isReadyCallback: (isReady: boolean) => void;
|
|
33
|
+
private isGeneratingCallback: (isGenerating: boolean) => void;
|
|
34
|
+
private onDownloadProgressCallback:
|
|
35
|
+
| ((downloadProgress: number) => void)
|
|
36
|
+
| undefined;
|
|
37
|
+
|
|
38
|
+
constructor({
|
|
39
|
+
responseCallback,
|
|
40
|
+
messageHistoryCallback,
|
|
41
|
+
isReadyCallback,
|
|
42
|
+
isGeneratingCallback,
|
|
43
|
+
onDownloadProgressCallback,
|
|
44
|
+
}: {
|
|
45
|
+
responseCallback?: (response: string) => void;
|
|
46
|
+
messageHistoryCallback?: (messageHistory: Message[]) => void;
|
|
47
|
+
isReadyCallback?: (isReady: boolean) => void;
|
|
48
|
+
isGeneratingCallback?: (isGenerating: boolean) => void;
|
|
49
|
+
onDownloadProgressCallback?: (downloadProgress: number) => void;
|
|
50
|
+
}) {
|
|
51
|
+
this.responseCallback = (response) => {
|
|
52
|
+
this._response = response;
|
|
53
|
+
responseCallback?.(response);
|
|
54
|
+
};
|
|
55
|
+
this.messageHistoryCallback = (messageHistory) => {
|
|
56
|
+
this._messageHistory = messageHistory;
|
|
57
|
+
messageHistoryCallback?.(messageHistory);
|
|
58
|
+
};
|
|
59
|
+
this.isReadyCallback = (isReady) => {
|
|
60
|
+
this._isReady = isReady;
|
|
61
|
+
isReadyCallback?.(isReady);
|
|
62
|
+
};
|
|
63
|
+
this.isGeneratingCallback = (isGenerating) => {
|
|
64
|
+
this._isGenerating = isGenerating;
|
|
65
|
+
isGeneratingCallback?.(isGenerating);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
this.onDownloadProgressCallback = onDownloadProgressCallback;
|
|
69
|
+
|
|
70
|
+
this.nativeModule = LLMNativeModule;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public get response() {
|
|
74
|
+
return this._response;
|
|
75
|
+
}
|
|
76
|
+
public get isReady() {
|
|
77
|
+
return this._isReady;
|
|
78
|
+
}
|
|
79
|
+
public get isGenerating() {
|
|
80
|
+
return this._isGenerating;
|
|
81
|
+
}
|
|
82
|
+
public get messageHistory() {
|
|
83
|
+
return this._messageHistory;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
public async load({
|
|
87
|
+
modelSource,
|
|
88
|
+
tokenizerSource,
|
|
89
|
+
tokenizerConfigSource,
|
|
90
|
+
}: {
|
|
91
|
+
modelSource: ResourceSource;
|
|
92
|
+
tokenizerSource: ResourceSource;
|
|
93
|
+
tokenizerConfigSource: ResourceSource;
|
|
94
|
+
}) {
|
|
95
|
+
// reset inner state when loading new model
|
|
96
|
+
this.responseCallback('');
|
|
97
|
+
this.messageHistoryCallback(this.chatConfig.initialMessageHistory);
|
|
98
|
+
this.isGeneratingCallback(false);
|
|
99
|
+
this.isReadyCallback(false);
|
|
100
|
+
|
|
101
|
+
try {
|
|
102
|
+
const tokenizerFileUri = await ResourceFetcher.fetch(tokenizerSource);
|
|
103
|
+
const tokenizerConfigFileUri = await ResourceFetcher.fetch(
|
|
104
|
+
tokenizerConfigSource
|
|
105
|
+
);
|
|
106
|
+
this.tokenizerConfig = JSON.parse(
|
|
107
|
+
await readAsStringAsync('file://' + tokenizerConfigFileUri)
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
const modelFileUri = await ResourceFetcher.fetch(
|
|
111
|
+
modelSource,
|
|
112
|
+
this.onDownloadProgressCallback
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
await this.nativeModule.loadLLM(modelFileUri, tokenizerFileUri);
|
|
116
|
+
this.isReadyCallback(true);
|
|
117
|
+
this.onToken = this.nativeModule.onToken((data: string | undefined) => {
|
|
118
|
+
if (!data) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
this.responseCallback(this._response + data);
|
|
122
|
+
});
|
|
123
|
+
} catch (e) {
|
|
124
|
+
this.isReadyCallback(false);
|
|
125
|
+
throw new Error(getError(e));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
public configure({
|
|
130
|
+
chatConfig,
|
|
131
|
+
toolsConfig,
|
|
132
|
+
}: {
|
|
133
|
+
chatConfig?: Partial<ChatConfig>;
|
|
134
|
+
toolsConfig?: ToolsConfig;
|
|
135
|
+
}) {
|
|
136
|
+
this.chatConfig = { ...DEFAULT_CHAT_CONFIG, ...chatConfig };
|
|
137
|
+
this.toolsConfig = toolsConfig;
|
|
138
|
+
|
|
139
|
+
// reset inner state when loading new configuration
|
|
140
|
+
this.responseCallback('');
|
|
141
|
+
this.messageHistoryCallback(this.chatConfig.initialMessageHistory);
|
|
142
|
+
this.isGeneratingCallback(false);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
public delete() {
|
|
146
|
+
if (this._isGenerating) {
|
|
147
|
+
throw new Error(
|
|
148
|
+
'Model is generating! You cannot delete the model now. You need to interrupt first.'
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
this.onToken?.remove();
|
|
152
|
+
this.onToken = null;
|
|
153
|
+
this.nativeModule.releaseResources();
|
|
154
|
+
this.isReadyCallback(false);
|
|
155
|
+
this.isGeneratingCallback(false);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
public async forward(input: string) {
|
|
159
|
+
if (!this._isReady) {
|
|
160
|
+
throw new Error(getError(ETError.ModuleNotLoaded));
|
|
161
|
+
}
|
|
162
|
+
try {
|
|
163
|
+
this.responseCallback('');
|
|
164
|
+
this.isGeneratingCallback(true);
|
|
165
|
+
await this.nativeModule.forward(input);
|
|
166
|
+
} catch (e) {
|
|
167
|
+
throw new Error(getError(e));
|
|
168
|
+
} finally {
|
|
169
|
+
this.isGeneratingCallback(false);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
public interrupt() {
|
|
174
|
+
this.nativeModule.interrupt();
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
public async generate(messages: Message[], tools?: LLMTool[]) {
|
|
178
|
+
if (!this._isReady) {
|
|
179
|
+
throw new Error(getError(ETError.ModuleNotLoaded));
|
|
180
|
+
}
|
|
181
|
+
if (messages.length === 0) {
|
|
182
|
+
throw new Error(`Empty 'messages' array!`);
|
|
183
|
+
}
|
|
184
|
+
if (messages[0] && messages[0].role !== 'system') {
|
|
185
|
+
console.warn(
|
|
186
|
+
`You are not providing system prompt. You can pass it in the first message using { role: 'system', content: YOUR_PROMPT }. Otherwise prompt from your model's chat template will be used.`
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const renderedChat: string = this.applyChatTemplate(
|
|
191
|
+
messages,
|
|
192
|
+
this.tokenizerConfig,
|
|
193
|
+
tools,
|
|
194
|
+
// eslint-disable-next-line camelcase
|
|
195
|
+
{ tools_in_user_message: false, add_generation_prompt: true }
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
await this.forward(renderedChat);
|
|
199
|
+
|
|
200
|
+
if (!this._response) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const cleanedResponse = this._response
|
|
205
|
+
.replaceAll(this.tokenizerConfig.eos_token, '')
|
|
206
|
+
.replaceAll(this.tokenizerConfig.pad_token, '');
|
|
207
|
+
this.responseCallback(cleanedResponse);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
public async sendMessage(message: string) {
|
|
211
|
+
this.messageHistoryCallback([
|
|
212
|
+
...this._messageHistory,
|
|
213
|
+
{ content: message, role: 'user' },
|
|
214
|
+
]);
|
|
215
|
+
|
|
216
|
+
const messageHistoryWithPrompt: Message[] = [
|
|
217
|
+
{ content: this.chatConfig.systemPrompt, role: 'system' },
|
|
218
|
+
...this._messageHistory.slice(-this.chatConfig.contextWindowLength),
|
|
219
|
+
];
|
|
220
|
+
|
|
221
|
+
await this.generate(messageHistoryWithPrompt, this.toolsConfig?.tools);
|
|
222
|
+
|
|
223
|
+
if (!this.toolsConfig || this.toolsConfig.displayToolCalls) {
|
|
224
|
+
this.responseCallback(
|
|
225
|
+
this._response.replace(this.tokenizerConfig.eos_token, '')
|
|
226
|
+
);
|
|
227
|
+
this.messageHistoryCallback([
|
|
228
|
+
...this._messageHistory,
|
|
229
|
+
{ content: this._response, role: 'assistant' },
|
|
230
|
+
]);
|
|
231
|
+
}
|
|
232
|
+
if (!this.toolsConfig) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const toolCalls = parseToolCall(this._response);
|
|
237
|
+
|
|
238
|
+
for (const toolCall of toolCalls) {
|
|
239
|
+
this.toolsConfig
|
|
240
|
+
.executeToolCallback(toolCall)
|
|
241
|
+
.then((toolResponse: string | null) => {
|
|
242
|
+
if (toolResponse) {
|
|
243
|
+
this.messageHistoryCallback([
|
|
244
|
+
...this._messageHistory,
|
|
245
|
+
{ content: toolResponse, role: 'assistant' },
|
|
246
|
+
]);
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
public deleteMessage(index: number) {
|
|
253
|
+
// we delete referenced message and all messages after it
|
|
254
|
+
// so the model responses that used them are deleted as well
|
|
255
|
+
const newMessageHistory = this._messageHistory.slice(0, index);
|
|
256
|
+
|
|
257
|
+
this.messageHistoryCallback(newMessageHistory);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
private applyChatTemplate(
|
|
261
|
+
messages: Message[],
|
|
262
|
+
tokenizerConfig: any,
|
|
263
|
+
tools?: LLMTool[],
|
|
264
|
+
templateFlags?: Object
|
|
265
|
+
): string {
|
|
266
|
+
if (!tokenizerConfig.chat_template) {
|
|
267
|
+
throw Error("Tokenizer config doesn't include chat_template");
|
|
268
|
+
}
|
|
269
|
+
const template = new Template(tokenizerConfig.chat_template);
|
|
270
|
+
|
|
271
|
+
const specialTokens = Object.fromEntries(
|
|
272
|
+
SPECIAL_TOKENS.filter((key) => key in tokenizerConfig).map((key) => [
|
|
273
|
+
key,
|
|
274
|
+
tokenizerConfig[key],
|
|
275
|
+
])
|
|
276
|
+
);
|
|
277
|
+
|
|
278
|
+
const result = template.render({
|
|
279
|
+
messages,
|
|
280
|
+
tools,
|
|
281
|
+
...templateFlags,
|
|
282
|
+
...specialTokens,
|
|
283
|
+
});
|
|
284
|
+
return result;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { symbols } from '../constants/ocr/symbols';
|
|
2
2
|
import { ETError, getError } from '../Error';
|
|
3
|
-
import {
|
|
3
|
+
import { OCRNativeModule } from '../native/RnExecutorchModules';
|
|
4
4
|
import { ResourceSource } from '../types/common';
|
|
5
5
|
import { OCRLanguage } from '../types/ocr';
|
|
6
|
-
import {
|
|
7
|
-
fetchResource,
|
|
8
|
-
calculateDownloadProgres,
|
|
9
|
-
} from '../utils/fetchResource';
|
|
6
|
+
import { ResourceFetcher } from '../utils/ResourceFetcher';
|
|
10
7
|
|
|
11
8
|
export class OCRController {
|
|
12
|
-
private nativeModule:
|
|
9
|
+
private nativeModule: typeof OCRNativeModule;
|
|
13
10
|
public isReady: boolean = false;
|
|
14
11
|
public isGenerating: boolean = false;
|
|
15
12
|
public error: string | null = null;
|
|
@@ -24,7 +21,7 @@ export class OCRController {
|
|
|
24
21
|
isGeneratingCallback = (_isGenerating: boolean) => {},
|
|
25
22
|
errorCallback = (_error: string) => {},
|
|
26
23
|
}) {
|
|
27
|
-
this.nativeModule =
|
|
24
|
+
this.nativeModule = OCRNativeModule;
|
|
28
25
|
this.modelDownloadProgressCallback = modelDownloadProgressCallback;
|
|
29
26
|
this.isReadyCallback = isReadyCallback;
|
|
30
27
|
this.isGeneratingCallback = isGeneratingCallback;
|
|
@@ -47,34 +44,23 @@ export class OCRController {
|
|
|
47
44
|
if (!symbols[language]) {
|
|
48
45
|
throw new Error(getError(ETError.LanguageNotSupported));
|
|
49
46
|
}
|
|
47
|
+
|
|
50
48
|
this.isReady = false;
|
|
51
49
|
this.isReadyCallback(false);
|
|
52
50
|
|
|
53
|
-
const
|
|
51
|
+
const paths = await ResourceFetcher.fetchMultipleResources(
|
|
52
|
+
this.modelDownloadProgressCallback,
|
|
54
53
|
detectorSource,
|
|
55
|
-
|
|
54
|
+
recognizerSources.recognizerLarge,
|
|
55
|
+
recognizerSources.recognizerMedium,
|
|
56
|
+
recognizerSources.recognizerSmall
|
|
56
57
|
);
|
|
57
58
|
|
|
58
|
-
const recognizerPaths = {
|
|
59
|
-
recognizerLarge: await fetchResource(
|
|
60
|
-
recognizerSources.recognizerLarge,
|
|
61
|
-
calculateDownloadProgres(4, 1, this.modelDownloadProgressCallback)
|
|
62
|
-
),
|
|
63
|
-
recognizerMedium: await fetchResource(
|
|
64
|
-
recognizerSources.recognizerMedium,
|
|
65
|
-
calculateDownloadProgres(4, 2, this.modelDownloadProgressCallback)
|
|
66
|
-
),
|
|
67
|
-
recognizerSmall: await fetchResource(
|
|
68
|
-
recognizerSources.recognizerSmall,
|
|
69
|
-
calculateDownloadProgres(4, 3, this.modelDownloadProgressCallback)
|
|
70
|
-
),
|
|
71
|
-
};
|
|
72
|
-
|
|
73
59
|
await this.nativeModule.loadModule(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
60
|
+
paths[0]!,
|
|
61
|
+
paths[1]!,
|
|
62
|
+
paths[2]!,
|
|
63
|
+
paths[3]!,
|
|
78
64
|
symbols[language]
|
|
79
65
|
);
|
|
80
66
|
|