react-native-executorch 0.5.3 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/cpp/CMakeLists.txt +2 -1
- package/common/rnexecutorch/data_processing/Numerical.cpp +27 -19
- package/common/rnexecutorch/data_processing/Numerical.h +53 -4
- package/common/rnexecutorch/data_processing/dsp.cpp +1 -1
- package/common/rnexecutorch/data_processing/dsp.h +1 -1
- package/common/rnexecutorch/data_processing/gzip.cpp +47 -0
- package/common/rnexecutorch/data_processing/gzip.h +7 -0
- package/common/rnexecutorch/host_objects/ModelHostObject.h +24 -0
- package/common/rnexecutorch/metaprogramming/TypeConcepts.h +21 -1
- package/common/rnexecutorch/models/BaseModel.cpp +3 -2
- package/common/rnexecutorch/models/BaseModel.h +3 -2
- package/common/rnexecutorch/models/speech_to_text/SpeechToText.cpp +103 -39
- package/common/rnexecutorch/models/speech_to_text/SpeechToText.h +39 -21
- package/common/rnexecutorch/models/speech_to_text/asr/ASR.cpp +310 -0
- package/common/rnexecutorch/models/speech_to_text/asr/ASR.h +62 -0
- package/common/rnexecutorch/models/speech_to_text/stream/HypothesisBuffer.cpp +82 -0
- package/common/rnexecutorch/models/speech_to_text/stream/HypothesisBuffer.h +25 -0
- package/common/rnexecutorch/models/speech_to_text/stream/OnlineASRProcessor.cpp +99 -0
- package/common/rnexecutorch/models/speech_to_text/stream/OnlineASRProcessor.h +33 -0
- package/common/rnexecutorch/models/speech_to_text/types/DecodingOptions.h +15 -0
- package/common/rnexecutorch/models/speech_to_text/types/GenerationResult.h +12 -0
- package/common/rnexecutorch/models/speech_to_text/types/ProcessResult.h +12 -0
- package/common/rnexecutorch/models/speech_to_text/types/Segment.h +14 -0
- package/common/rnexecutorch/models/speech_to_text/types/Word.h +13 -0
- package/lib/module/modules/natural_language_processing/SpeechToTextModule.js +75 -53
- package/lib/module/modules/natural_language_processing/SpeechToTextModule.js.map +1 -1
- package/lib/typescript/hooks/natural_language_processing/useSpeechToText.d.ts +5 -5
- package/lib/typescript/modules/natural_language_processing/SpeechToTextModule.d.ts +7 -12
- package/lib/typescript/modules/natural_language_processing/SpeechToTextModule.d.ts.map +1 -1
- package/lib/typescript/types/stt.d.ts +0 -9
- package/lib/typescript/types/stt.d.ts.map +1 -1
- package/package.json +1 -1
- package/react-native-executorch.podspec +2 -0
- package/src/modules/natural_language_processing/SpeechToTextModule.ts +118 -54
- package/src/types/stt.ts +0 -12
- package/common/rnexecutorch/models/EncoderDecoderBase.cpp +0 -21
- package/common/rnexecutorch/models/EncoderDecoderBase.h +0 -31
- package/common/rnexecutorch/models/speech_to_text/SpeechToTextStrategy.h +0 -27
- package/common/rnexecutorch/models/speech_to_text/WhisperStrategy.cpp +0 -50
- package/common/rnexecutorch/models/speech_to_text/WhisperStrategy.h +0 -25
- package/lib/Error.js +0 -53
- package/lib/ThreadPool.d.ts +0 -10
- package/lib/ThreadPool.js +0 -28
- package/lib/common/Logger.d.ts +0 -8
- package/lib/common/Logger.js +0 -19
- package/lib/constants/directories.js +0 -2
- package/lib/constants/llmDefaults.d.ts +0 -6
- package/lib/constants/llmDefaults.js +0 -16
- package/lib/constants/modelUrls.d.ts +0 -223
- package/lib/constants/modelUrls.js +0 -322
- package/lib/constants/ocr/models.d.ts +0 -882
- package/lib/constants/ocr/models.js +0 -182
- package/lib/constants/ocr/symbols.js +0 -139
- package/lib/constants/sttDefaults.d.ts +0 -28
- package/lib/constants/sttDefaults.js +0 -68
- package/lib/controllers/LLMController.d.ts +0 -47
- package/lib/controllers/LLMController.js +0 -213
- package/lib/controllers/OCRController.js +0 -67
- package/lib/controllers/SpeechToTextController.d.ts +0 -56
- package/lib/controllers/SpeechToTextController.js +0 -349
- package/lib/controllers/VerticalOCRController.js +0 -70
- package/lib/hooks/computer_vision/useClassification.d.ts +0 -15
- package/lib/hooks/computer_vision/useClassification.js +0 -7
- package/lib/hooks/computer_vision/useImageEmbeddings.d.ts +0 -15
- package/lib/hooks/computer_vision/useImageEmbeddings.js +0 -7
- package/lib/hooks/computer_vision/useImageSegmentation.d.ts +0 -38
- package/lib/hooks/computer_vision/useImageSegmentation.js +0 -7
- package/lib/hooks/computer_vision/useOCR.d.ts +0 -20
- package/lib/hooks/computer_vision/useOCR.js +0 -41
- package/lib/hooks/computer_vision/useObjectDetection.d.ts +0 -15
- package/lib/hooks/computer_vision/useObjectDetection.js +0 -7
- package/lib/hooks/computer_vision/useStyleTransfer.d.ts +0 -15
- package/lib/hooks/computer_vision/useStyleTransfer.js +0 -7
- package/lib/hooks/computer_vision/useVerticalOCR.d.ts +0 -21
- package/lib/hooks/computer_vision/useVerticalOCR.js +0 -43
- package/lib/hooks/general/useExecutorchModule.d.ts +0 -13
- package/lib/hooks/general/useExecutorchModule.js +0 -7
- package/lib/hooks/natural_language_processing/useLLM.d.ts +0 -10
- package/lib/hooks/natural_language_processing/useLLM.js +0 -78
- package/lib/hooks/natural_language_processing/useSpeechToText.d.ts +0 -27
- package/lib/hooks/natural_language_processing/useSpeechToText.js +0 -49
- package/lib/hooks/natural_language_processing/useTextEmbeddings.d.ts +0 -16
- package/lib/hooks/natural_language_processing/useTextEmbeddings.js +0 -7
- package/lib/hooks/natural_language_processing/useTokenizer.d.ts +0 -17
- package/lib/hooks/natural_language_processing/useTokenizer.js +0 -52
- package/lib/hooks/useModule.js +0 -45
- package/lib/hooks/useNonStaticModule.d.ts +0 -20
- package/lib/hooks/useNonStaticModule.js +0 -49
- package/lib/index.d.ts +0 -48
- package/lib/index.js +0 -58
- package/lib/module/utils/SpeechToTextModule/ASR.js +0 -191
- package/lib/module/utils/SpeechToTextModule/ASR.js.map +0 -1
- package/lib/module/utils/SpeechToTextModule/OnlineProcessor.js +0 -73
- package/lib/module/utils/SpeechToTextModule/OnlineProcessor.js.map +0 -1
- package/lib/module/utils/SpeechToTextModule/hypothesisBuffer.js +0 -56
- package/lib/module/utils/SpeechToTextModule/hypothesisBuffer.js.map +0 -1
- package/lib/module/utils/stt.js +0 -22
- package/lib/module/utils/stt.js.map +0 -1
- package/lib/modules/BaseModule.js +0 -25
- package/lib/modules/BaseNonStaticModule.js +0 -14
- package/lib/modules/computer_vision/ClassificationModule.d.ts +0 -8
- package/lib/modules/computer_vision/ClassificationModule.js +0 -17
- package/lib/modules/computer_vision/ImageEmbeddingsModule.d.ts +0 -8
- package/lib/modules/computer_vision/ImageEmbeddingsModule.js +0 -17
- package/lib/modules/computer_vision/ImageSegmentationModule.d.ts +0 -11
- package/lib/modules/computer_vision/ImageSegmentationModule.js +0 -27
- package/lib/modules/computer_vision/OCRModule.d.ts +0 -14
- package/lib/modules/computer_vision/OCRModule.js +0 -17
- package/lib/modules/computer_vision/ObjectDetectionModule.d.ts +0 -9
- package/lib/modules/computer_vision/ObjectDetectionModule.js +0 -17
- package/lib/modules/computer_vision/StyleTransferModule.d.ts +0 -8
- package/lib/modules/computer_vision/StyleTransferModule.js +0 -17
- package/lib/modules/computer_vision/VerticalOCRModule.d.ts +0 -14
- package/lib/modules/computer_vision/VerticalOCRModule.js +0 -19
- package/lib/modules/general/ExecutorchModule.d.ts +0 -7
- package/lib/modules/general/ExecutorchModule.js +0 -14
- package/lib/modules/natural_language_processing/LLMModule.d.ts +0 -28
- package/lib/modules/natural_language_processing/LLMModule.js +0 -45
- package/lib/modules/natural_language_processing/SpeechToTextModule.d.ts +0 -24
- package/lib/modules/natural_language_processing/SpeechToTextModule.js +0 -36
- package/lib/modules/natural_language_processing/TextEmbeddingsModule.d.ts +0 -9
- package/lib/modules/natural_language_processing/TextEmbeddingsModule.js +0 -21
- package/lib/modules/natural_language_processing/TokenizerModule.d.ts +0 -12
- package/lib/modules/natural_language_processing/TokenizerModule.js +0 -30
- package/lib/native/NativeETInstaller.js +0 -2
- package/lib/native/NativeOCR.js +0 -2
- package/lib/native/NativeVerticalOCR.js +0 -2
- package/lib/native/RnExecutorchModules.d.ts +0 -7
- package/lib/native/RnExecutorchModules.js +0 -18
- package/lib/tsconfig.tsbuildinfo +0 -1
- package/lib/types/common.d.ts +0 -32
- package/lib/types/common.js +0 -25
- package/lib/types/imageSegmentation.js +0 -26
- package/lib/types/llm.d.ts +0 -46
- package/lib/types/llm.js +0 -9
- package/lib/types/objectDetection.js +0 -94
- package/lib/types/ocr.js +0 -1
- package/lib/types/stt.d.ts +0 -94
- package/lib/types/stt.js +0 -85
- package/lib/typescript/utils/SpeechToTextModule/ASR.d.ts +0 -27
- package/lib/typescript/utils/SpeechToTextModule/ASR.d.ts.map +0 -1
- package/lib/typescript/utils/SpeechToTextModule/OnlineProcessor.d.ts +0 -23
- package/lib/typescript/utils/SpeechToTextModule/OnlineProcessor.d.ts.map +0 -1
- package/lib/typescript/utils/SpeechToTextModule/hypothesisBuffer.d.ts +0 -13
- package/lib/typescript/utils/SpeechToTextModule/hypothesisBuffer.d.ts.map +0 -1
- package/lib/typescript/utils/stt.d.ts +0 -2
- package/lib/typescript/utils/stt.d.ts.map +0 -1
- package/lib/utils/ResourceFetcher.d.ts +0 -24
- package/lib/utils/ResourceFetcher.js +0 -305
- package/lib/utils/ResourceFetcherUtils.d.ts +0 -54
- package/lib/utils/ResourceFetcherUtils.js +0 -127
- package/lib/utils/llm.d.ts +0 -6
- package/lib/utils/llm.js +0 -72
- package/lib/utils/stt.js +0 -21
- package/src/utils/SpeechToTextModule/ASR.ts +0 -303
- package/src/utils/SpeechToTextModule/OnlineProcessor.ts +0 -87
- package/src/utils/SpeechToTextModule/hypothesisBuffer.ts +0 -79
- package/src/utils/stt.ts +0 -28
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ResourceSource } from '../../types/common';
|
|
2
|
-
import { BaseNonStaticModule } from '../BaseNonStaticModule';
|
|
3
|
-
export declare class ClassificationModule extends BaseNonStaticModule {
|
|
4
|
-
load(model: {
|
|
5
|
-
modelSource: ResourceSource;
|
|
6
|
-
}, onDownloadProgressCallback?: (progress: number) => void): Promise<void>;
|
|
7
|
-
forward(imageSource: string): Promise<any>;
|
|
8
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { ResourceFetcher } from '../../utils/ResourceFetcher';
|
|
2
|
-
import { ETError, getError } from '../../Error';
|
|
3
|
-
import { BaseNonStaticModule } from '../BaseNonStaticModule';
|
|
4
|
-
export class ClassificationModule extends BaseNonStaticModule {
|
|
5
|
-
async load(model, onDownloadProgressCallback = () => { }) {
|
|
6
|
-
const paths = await ResourceFetcher.fetch(onDownloadProgressCallback, model.modelSource);
|
|
7
|
-
if (paths === null || paths.length < 1) {
|
|
8
|
-
throw new Error('Download interrupted.');
|
|
9
|
-
}
|
|
10
|
-
this.nativeModule = global.loadClassification(paths[0] || '');
|
|
11
|
-
}
|
|
12
|
-
async forward(imageSource) {
|
|
13
|
-
if (this.nativeModule == null)
|
|
14
|
-
throw new Error(getError(ETError.ModuleNotLoaded));
|
|
15
|
-
return await this.nativeModule.generate(imageSource);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ResourceSource } from '../../types/common';
|
|
2
|
-
import { BaseNonStaticModule } from '../BaseNonStaticModule';
|
|
3
|
-
export declare class ImageEmbeddingsModule extends BaseNonStaticModule {
|
|
4
|
-
load(model: {
|
|
5
|
-
modelSource: ResourceSource;
|
|
6
|
-
}, onDownloadProgressCallback?: (progress: number) => void): Promise<void>;
|
|
7
|
-
forward(imageSource: string): Promise<Float32Array>;
|
|
8
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { ResourceFetcher } from '../../utils/ResourceFetcher';
|
|
2
|
-
import { ETError, getError } from '../../Error';
|
|
3
|
-
import { BaseNonStaticModule } from '../BaseNonStaticModule';
|
|
4
|
-
export class ImageEmbeddingsModule extends BaseNonStaticModule {
|
|
5
|
-
async load(model, onDownloadProgressCallback = () => { }) {
|
|
6
|
-
const paths = await ResourceFetcher.fetch(onDownloadProgressCallback, model.modelSource);
|
|
7
|
-
if (paths === null || paths.length < 1) {
|
|
8
|
-
throw new Error('Download interrupted.');
|
|
9
|
-
}
|
|
10
|
-
this.nativeModule = global.loadImageEmbeddings(paths[0] || '');
|
|
11
|
-
}
|
|
12
|
-
async forward(imageSource) {
|
|
13
|
-
if (this.nativeModule == null)
|
|
14
|
-
throw new Error(getError(ETError.ModuleNotLoaded));
|
|
15
|
-
return new Float32Array(await this.nativeModule.generate(imageSource));
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ResourceSource } from '../../types/common';
|
|
2
|
-
import { DeeplabLabel } from '../../types/imageSegmentation';
|
|
3
|
-
import { BaseNonStaticModule } from '../BaseNonStaticModule';
|
|
4
|
-
export declare class ImageSegmentationModule extends BaseNonStaticModule {
|
|
5
|
-
load(model: {
|
|
6
|
-
modelSource: ResourceSource;
|
|
7
|
-
}, onDownloadProgressCallback?: (progress: number) => void): Promise<void>;
|
|
8
|
-
forward(imageSource: string, classesOfInterest?: DeeplabLabel[], resize?: boolean): Promise<{
|
|
9
|
-
[key in DeeplabLabel]?: number[];
|
|
10
|
-
}>;
|
|
11
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { ResourceFetcher } from '../../utils/ResourceFetcher';
|
|
2
|
-
import { DeeplabLabel } from '../../types/imageSegmentation';
|
|
3
|
-
import { ETError, getError } from '../../Error';
|
|
4
|
-
import { BaseNonStaticModule } from '../BaseNonStaticModule';
|
|
5
|
-
export class ImageSegmentationModule extends BaseNonStaticModule {
|
|
6
|
-
async load(model, onDownloadProgressCallback = () => { }) {
|
|
7
|
-
const paths = await ResourceFetcher.fetch(onDownloadProgressCallback, model.modelSource);
|
|
8
|
-
if (paths === null || paths.length < 1) {
|
|
9
|
-
throw new Error('Download interrupted.');
|
|
10
|
-
}
|
|
11
|
-
this.nativeModule = global.loadImageSegmentation(paths[0] || '');
|
|
12
|
-
}
|
|
13
|
-
async forward(imageSource, classesOfInterest, resize) {
|
|
14
|
-
if (this.nativeModule == null) {
|
|
15
|
-
throw new Error(getError(ETError.ModuleNotLoaded));
|
|
16
|
-
}
|
|
17
|
-
const stringDict = await this.nativeModule.generate(imageSource, (classesOfInterest || []).map((label) => DeeplabLabel[label]), resize || false);
|
|
18
|
-
let enumDict = {};
|
|
19
|
-
for (const key in stringDict) {
|
|
20
|
-
if (key in DeeplabLabel) {
|
|
21
|
-
const enumKey = DeeplabLabel[key];
|
|
22
|
-
enumDict[enumKey] = stringDict[key];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return enumDict;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { OCRController } from '../../controllers/OCRController';
|
|
2
|
-
import { ResourceSource } from '../../types/common';
|
|
3
|
-
import { OCRLanguage } from '../../types/ocr';
|
|
4
|
-
export declare class OCRModule {
|
|
5
|
-
static module: OCRController;
|
|
6
|
-
static load(model: {
|
|
7
|
-
detectorSource: ResourceSource;
|
|
8
|
-
recognizerLarge: ResourceSource;
|
|
9
|
-
recognizerMedium: ResourceSource;
|
|
10
|
-
recognizerSmall: ResourceSource;
|
|
11
|
-
language: OCRLanguage;
|
|
12
|
-
}, onDownloadProgressCallback?: (progress: number) => void): Promise<void>;
|
|
13
|
-
static forward(input: string): Promise<import("../../types/ocr").OCRDetection[]>;
|
|
14
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { OCRController } from '../../controllers/OCRController';
|
|
2
|
-
export class OCRModule {
|
|
3
|
-
static module;
|
|
4
|
-
static async load(model, onDownloadProgressCallback = () => { }) {
|
|
5
|
-
this.module = new OCRController({
|
|
6
|
-
modelDownloadProgressCallback: onDownloadProgressCallback,
|
|
7
|
-
});
|
|
8
|
-
await this.module.loadModel(model.detectorSource, {
|
|
9
|
-
recognizerLarge: model.recognizerLarge,
|
|
10
|
-
recognizerMedium: model.recognizerMedium,
|
|
11
|
-
recognizerSmall: model.recognizerSmall,
|
|
12
|
-
}, model.language);
|
|
13
|
-
}
|
|
14
|
-
static async forward(input) {
|
|
15
|
-
return await this.module.forward(input);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ResourceSource } from '../../types/common';
|
|
2
|
-
import { Detection } from '../../types/objectDetection';
|
|
3
|
-
import { BaseNonStaticModule } from '../BaseNonStaticModule';
|
|
4
|
-
export declare class ObjectDetectionModule extends BaseNonStaticModule {
|
|
5
|
-
load(model: {
|
|
6
|
-
modelSource: ResourceSource;
|
|
7
|
-
}, onDownloadProgressCallback?: (progress: number) => void): Promise<void>;
|
|
8
|
-
forward(imageSource: string, detectionThreshold?: number): Promise<Detection[]>;
|
|
9
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { ResourceFetcher } from '../../utils/ResourceFetcher';
|
|
2
|
-
import { ETError, getError } from '../../Error';
|
|
3
|
-
import { BaseNonStaticModule } from '../BaseNonStaticModule';
|
|
4
|
-
export class ObjectDetectionModule extends BaseNonStaticModule {
|
|
5
|
-
async load(model, onDownloadProgressCallback = () => { }) {
|
|
6
|
-
const paths = await ResourceFetcher.fetch(onDownloadProgressCallback, model.modelSource);
|
|
7
|
-
if (paths === null || paths.length < 1) {
|
|
8
|
-
throw new Error('Download interrupted.');
|
|
9
|
-
}
|
|
10
|
-
this.nativeModule = global.loadObjectDetection(paths[0] || '');
|
|
11
|
-
}
|
|
12
|
-
async forward(imageSource, detectionThreshold = 0.7) {
|
|
13
|
-
if (this.nativeModule == null)
|
|
14
|
-
throw new Error(getError(ETError.ModuleNotLoaded));
|
|
15
|
-
return await this.nativeModule.generate(imageSource, detectionThreshold);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ResourceSource } from '../../types/common';
|
|
2
|
-
import { BaseNonStaticModule } from '../BaseNonStaticModule';
|
|
3
|
-
export declare class StyleTransferModule extends BaseNonStaticModule {
|
|
4
|
-
load(model: {
|
|
5
|
-
modelSource: ResourceSource;
|
|
6
|
-
}, onDownloadProgressCallback?: (progress: number) => void): Promise<void>;
|
|
7
|
-
forward(imageSource: string): Promise<string>;
|
|
8
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { ResourceFetcher } from '../../utils/ResourceFetcher';
|
|
2
|
-
import { ETError, getError } from '../../Error';
|
|
3
|
-
import { BaseNonStaticModule } from '../BaseNonStaticModule';
|
|
4
|
-
export class StyleTransferModule extends BaseNonStaticModule {
|
|
5
|
-
async load(model, onDownloadProgressCallback = () => { }) {
|
|
6
|
-
const paths = await ResourceFetcher.fetch(onDownloadProgressCallback, model.modelSource);
|
|
7
|
-
if (paths === null || paths.length < 1) {
|
|
8
|
-
throw new Error('Download interrupted.');
|
|
9
|
-
}
|
|
10
|
-
this.nativeModule = global.loadStyleTransfer(paths[0] || '');
|
|
11
|
-
}
|
|
12
|
-
async forward(imageSource) {
|
|
13
|
-
if (this.nativeModule == null)
|
|
14
|
-
throw new Error(getError(ETError.ModuleNotLoaded));
|
|
15
|
-
return await this.nativeModule.generate(imageSource);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { VerticalOCRController } from '../../controllers/VerticalOCRController';
|
|
2
|
-
import { ResourceSource } from '../../types/common';
|
|
3
|
-
import { OCRLanguage } from '../../types/ocr';
|
|
4
|
-
export declare class VerticalOCRModule {
|
|
5
|
-
static module: VerticalOCRController;
|
|
6
|
-
static load(model: {
|
|
7
|
-
detectorLarge: ResourceSource;
|
|
8
|
-
detectorNarrow: ResourceSource;
|
|
9
|
-
recognizerLarge: ResourceSource;
|
|
10
|
-
recognizerSmall: ResourceSource;
|
|
11
|
-
language: OCRLanguage;
|
|
12
|
-
}, independentCharacters: boolean, onDownloadProgressCallback?: (progress: number) => void): Promise<void>;
|
|
13
|
-
static forward(input: string): Promise<import("../../types/ocr").OCRDetection[]>;
|
|
14
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { VerticalOCRController } from '../../controllers/VerticalOCRController';
|
|
2
|
-
export class VerticalOCRModule {
|
|
3
|
-
static module;
|
|
4
|
-
static async load(model, independentCharacters, onDownloadProgressCallback = () => { }) {
|
|
5
|
-
this.module = new VerticalOCRController({
|
|
6
|
-
modelDownloadProgressCallback: onDownloadProgressCallback,
|
|
7
|
-
});
|
|
8
|
-
await this.module.loadModel({
|
|
9
|
-
detectorLarge: model.detectorLarge,
|
|
10
|
-
detectorNarrow: model.detectorNarrow,
|
|
11
|
-
}, {
|
|
12
|
-
recognizerLarge: model.recognizerLarge,
|
|
13
|
-
recognizerSmall: model.recognizerSmall,
|
|
14
|
-
}, model.language, independentCharacters);
|
|
15
|
-
}
|
|
16
|
-
static async forward(input) {
|
|
17
|
-
return await this.module.forward(input);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { TensorPtr } from '../../types/common';
|
|
2
|
-
import { BaseNonStaticModule } from '../BaseNonStaticModule';
|
|
3
|
-
import { ResourceSource } from '../../types/common';
|
|
4
|
-
export declare class ExecutorchModule extends BaseNonStaticModule {
|
|
5
|
-
load(modelSource: ResourceSource, onDownloadProgressCallback?: (progress: number) => void): Promise<void>;
|
|
6
|
-
forward(inputTensor: TensorPtr[]): Promise<TensorPtr[]>;
|
|
7
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { BaseNonStaticModule } from '../BaseNonStaticModule';
|
|
2
|
-
import { ResourceFetcher } from '../../utils/ResourceFetcher';
|
|
3
|
-
export class ExecutorchModule extends BaseNonStaticModule {
|
|
4
|
-
async load(modelSource, onDownloadProgressCallback = () => { }) {
|
|
5
|
-
const paths = await ResourceFetcher.fetch(onDownloadProgressCallback, modelSource);
|
|
6
|
-
if (paths === null || paths.length < 1) {
|
|
7
|
-
throw new Error('Download interrupted.');
|
|
8
|
-
}
|
|
9
|
-
this.nativeModule = global.loadExecutorchModule(paths[0] || '');
|
|
10
|
-
}
|
|
11
|
-
async forward(inputTensor) {
|
|
12
|
-
return await this.forwardET(inputTensor);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { ResourceSource } from '../../types/common';
|
|
2
|
-
import { ChatConfig, LLMTool, Message, ToolsConfig } from '../../types/llm';
|
|
3
|
-
export declare class LLMModule {
|
|
4
|
-
private controller;
|
|
5
|
-
constructor({ tokenCallback, responseCallback, messageHistoryCallback, }?: {
|
|
6
|
-
tokenCallback?: (token: string) => void;
|
|
7
|
-
responseCallback?: (response: string) => void;
|
|
8
|
-
messageHistoryCallback?: (messageHistory: Message[]) => void;
|
|
9
|
-
});
|
|
10
|
-
load(model: {
|
|
11
|
-
modelSource: ResourceSource;
|
|
12
|
-
tokenizerSource: ResourceSource;
|
|
13
|
-
tokenizerConfigSource: ResourceSource;
|
|
14
|
-
}, onDownloadProgressCallback?: (progress: number) => void): Promise<void>;
|
|
15
|
-
setTokenCallback({ tokenCallback, }: {
|
|
16
|
-
tokenCallback: (token: string) => void;
|
|
17
|
-
}): void;
|
|
18
|
-
configure({ chatConfig, toolsConfig, }: {
|
|
19
|
-
chatConfig?: Partial<ChatConfig>;
|
|
20
|
-
toolsConfig?: ToolsConfig;
|
|
21
|
-
}): void;
|
|
22
|
-
forward(input: string): Promise<string>;
|
|
23
|
-
generate(messages: Message[], tools?: LLMTool[]): Promise<string>;
|
|
24
|
-
sendMessage(message: string): Promise<Message[]>;
|
|
25
|
-
deleteMessage(index: number): Message[];
|
|
26
|
-
interrupt(): void;
|
|
27
|
-
delete(): void;
|
|
28
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { LLMController } from '../../controllers/LLMController';
|
|
2
|
-
export class LLMModule {
|
|
3
|
-
controller;
|
|
4
|
-
constructor({ tokenCallback, responseCallback, messageHistoryCallback, } = {}) {
|
|
5
|
-
this.controller = new LLMController({
|
|
6
|
-
tokenCallback,
|
|
7
|
-
responseCallback,
|
|
8
|
-
messageHistoryCallback,
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
async load(model, onDownloadProgressCallback = () => { }) {
|
|
12
|
-
await this.controller.load({
|
|
13
|
-
...model,
|
|
14
|
-
onDownloadProgressCallback,
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
setTokenCallback({ tokenCallback, }) {
|
|
18
|
-
this.controller.setTokenCallback(tokenCallback);
|
|
19
|
-
}
|
|
20
|
-
configure({ chatConfig, toolsConfig, }) {
|
|
21
|
-
this.controller.configure({ chatConfig, toolsConfig });
|
|
22
|
-
}
|
|
23
|
-
async forward(input) {
|
|
24
|
-
await this.controller.forward(input);
|
|
25
|
-
return this.controller.response;
|
|
26
|
-
}
|
|
27
|
-
async generate(messages, tools) {
|
|
28
|
-
await this.controller.generate(messages, tools);
|
|
29
|
-
return this.controller.response;
|
|
30
|
-
}
|
|
31
|
-
async sendMessage(message) {
|
|
32
|
-
await this.controller.sendMessage(message);
|
|
33
|
-
return this.controller.messageHistory;
|
|
34
|
-
}
|
|
35
|
-
deleteMessage(index) {
|
|
36
|
-
this.controller.deleteMessage(index);
|
|
37
|
-
return this.controller.messageHistory;
|
|
38
|
-
}
|
|
39
|
-
interrupt() {
|
|
40
|
-
this.controller.interrupt();
|
|
41
|
-
}
|
|
42
|
-
delete() {
|
|
43
|
-
this.controller.delete();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { ResourceSource } from '../../types/common';
|
|
2
|
-
import { SpeechToTextController } from '../../controllers/SpeechToTextController';
|
|
3
|
-
import { AvailableModels, SpeechToTextLanguage } from '../../types/stt';
|
|
4
|
-
import { STREAMING_ACTION } from '../../constants/sttDefaults';
|
|
5
|
-
export declare class SpeechToTextModule {
|
|
6
|
-
private module;
|
|
7
|
-
constructor({ transcribeCallback, overlapSeconds, windowSize, streamingConfig, }?: {
|
|
8
|
-
transcribeCallback?: (sequence: string) => void;
|
|
9
|
-
overlapSeconds?: ConstructorParameters<typeof SpeechToTextController>['0']['overlapSeconds'];
|
|
10
|
-
windowSize?: ConstructorParameters<typeof SpeechToTextController>['0']['windowSize'];
|
|
11
|
-
streamingConfig?: ConstructorParameters<typeof SpeechToTextController>['0']['streamingConfig'];
|
|
12
|
-
});
|
|
13
|
-
load(model: {
|
|
14
|
-
modelName: AvailableModels;
|
|
15
|
-
encoderSource?: ResourceSource;
|
|
16
|
-
decoderSource?: ResourceSource;
|
|
17
|
-
tokenizerSource?: ResourceSource;
|
|
18
|
-
}, onDownloadProgressCallback?: (progress: number) => void): Promise<void>;
|
|
19
|
-
configureStreaming(overlapSeconds: Parameters<SpeechToTextController['configureStreaming']>[0], windowSize: Parameters<SpeechToTextController['configureStreaming']>[1], streamingConfig: Parameters<SpeechToTextController['configureStreaming']>[2]): void;
|
|
20
|
-
encode(waveform: Float32Array): Promise<null>;
|
|
21
|
-
decode(seq: number[]): Promise<number>;
|
|
22
|
-
transcribe(waveform: number[], audioLanguage?: SpeechToTextLanguage): ReturnType<SpeechToTextController['transcribe']>;
|
|
23
|
-
streamingTranscribe(streamAction: STREAMING_ACTION, waveform?: number[], audioLanguage?: SpeechToTextLanguage): ReturnType<SpeechToTextController['streamingTranscribe']>;
|
|
24
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { SpeechToTextController } from '../../controllers/SpeechToTextController';
|
|
2
|
-
export class SpeechToTextModule {
|
|
3
|
-
module;
|
|
4
|
-
constructor({ transcribeCallback, overlapSeconds, windowSize, streamingConfig, } = {}) {
|
|
5
|
-
this.module = new SpeechToTextController({
|
|
6
|
-
transcribeCallback: transcribeCallback || (() => { }),
|
|
7
|
-
overlapSeconds,
|
|
8
|
-
windowSize,
|
|
9
|
-
streamingConfig,
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
async load(model, onDownloadProgressCallback = () => { }) {
|
|
13
|
-
await this.module.load({
|
|
14
|
-
modelName: model.modelName,
|
|
15
|
-
encoderSource: model.encoderSource,
|
|
16
|
-
decoderSource: model.decoderSource,
|
|
17
|
-
tokenizerSource: model.tokenizerSource,
|
|
18
|
-
onDownloadProgressCallback,
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
configureStreaming(overlapSeconds, windowSize, streamingConfig) {
|
|
22
|
-
this.module.configureStreaming(overlapSeconds, windowSize, streamingConfig);
|
|
23
|
-
}
|
|
24
|
-
async encode(waveform) {
|
|
25
|
-
return await this.module.encode(waveform);
|
|
26
|
-
}
|
|
27
|
-
async decode(seq) {
|
|
28
|
-
return await this.module.decode(seq);
|
|
29
|
-
}
|
|
30
|
-
async transcribe(waveform, audioLanguage) {
|
|
31
|
-
return await this.module.transcribe(waveform, audioLanguage);
|
|
32
|
-
}
|
|
33
|
-
async streamingTranscribe(streamAction, waveform, audioLanguage) {
|
|
34
|
-
return await this.module.streamingTranscribe(streamAction, waveform, audioLanguage);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ResourceSource } from '../../types/common';
|
|
2
|
-
import { BaseNonStaticModule } from '../BaseNonStaticModule';
|
|
3
|
-
export declare class TextEmbeddingsModule extends BaseNonStaticModule {
|
|
4
|
-
load(model: {
|
|
5
|
-
modelSource: ResourceSource;
|
|
6
|
-
tokenizerSource: ResourceSource;
|
|
7
|
-
}, onDownloadProgressCallback?: (progress: number) => void): Promise<void>;
|
|
8
|
-
forward(input: string): Promise<Float32Array>;
|
|
9
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ResourceFetcher } from '../../utils/ResourceFetcher';
|
|
2
|
-
import { BaseNonStaticModule } from '../BaseNonStaticModule';
|
|
3
|
-
export class TextEmbeddingsModule extends BaseNonStaticModule {
|
|
4
|
-
async load(model, onDownloadProgressCallback = () => { }) {
|
|
5
|
-
const modelPromise = ResourceFetcher.fetch(onDownloadProgressCallback, model.modelSource);
|
|
6
|
-
const tokenizerPromise = ResourceFetcher.fetch(undefined, model.tokenizerSource);
|
|
7
|
-
const [modelResult, tokenizerResult] = await Promise.all([
|
|
8
|
-
modelPromise,
|
|
9
|
-
tokenizerPromise,
|
|
10
|
-
]);
|
|
11
|
-
const modelPath = modelResult?.[0];
|
|
12
|
-
const tokenizerPath = tokenizerResult?.[0];
|
|
13
|
-
if (!modelPath || !tokenizerPath) {
|
|
14
|
-
throw new Error('Download interrupted.');
|
|
15
|
-
}
|
|
16
|
-
this.nativeModule = global.loadTextEmbeddings(modelPath, tokenizerPath);
|
|
17
|
-
}
|
|
18
|
-
async forward(input) {
|
|
19
|
-
return new Float32Array(await this.nativeModule.generate(input));
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ResourceSource } from '../../types/common';
|
|
2
|
-
export declare class TokenizerModule {
|
|
3
|
-
nativeModule: any;
|
|
4
|
-
load(tokenizer: {
|
|
5
|
-
tokenizerSource: ResourceSource;
|
|
6
|
-
}, onDownloadProgressCallback?: (progress: number) => void): Promise<void>;
|
|
7
|
-
encode(s: string): Promise<any>;
|
|
8
|
-
decode(tokens: number[], skipSpecialTokens?: boolean): Promise<any>;
|
|
9
|
-
getVocabSize(): Promise<number>;
|
|
10
|
-
idToToken(tokenId: number): Promise<string>;
|
|
11
|
-
tokenToId(token: string): Promise<number>;
|
|
12
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { ResourceFetcher } from '../../utils/ResourceFetcher';
|
|
2
|
-
export class TokenizerModule {
|
|
3
|
-
nativeModule;
|
|
4
|
-
async load(tokenizer, onDownloadProgressCallback = () => { }) {
|
|
5
|
-
const paths = await ResourceFetcher.fetch(onDownloadProgressCallback, tokenizer.tokenizerSource);
|
|
6
|
-
const path = paths?.[0];
|
|
7
|
-
if (!path) {
|
|
8
|
-
throw new Error('Download interrupted.');
|
|
9
|
-
}
|
|
10
|
-
this.nativeModule = global.loadTokenizerModule(path);
|
|
11
|
-
}
|
|
12
|
-
async encode(s) {
|
|
13
|
-
return await this.nativeModule.encode(s);
|
|
14
|
-
}
|
|
15
|
-
async decode(tokens, skipSpecialTokens = true) {
|
|
16
|
-
if (tokens.length === 0) {
|
|
17
|
-
return '';
|
|
18
|
-
}
|
|
19
|
-
return await this.nativeModule.decode(tokens, skipSpecialTokens);
|
|
20
|
-
}
|
|
21
|
-
async getVocabSize() {
|
|
22
|
-
return await this.nativeModule.getVocabSize();
|
|
23
|
-
}
|
|
24
|
-
async idToToken(tokenId) {
|
|
25
|
-
return this.nativeModule.idToToken(tokenId);
|
|
26
|
-
}
|
|
27
|
-
async tokenToId(token) {
|
|
28
|
-
return await this.nativeModule.tokenToId(token);
|
|
29
|
-
}
|
|
30
|
-
}
|
package/lib/native/NativeOCR.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Spec as OCRInterface } from './NativeOCR';
|
|
2
|
-
import { Spec as VerticalOCRInterface } from './NativeVerticalOCR';
|
|
3
|
-
import { Spec as ETInstallerInterface } from './NativeETInstaller';
|
|
4
|
-
declare const OCRNativeModule: OCRInterface;
|
|
5
|
-
declare const VerticalOCRNativeModule: VerticalOCRInterface;
|
|
6
|
-
declare const ETInstallerNativeModule: ETInstallerInterface;
|
|
7
|
-
export { OCRNativeModule, VerticalOCRNativeModule, ETInstallerNativeModule };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Platform } from 'react-native';
|
|
2
|
-
const LINKING_ERROR = `The package 'react-native-executorch' doesn't seem to be linked. Make sure: \n\n` +
|
|
3
|
-
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
4
|
-
'- You rebuilt the app after installing the package\n' +
|
|
5
|
-
'- You are not using Expo Go\n';
|
|
6
|
-
function returnSpecOrThrowLinkingError(spec) {
|
|
7
|
-
return spec
|
|
8
|
-
? spec
|
|
9
|
-
: new Proxy({}, {
|
|
10
|
-
get() {
|
|
11
|
-
throw new Error(LINKING_ERROR);
|
|
12
|
-
},
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
const OCRNativeModule = returnSpecOrThrowLinkingError(require('./NativeOCR').default);
|
|
16
|
-
const VerticalOCRNativeModule = returnSpecOrThrowLinkingError(require('./NativeVerticalOCR').default);
|
|
17
|
-
const ETInstallerNativeModule = returnSpecOrThrowLinkingError(require('./NativeETInstaller').default);
|
|
18
|
-
export { OCRNativeModule, VerticalOCRNativeModule, ETInstallerNativeModule };
|