react-native-sherpa-onnx 0.3.5 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -0
- package/README.md +90 -21
- package/SherpaOnnx.podspec +3 -0
- package/THIRD_PARTY_LICENSES/README.md +62 -0
- package/THIRD_PARTY_LICENSES/ffmpeg.txt +502 -0
- package/THIRD_PARTY_LICENSES/libarchive.txt +65 -0
- package/THIRD_PARTY_LICENSES/nvidia_omla.txt +181 -0
- package/THIRD_PARTY_LICENSES/onnxruntime.txt +21 -0
- package/THIRD_PARTY_LICENSES/opus.txt +44 -0
- package/THIRD_PARTY_LICENSES/sherpa-onnx.txt +201 -0
- package/THIRD_PARTY_LICENSES/shine.txt +482 -0
- package/THIRD_PARTY_LICENSES/zstd.txt +30 -0
- package/android/build.gradle +7 -3
- package/android/prebuilt-download.gradle +345 -153
- package/android/prebuilt-versions.gradle +2 -2
- package/android/src/main/assets/model_licenses/asr-models-license-status.csv +409 -0
- package/android/src/main/assets/model_licenses/qnn-asr-models-license-status.csv +695 -0
- package/android/src/main/assets/model_licenses/tts-models-license-status.csv +596 -0
- package/android/src/main/cpp/CMakeLists.txt +28 -10
- package/android/src/main/cpp/jni/archive/sherpa-onnx-archive-helper.cpp +306 -6
- package/android/src/main/cpp/jni/archive/sherpa-onnx-archive-helper.h +33 -4
- package/android/src/main/cpp/jni/archive/sherpa-onnx-archive-jni.cpp +266 -7
- package/android/src/main/cpp/jni/audio/sherpa-onnx-audio-convert-jni.cpp +268 -2
- package/android/src/main/cpp/jni/model_detect/sherpa-onnx-model-detect-tts.cpp +6 -2
- package/android/src/main/cpp/jni/model_detect/sherpa-onnx-validate-tts.cpp +4 -2
- package/android/src/main/java/com/sherpaonnx/SherpaOnnxArchiveHelper.kt +137 -7
- package/android/src/main/java/com/sherpaonnx/SherpaOnnxAssetHelper.kt +51 -6
- package/android/src/main/java/com/sherpaonnx/SherpaOnnxModule.kt +159 -0
- package/android/src/main/java/com/sherpaonnx/SherpaOnnxOnlineSttHelper.kt +4 -1
- package/android/src/main/java/com/sherpaonnx/SherpaOnnxTtsHelper.kt +112 -97
- package/ios/Resources/model_licenses/asr-models-license-status.csv +409 -0
- package/ios/Resources/model_licenses/qnn-asr-models-license-status.csv +695 -0
- package/ios/Resources/model_licenses/tts-models-license-status.csv +596 -0
- package/ios/SherpaOnnx+OnlineSTT.mm +2 -0
- package/ios/SherpaOnnx+PcmLiveStream.mm +2 -29
- package/ios/SherpaOnnx+TTS.mm +178 -20
- package/ios/SherpaOnnx.mm +108 -1
- package/ios/SherpaOnnxAudioConvert.h +10 -0
- package/ios/SherpaOnnxAudioConvert.mm +257 -1
- package/ios/archive/sherpa-onnx-archive-helper.h +10 -0
- package/ios/archive/sherpa-onnx-archive-helper.mm +56 -5
- package/ios/model_detect/sherpa-onnx-model-detect-tts.mm +13 -2
- package/ios/model_detect/sherpa-onnx-validate-tts.mm +4 -2
- package/ios/online_stt/sherpa-onnx-online-stt-wrapper.h +1 -0
- package/ios/online_stt/sherpa-onnx-online-stt-wrapper.mm +4 -0
- package/ios/tts/sherpa-onnx-tts-wrapper.h +37 -0
- package/ios/tts/sherpa-onnx-tts-wrapper.mm +149 -3
- package/lib/module/NativeSherpaOnnx.js.map +1 -1
- package/lib/module/audio/index.js +8 -0
- package/lib/module/audio/index.js.map +1 -1
- package/lib/module/download/ModelDownloadManager.js +10 -929
- package/lib/module/download/ModelDownloadManager.js.map +1 -1
- package/lib/module/download/activeModelOperations.js +26 -0
- package/lib/module/download/activeModelOperations.js.map +1 -0
- package/lib/module/download/background-downloader.d.js +2 -0
- package/lib/module/download/background-downloader.d.js.map +1 -0
- package/lib/module/download/bulkPurge.js +72 -0
- package/lib/module/download/bulkPurge.js.map +1 -0
- package/lib/module/download/checksumPrompt.js +19 -0
- package/lib/module/download/checksumPrompt.js.map +1 -0
- package/lib/module/download/constants.js +7 -0
- package/lib/module/download/constants.js.map +1 -0
- package/lib/module/download/downloadEvents.js +35 -0
- package/lib/module/download/downloadEvents.js.map +1 -0
- package/lib/module/download/downloadTask.js +385 -0
- package/lib/module/download/downloadTask.js.map +1 -0
- package/lib/module/download/ensureModel.js +89 -0
- package/lib/module/download/ensureModel.js.map +1 -0
- package/lib/module/download/index.js +4 -3
- package/lib/module/download/index.js.map +1 -1
- package/lib/module/download/localModels.js +151 -0
- package/lib/module/download/localModels.js.map +1 -0
- package/lib/module/download/modelExtraction.js +174 -0
- package/lib/module/download/modelExtraction.js.map +1 -0
- package/lib/module/download/paths.js +98 -0
- package/lib/module/download/paths.js.map +1 -0
- package/lib/module/download/postDownloadProcessing.js +206 -0
- package/lib/module/download/postDownloadProcessing.js.map +1 -0
- package/lib/module/download/protectedModelKeys.js +31 -0
- package/lib/module/download/protectedModelKeys.js.map +1 -0
- package/lib/module/download/registry.js +267 -0
- package/lib/module/download/registry.js.map +1 -0
- package/lib/module/download/retry.js +59 -0
- package/lib/module/download/retry.js.map +1 -0
- package/lib/module/download/types.js +17 -0
- package/lib/module/download/types.js.map +1 -0
- package/lib/module/download/validation.js +101 -5
- package/lib/module/download/validation.js.map +1 -1
- package/lib/module/{download → extraction}/extractTarBz2.js +3 -1
- package/lib/module/extraction/extractTarBz2.js.map +1 -0
- package/lib/module/extraction/extractTarZst.js +54 -0
- package/lib/module/extraction/extractTarZst.js.map +1 -0
- package/lib/module/extraction/index.js +190 -0
- package/lib/module/extraction/index.js.map +1 -0
- package/lib/module/extraction/types.js +2 -0
- package/lib/module/extraction/types.js.map +1 -0
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/licenses.js +63 -0
- package/lib/module/licenses.js.map +1 -0
- package/lib/module/stt/index.js +16 -2
- package/lib/module/stt/index.js.map +1 -1
- package/lib/module/stt/streaming.js +2 -0
- package/lib/module/stt/streaming.js.map +1 -1
- package/lib/module/stt/streamingTypes.js.map +1 -1
- package/lib/module/stt/types.js.map +1 -1
- package/lib/module/tts/index.js +20 -2
- package/lib/module/tts/index.js.map +1 -1
- package/lib/module/tts/streaming.js +4 -0
- package/lib/module/tts/streaming.js.map +1 -1
- package/lib/module/tts/types.js.map +1 -1
- package/lib/module/utils.js +16 -1
- package/lib/module/utils.js.map +1 -1
- package/lib/typescript/src/NativeSherpaOnnx.d.ts +72 -5
- package/lib/typescript/src/NativeSherpaOnnx.d.ts.map +1 -1
- package/lib/typescript/src/audio/index.d.ts +10 -0
- package/lib/typescript/src/audio/index.d.ts.map +1 -1
- package/lib/typescript/src/download/ModelDownloadManager.d.ts +10 -108
- package/lib/typescript/src/download/ModelDownloadManager.d.ts.map +1 -1
- package/lib/typescript/src/download/activeModelOperations.d.ts +6 -0
- package/lib/typescript/src/download/activeModelOperations.d.ts.map +1 -0
- package/lib/typescript/src/download/bulkPurge.d.ts +14 -0
- package/lib/typescript/src/download/bulkPurge.d.ts.map +1 -0
- package/lib/typescript/src/download/checksumPrompt.d.ts +3 -0
- package/lib/typescript/src/download/checksumPrompt.d.ts.map +1 -0
- package/lib/typescript/src/download/constants.d.ts +5 -0
- package/lib/typescript/src/download/constants.d.ts.map +1 -0
- package/lib/typescript/src/download/downloadEvents.d.ts +6 -0
- package/lib/typescript/src/download/downloadEvents.d.ts.map +1 -0
- package/lib/typescript/src/download/downloadTask.d.ts +20 -0
- package/lib/typescript/src/download/downloadTask.d.ts.map +1 -0
- package/lib/typescript/src/download/ensureModel.d.ts +26 -0
- package/lib/typescript/src/download/ensureModel.d.ts.map +1 -0
- package/lib/typescript/src/download/index.d.ts +7 -5
- package/lib/typescript/src/download/index.d.ts.map +1 -1
- package/lib/typescript/src/download/localModels.d.ts +15 -0
- package/lib/typescript/src/download/localModels.d.ts.map +1 -0
- package/lib/typescript/src/download/modelExtraction.d.ts +36 -0
- package/lib/typescript/src/download/modelExtraction.d.ts.map +1 -0
- package/lib/typescript/src/download/paths.d.ts +28 -0
- package/lib/typescript/src/download/paths.d.ts.map +1 -0
- package/lib/typescript/src/download/postDownloadProcessing.d.ts +19 -0
- package/lib/typescript/src/download/postDownloadProcessing.d.ts.map +1 -0
- package/lib/typescript/src/download/protectedModelKeys.d.ts +6 -0
- package/lib/typescript/src/download/protectedModelKeys.d.ts.map +1 -0
- package/lib/typescript/src/download/registry.d.ts +14 -0
- package/lib/typescript/src/download/registry.d.ts.map +1 -0
- package/lib/typescript/src/download/retry.d.ts +15 -0
- package/lib/typescript/src/download/retry.d.ts.map +1 -0
- package/lib/typescript/src/download/types.d.ts +96 -0
- package/lib/typescript/src/download/types.d.ts.map +1 -0
- package/lib/typescript/src/download/validation.d.ts +19 -0
- package/lib/typescript/src/download/validation.d.ts.map +1 -1
- package/lib/typescript/src/extraction/extractTarBz2.d.ts.map +1 -0
- package/lib/typescript/src/extraction/extractTarZst.d.ts +14 -0
- package/lib/typescript/src/extraction/extractTarZst.d.ts.map +1 -0
- package/lib/typescript/src/extraction/index.d.ts +50 -0
- package/lib/typescript/src/extraction/index.d.ts.map +1 -0
- package/lib/typescript/src/extraction/types.d.ts +60 -0
- package/lib/typescript/src/extraction/types.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/licenses.d.ts +10 -0
- package/lib/typescript/src/licenses.d.ts.map +1 -0
- package/lib/typescript/src/stt/index.d.ts +4 -1
- package/lib/typescript/src/stt/index.d.ts.map +1 -1
- package/lib/typescript/src/stt/streaming.d.ts.map +1 -1
- package/lib/typescript/src/stt/streamingTypes.d.ts +5 -0
- package/lib/typescript/src/stt/streamingTypes.d.ts.map +1 -1
- package/lib/typescript/src/stt/types.d.ts +3 -1
- package/lib/typescript/src/stt/types.d.ts.map +1 -1
- package/lib/typescript/src/tts/index.d.ts +3 -1
- package/lib/typescript/src/tts/index.d.ts.map +1 -1
- package/lib/typescript/src/tts/streaming.d.ts.map +1 -1
- package/lib/typescript/src/tts/types.d.ts +6 -5
- package/lib/typescript/src/tts/types.d.ts.map +1 -1
- package/lib/typescript/src/utils.d.ts +5 -0
- package/lib/typescript/src/utils.d.ts.map +1 -1
- package/package.json +11 -1
- package/scripts/{check-model-csvs.sh → ci/check-model-csvs.sh} +9 -2
- package/scripts/ci/collect_all_sherpa_model_streams.sh +101 -0
- package/scripts/ci/collect_one_sherpa_release_stream.sh +189 -0
- package/scripts/ci/sherpa_asr_model_release_streams.json +21 -0
- package/scripts/ci/sherpa_tts_model_release_streams.json +13 -0
- package/scripts/ci/update_model_license_csv.sh +765 -0
- package/scripts/setup-ios-framework.sh +14 -11
- package/scripts/update_commercial_use.js +73 -0
- package/src/NativeSherpaOnnx.ts +92 -5
- package/src/audio/index.ts +20 -0
- package/src/download/ModelDownloadManager.ts +55 -1343
- package/src/download/activeModelOperations.ts +38 -0
- package/src/download/background-downloader.d.ts +43 -0
- package/src/download/bulkPurge.ts +102 -0
- package/src/download/checksumPrompt.ts +25 -0
- package/src/download/constants.ts +5 -0
- package/src/download/downloadEvents.ts +55 -0
- package/src/download/downloadTask.ts +497 -0
- package/src/download/ensureModel.ts +124 -0
- package/src/download/index.ts +19 -2
- package/src/download/localModels.ts +234 -0
- package/src/download/modelExtraction.ts +244 -0
- package/src/download/paths.ts +134 -0
- package/src/download/postDownloadProcessing.ts +292 -0
- package/src/download/protectedModelKeys.ts +30 -0
- package/src/download/registry.ts +404 -0
- package/src/download/retry.ts +76 -0
- package/src/download/types.ts +120 -0
- package/src/download/validation.ts +114 -8
- package/src/{download → extraction}/extractTarBz2.ts +3 -1
- package/src/extraction/extractTarZst.ts +79 -0
- package/src/extraction/index.ts +269 -0
- package/src/extraction/types.ts +63 -0
- package/src/index.tsx +2 -0
- package/src/licenses.ts +100 -0
- package/src/stt/index.ts +20 -2
- package/src/stt/streaming.ts +3 -0
- package/src/stt/streamingTypes.ts +5 -0
- package/src/stt/types.ts +3 -1
- package/src/tts/index.ts +30 -2
- package/src/tts/streaming.ts +10 -0
- package/src/tts/types.ts +6 -5
- package/src/utils.ts +22 -1
- package/third_party/libarchive_prebuilt/ANDROID_RELEASE_TAG +1 -1
- package/third_party/libarchive_prebuilt/IOS_RELEASE_TAG +1 -1
- package/third_party/sherpa-onnx-prebuilt/ANDROID_RELEASE_TAG +1 -1
- package/third_party/sherpa-onnx-prebuilt/IOS_RELEASE_TAG +1 -1
- package/android/src/main/cpp/jni/tts/sherpa-onnx-tts-zipvoice-jni.cpp +0 -301
- package/android/src/main/java/com/sherpaonnx/ZipvoiceTtsWrapper.kt +0 -187
- package/lib/module/download/extractTarBz2.js.map +0 -1
- package/lib/typescript/src/download/extractTarBz2.d.ts.map +0 -1
- package/scripts/check-qnn-support.sh +0 -78
- /package/lib/typescript/src/{download → extraction}/extractTarBz2.d.ts +0 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ModelCategory, type ModelMetaBase, type ChecksumIssue, type DownloadProgress, type DownloadResult, type DownloadState } from './types';
|
|
2
|
+
export declare function downloadModelByCategory<T extends ModelMetaBase>(category: ModelCategory, id: string, opts?: {
|
|
3
|
+
onProgress?: (progress: DownloadProgress) => void;
|
|
4
|
+
overwrite?: boolean;
|
|
5
|
+
signal?: AbortSignal;
|
|
6
|
+
maxRetries?: number;
|
|
7
|
+
onChecksumIssue?: (issue: ChecksumIssue) => Promise<boolean>;
|
|
8
|
+
deleteArchiveAfterExtract?: boolean;
|
|
9
|
+
}): Promise<DownloadResult>;
|
|
10
|
+
export declare function getIncompleteDownloads(category: ModelCategory): Promise<DownloadState[]>;
|
|
11
|
+
export declare function resumeDownload<T extends ModelMetaBase>(category: ModelCategory, id: string, opts?: {
|
|
12
|
+
onProgress?: (progress: DownloadProgress) => void;
|
|
13
|
+
signal?: AbortSignal;
|
|
14
|
+
onChecksumIssue?: (issue: ChecksumIssue) => Promise<boolean>;
|
|
15
|
+
deleteArchiveAfterExtract?: boolean;
|
|
16
|
+
}): Promise<DownloadResult>;
|
|
17
|
+
export declare function deleteIncompleteDownload(category: ModelCategory, id: string): Promise<void>;
|
|
18
|
+
/** Task ids in the form `category:modelId` for downloads currently tracked in JS (before post-processing). */
|
|
19
|
+
export declare function getActiveDownloadTaskKeys(): string[];
|
|
20
|
+
//# sourceMappingURL=downloadTask.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"downloadTask.d.ts","sourceRoot":"","sources":["../../../../src/download/downloadTask.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,aAAa,EACb,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,aAAa,EACnB,MAAM,SAAS,CAAC;AAsBjB,wBAAsB,uBAAuB,CAAC,CAAC,SAAS,aAAa,EACnE,QAAQ,EAAE,aAAa,EACvB,EAAE,EAAE,MAAM,EACV,IAAI,CAAC,EAAE;IACL,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAClD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7D,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC,GACA,OAAO,CAAC,cAAc,CAAC,CAmNzB;AAED,wBAAsB,sBAAsB,CAC1C,QAAQ,EAAE,aAAa,GACtB,OAAO,CAAC,aAAa,EAAE,CAAC,CA4D1B;AAED,wBAAsB,cAAc,CAAC,CAAC,SAAS,aAAa,EAC1D,QAAQ,EAAE,aAAa,EACvB,EAAE,EAAE,MAAM,EACV,IAAI,CAAC,EAAE;IACL,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAClD,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7D,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC,GACA,OAAO,CAAC,cAAc,CAAC,CAwHzB;AAED,wBAAsB,wBAAwB,CAC5C,QAAQ,EAAE,aAAa,EACvB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,IAAI,CAAC,CA0Bf;AAED,8GAA8G;AAC9G,wBAAgB,yBAAyB,IAAI,MAAM,EAAE,CAEpD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ModelCategory, ModelMetaBase, ChecksumIssue, DownloadProgress } from './types';
|
|
2
|
+
import type { DownloadResult } from './types';
|
|
3
|
+
export type EnsureModelOptions = {
|
|
4
|
+
/** Progress callback (percent, phase, speed, eta). */
|
|
5
|
+
onProgress?: (progress: DownloadProgress) => void;
|
|
6
|
+
/** AbortController signal to cancel download or extraction. */
|
|
7
|
+
signal?: AbortSignal;
|
|
8
|
+
/** If true, remove existing model and any incomplete state, then download/extract from scratch. */
|
|
9
|
+
overwrite?: boolean;
|
|
10
|
+
/** Called on checksum mismatch; return true to keep the file. */
|
|
11
|
+
onChecksumIssue?: (issue: ChecksumIssue) => Promise<boolean>;
|
|
12
|
+
/** For archive models: if true (default), delete the archive after extraction to save space. */
|
|
13
|
+
deleteArchiveAfterExtract?: boolean;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Single entry point to ensure a model is available locally: handles download, extraction,
|
|
17
|
+
* and all edge cases (already ready, incomplete download, incomplete extraction, archive
|
|
18
|
+
* already present). Call this with category, id, and optional opts; the function decides
|
|
19
|
+
* whether to return the existing path, resume an interrupted operation, or start download/extraction.
|
|
20
|
+
*
|
|
21
|
+
* Use this as the main API when you only need "make this model ready"; the lower-level
|
|
22
|
+
* APIs (downloadModelByCategory, resumeDownload, extractModelByCategory, getIncompleteExtractions,
|
|
23
|
+
* etc.) remain available for advanced flows.
|
|
24
|
+
*/
|
|
25
|
+
export declare function ensureModelByCategory<T extends ModelMetaBase>(category: ModelCategory, id: string, opts?: EnsureModelOptions): Promise<DownloadResult>;
|
|
26
|
+
//# sourceMappingURL=ensureModel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensureModel.d.ts","sourceRoot":"","sources":["../../../../src/download/ensureModel.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACb,aAAa,EACb,gBAAgB,EACjB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAkB9C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,sDAAsD;IACtD,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAClD,+DAA+D;IAC/D,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,mGAAmG;IACnG,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,iEAAiE;IACjE,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7D,gGAAgG;IAChG,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAsB,qBAAqB,CAAC,CAAC,SAAS,aAAa,EACjE,QAAQ,EAAE,aAAa,EACvB,EAAE,EAAE,MAAM,EACV,IAAI,CAAC,EAAE,kBAAkB,GACxB,OAAO,CAAC,cAAc,CAAC,CAuEzB"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export { extractTarBz2 } from '
|
|
2
|
-
export type { ExtractProgressEvent } from '
|
|
3
|
-
export {
|
|
4
|
-
export type {
|
|
5
|
-
export {
|
|
1
|
+
export { extractTarBz2 } from '../extraction/extractTarBz2';
|
|
2
|
+
export type { ExtractProgressEvent } from '../extraction/extractTarBz2';
|
|
3
|
+
export { extractTarZst } from '../extraction/extractTarZst';
|
|
4
|
+
export type { ExtractProgressEvent as ExtractZstProgressEvent } from '../extraction/extractTarZst';
|
|
5
|
+
export { listModelsByCategory, refreshModelsByCategory, getModelsCacheStatusByCategory, getModelByIdByCategory, listDownloadedModelsByCategory, isModelDownloadedByCategory, getLocalModelPathByCategory, downloadModelByCategory, deleteModelByCategory, clearModelCacheByCategory, getDownloadStorageBase, subscribeDownloadProgress, subscribeModelsListUpdated, updateModelLastUsed, listDownloadedModelsWithMetadata, cleanupLeastRecentlyUsed, getIncompleteDownloads, resumeDownload, deleteIncompleteDownload, extractModelByCategory, getIncompleteExtractions, resumeExtraction, deleteIncompleteExtraction, ensureModelByCategory, ModelCategory, getProtectedModelKeysForBulkDelete, purgeDownloadedModelArtifacts, } from './ModelDownloadManager';
|
|
6
|
+
export type { ModelMetaBase, TtsModelMeta, TtsModelType, Quantization, SizeTier, DownloadProgress, DownloadProgressListener, ModelsListUpdatedListener, DownloadResult, DownloadState, ExtractionState, ModelWithMetadata, EnsureModelOptions, PurgeDownloadedModelArtifactsResult, } from './ModelDownloadManager';
|
|
7
|
+
export { validateChecksum, validateExtractedFiles, checkDiskSpace, resolveActualModelDir, setExpectedFilesForCategory, getExpectedFilesForCategory, parseChecksumFile, calculateFileChecksum, } from './validation';
|
|
6
8
|
export type { ValidationError } from './validation';
|
|
7
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/download/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/download/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,YAAY,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,YAAY,EAAE,oBAAoB,IAAI,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACnG,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,8BAA8B,EAC9B,sBAAsB,EACtB,8BAA8B,EAC9B,2BAA2B,EAC3B,2BAA2B,EAC3B,uBAAuB,EACvB,qBAAqB,EACrB,yBAAyB,EACzB,sBAAsB,EACtB,yBAAyB,EACzB,0BAA0B,EAC1B,mBAAmB,EACnB,gCAAgC,EAChC,wBAAwB,EACxB,sBAAsB,EACtB,cAAc,EACd,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,EACxB,gBAAgB,EAChB,0BAA0B,EAC1B,qBAAqB,EACrB,aAAa,EACb,kCAAkC,EAClC,6BAA6B,GAC9B,MAAM,wBAAwB,CAAC;AAChC,YAAY,EACV,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,gBAAgB,EAChB,wBAAwB,EACxB,yBAAyB,EACzB,cAAc,EACd,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,mCAAmC,GACpC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,cAAc,EACd,qBAAqB,EACrB,2BAA2B,EAC3B,2BAA2B,EAC3B,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ModelCategory, ModelMetaBase, ModelWithMetadata } from './types';
|
|
2
|
+
export declare function listDownloadedModelsByCategory<T extends ModelMetaBase>(category: ModelCategory): Promise<T[]>;
|
|
3
|
+
export declare function isModelDownloadedByCategory(category: ModelCategory, id: string): Promise<boolean>;
|
|
4
|
+
export declare function getLocalModelPathByCategory(category: ModelCategory, id: string): Promise<string | null>;
|
|
5
|
+
export declare function updateModelLastUsed(category: ModelCategory, id: string): Promise<void>;
|
|
6
|
+
export declare function listDownloadedModelsWithMetadata<T extends ModelMetaBase>(category: ModelCategory): Promise<ModelWithMetadata<T>[]>;
|
|
7
|
+
export declare function cleanupLeastRecentlyUsed(category: ModelCategory, options?: {
|
|
8
|
+
targetBytes?: number;
|
|
9
|
+
maxModelsToDelete?: number;
|
|
10
|
+
keepCount?: number;
|
|
11
|
+
}): Promise<string[]>;
|
|
12
|
+
export declare function deleteModelByCategory(category: ModelCategory, id: string): Promise<void>;
|
|
13
|
+
export declare function clearModelCacheByCategory(category: ModelCategory): Promise<void>;
|
|
14
|
+
export declare function getDownloadStorageBase(): Promise<string>;
|
|
15
|
+
//# sourceMappingURL=localModels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localModels.d.ts","sourceRoot":"","sources":["../../../../src/download/localModels.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EAEb,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAejB,wBAAsB,8BAA8B,CAAC,CAAC,SAAS,aAAa,EAC1E,QAAQ,EAAE,aAAa,GACtB,OAAO,CAAC,CAAC,EAAE,CAAC,CAyBd;AAED,wBAAsB,2BAA2B,CAC/C,QAAQ,EAAE,aAAa,EACvB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,OAAO,CAAC,CAGlB;AAED,wBAAsB,2BAA2B,CAC/C,QAAQ,EAAE,aAAa,EACvB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQxB;AAED,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,aAAa,EACvB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,IAAI,CAAC,CAaf;AAED,wBAAsB,gCAAgC,CAAC,CAAC,SAAS,aAAa,EAC5E,QAAQ,EAAE,aAAa,GACtB,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,CAAC,CAqCjC;AAED,wBAAsB,wBAAwB,CAC5C,QAAQ,EAAE,aAAa,EACvB,OAAO,CAAC,EAAE;IACR,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GACA,OAAO,CAAC,MAAM,EAAE,CAAC,CAkDnB;AAED,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,aAAa,EACvB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,IAAI,CAAC,CAgBf;AAED,wBAAsB,yBAAyB,CAC7C,QAAQ,EAAE,aAAa,GACtB,OAAO,CAAC,IAAI,CAAC,CAMf;AAED,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,MAAM,CAAC,CAK9D"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ModelCategory, ModelMetaBase, ChecksumIssue, DownloadProgress, ExtractionState } from './types';
|
|
2
|
+
import type { DownloadResult } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Start extraction for a model: archive must already exist (e.g. after download or from PAD).
|
|
5
|
+
* Writes extraction state so that if the app crashes, extraction can be resumed via
|
|
6
|
+
* getIncompleteExtractions + resumeExtraction.
|
|
7
|
+
* Use signal to abort (pause) extraction.
|
|
8
|
+
*/
|
|
9
|
+
export declare function extractModelByCategory<T extends ModelMetaBase>(category: ModelCategory, id: string, opts?: {
|
|
10
|
+
onProgress?: (progress: DownloadProgress) => void;
|
|
11
|
+
signal?: AbortSignal;
|
|
12
|
+
onChecksumIssue?: (issue: ChecksumIssue) => Promise<boolean>;
|
|
13
|
+
deleteArchiveAfterExtract?: boolean;
|
|
14
|
+
}): Promise<DownloadResult>;
|
|
15
|
+
/**
|
|
16
|
+
* Returns models in the given category that have incomplete extractions (e.g. after app
|
|
17
|
+
* crash during extraction). Use with resumeExtraction to continue.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getIncompleteExtractions(category: ModelCategory): Promise<ExtractionState[]>;
|
|
20
|
+
/**
|
|
21
|
+
* Resume an incomplete extraction (e.g. after app restart). Use getIncompleteExtractions
|
|
22
|
+
* to discover items to resume. Runs extraction from the start (archive is overwritten into
|
|
23
|
+
* model dir with force).
|
|
24
|
+
*/
|
|
25
|
+
export declare function resumeExtraction<T extends ModelMetaBase>(category: ModelCategory, id: string, opts?: {
|
|
26
|
+
onProgress?: (progress: DownloadProgress) => void;
|
|
27
|
+
signal?: AbortSignal;
|
|
28
|
+
onChecksumIssue?: (issue: ChecksumIssue) => Promise<boolean>;
|
|
29
|
+
deleteArchiveAfterExtract?: boolean;
|
|
30
|
+
}): Promise<DownloadResult>;
|
|
31
|
+
/**
|
|
32
|
+
* Cancel/delete an incomplete extraction: removes extraction state and partial model dir.
|
|
33
|
+
* Does not delete the archive so the user can retry extraction later.
|
|
34
|
+
*/
|
|
35
|
+
export declare function deleteIncompleteExtraction(category: ModelCategory, id: string): Promise<void>;
|
|
36
|
+
//# sourceMappingURL=modelExtraction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modelExtraction.d.ts","sourceRoot":"","sources":["../../../../src/download/modelExtraction.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,eAAe,EAChB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAoB9C;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAAC,CAAC,SAAS,aAAa,EAClE,QAAQ,EAAE,aAAa,EACvB,EAAE,EAAE,MAAM,EACV,IAAI,CAAC,EAAE;IACL,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAClD,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7D,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC,GACA,OAAO,CAAC,cAAc,CAAC,CAkDzB;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,CAC5C,QAAQ,EAAE,aAAa,GACtB,OAAO,CAAC,eAAe,EAAE,CAAC,CAoD5B;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,SAAS,aAAa,EAC5D,QAAQ,EAAE,aAAa,EACvB,EAAE,EAAE,MAAM,EACV,IAAI,CAAC,EAAE;IACL,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAClD,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7D,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC,GACA,OAAO,CAAC,cAAc,CAAC,CA4CzB;AAED;;;GAGG;AACH,wBAAsB,0BAA0B,CAC9C,QAAQ,EAAE,aAAa,EACvB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,IAAI,CAAC,CAcf"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ModelCategory } from './types';
|
|
2
|
+
import type { ModelArchiveExt } from './types';
|
|
3
|
+
export declare const CATEGORY_CONFIG: Record<ModelCategory, {
|
|
4
|
+
tag: string;
|
|
5
|
+
cacheFile: string;
|
|
6
|
+
baseDir: string;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function getCacheDir(): string;
|
|
9
|
+
export declare function getCachePath(category: ModelCategory): string;
|
|
10
|
+
export declare function getModelsBaseDir(category: ModelCategory): string;
|
|
11
|
+
export declare function getModelDir(category: ModelCategory, modelId: string): string;
|
|
12
|
+
export declare function getArchiveFilename(modelId: string, archiveExt: ModelArchiveExt): string;
|
|
13
|
+
export declare function getArchivePath(category: ModelCategory, modelId: string, archiveExt: ModelArchiveExt): string;
|
|
14
|
+
export declare function getTarArchivePath(category: ModelCategory, modelId: string): string;
|
|
15
|
+
export declare function getOnnxPath(category: ModelCategory, modelId: string): string;
|
|
16
|
+
export declare function getReadyMarkerPath(category: ModelCategory, modelId: string): string;
|
|
17
|
+
export declare function getManifestPath(category: ModelCategory, modelId: string): string;
|
|
18
|
+
export declare function getDownloadStatePath(category: ModelCategory, modelId: string): string;
|
|
19
|
+
/** Path to extraction state file; used to detect and resume incomplete extractions after app restart. */
|
|
20
|
+
export declare function getExtractionStatePath(category: ModelCategory, modelId: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Directory where native `resolveAssetPath` materializes a bundled model folder
|
|
23
|
+
* (`DocumentDirectoryPath/models/{modelId}` — Android internal `files/models/...`).
|
|
24
|
+
* Separate from {@link getModelDir}. Remove on delete so empty dirs do not break detection.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getNativeAssetExtractedModelDir(modelId: string): string;
|
|
27
|
+
export declare function getReleaseUrl(category: ModelCategory): string;
|
|
28
|
+
//# sourceMappingURL=paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../../../src/download/paths.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG/C,eAAO,MAAM,eAAe,EAAE,MAAM,CAClC,aAAa,EACb;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAqCpD,CAAC;AAEF,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,CAE5D;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,CAEhE;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAE5E;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,eAAe,GAC1B,MAAM,CAER;AAED,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,aAAa,EACvB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,eAAe,GAC1B,MAAM,CAMR;AAED,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,aAAa,EACvB,OAAO,EAAE,MAAM,GACd,MAAM,CAER;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAE5E;AAED,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,aAAa,EACvB,OAAO,EAAE,MAAM,GACd,MAAM,CAER;AAED,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,aAAa,EACvB,OAAO,EAAE,MAAM,GACd,MAAM,CAER;AAED,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,aAAa,EACvB,OAAO,EAAE,MAAM,GACd,MAAM,CAER;AAED,yGAAyG;AACzG,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,aAAa,EACvB,OAAO,EAAE,MAAM,GACd,MAAM,CAER;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGvE;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,CAE7D"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ModelCategory, ModelMetaBase, ChecksumIssue, DownloadProgress } from './types';
|
|
2
|
+
import type { DownloadResult } from './types';
|
|
3
|
+
export type RunPostDownloadProcessingOptions = {
|
|
4
|
+
category: ModelCategory;
|
|
5
|
+
id: string;
|
|
6
|
+
model: ModelMetaBase;
|
|
7
|
+
downloadPath: string;
|
|
8
|
+
modelDir: string;
|
|
9
|
+
isArchive: boolean;
|
|
10
|
+
statePath: string;
|
|
11
|
+
signal?: AbortSignal;
|
|
12
|
+
onChecksumIssue?: (issue: ChecksumIssue) => Promise<boolean>;
|
|
13
|
+
deleteArchiveAfterExtract?: boolean;
|
|
14
|
+
onProgress?: (progress: DownloadProgress) => void;
|
|
15
|
+
/** Called to get current list of downloaded models for emitModelsListUpdated. */
|
|
16
|
+
getDownloadedList: () => Promise<ModelMetaBase[]>;
|
|
17
|
+
};
|
|
18
|
+
export declare function runPostDownloadProcessing(options: RunPostDownloadProcessingOptions): Promise<DownloadResult>;
|
|
19
|
+
//# sourceMappingURL=postDownloadProcessing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postDownloadProcessing.d.ts","sourceRoot":"","sources":["../../../../src/download/postDownloadProcessing.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EAEb,aAAa,EACb,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAcjB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAM9C,MAAM,MAAM,gCAAgC,GAAG;IAC7C,QAAQ,EAAE,aAAa,CAAC;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,aAAa,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7D,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAClD,iFAAiF;IACjF,iBAAiB,EAAE,MAAM,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;CACnD,CAAC;AAEF,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,gCAAgC,GACxC,OAAO,CAAC,cAAc,CAAC,CAmCzB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model keys (`category:modelId`) that must not be removed by bulk delete: active JS download tasks,
|
|
3
|
+
* native background-downloader tasks, and models in post-download processing (extraction / validation).
|
|
4
|
+
*/
|
|
5
|
+
export declare function getProtectedModelKeysForBulkDelete(): Promise<ReadonlySet<string>>;
|
|
6
|
+
//# sourceMappingURL=protectedModelKeys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protectedModelKeys.d.ts","sourceRoot":"","sources":["../../../../src/download/protectedModelKeys.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAsB,kCAAkC,IAAI,OAAO,CACjE,WAAW,CAAC,MAAM,CAAC,CACpB,CAmBA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ModelCategory } from './types';
|
|
2
|
+
import type { ModelMetaBase, CacheStatus } from './types';
|
|
3
|
+
export declare function fetchChecksumsFromRelease(category: ModelCategory): Promise<Map<string, string>>;
|
|
4
|
+
export declare function listModelsByCategory<T extends ModelMetaBase>(category: ModelCategory): Promise<T[]>;
|
|
5
|
+
export declare function refreshModelsByCategory<T extends ModelMetaBase>(category: ModelCategory, options?: {
|
|
6
|
+
forceRefresh?: boolean;
|
|
7
|
+
cacheTtlMinutes?: number;
|
|
8
|
+
maxRetries?: number;
|
|
9
|
+
signal?: AbortSignal;
|
|
10
|
+
}): Promise<T[]>;
|
|
11
|
+
export declare function getModelsCacheStatusByCategory(category: ModelCategory): Promise<CacheStatus>;
|
|
12
|
+
export declare function getModelByIdByCategory<T extends ModelMetaBase>(category: ModelCategory, id: string): Promise<T | null>;
|
|
13
|
+
export declare function clearMemoryCacheForCategory(category: ModelCategory): void;
|
|
14
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../../src/download/registry.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,KAAK,EACV,aAAa,EAGb,WAAW,EAKZ,MAAM,SAAS,CAAC;AAyBjB,wBAAsB,yBAAyB,CAC7C,QAAQ,EAAE,aAAa,GACtB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAgC9B;AA4ND,wBAAsB,oBAAoB,CAAC,CAAC,SAAS,aAAa,EAChE,QAAQ,EAAE,aAAa,GACtB,OAAO,CAAC,CAAC,EAAE,CAAC,CAGd;AAED,wBAAsB,uBAAuB,CAAC,CAAC,SAAS,aAAa,EACnE,QAAQ,EAAE,aAAa,EACvB,OAAO,CAAC,EAAE;IACR,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,GACA,OAAO,CAAC,CAAC,EAAE,CAAC,CAsEd;AAED,wBAAsB,8BAA8B,CAClD,QAAQ,EAAE,aAAa,GACtB,OAAO,CAAC,WAAW,CAAC,CAMtB;AAED,wBAAsB,sBAAsB,CAAC,CAAC,SAAS,aAAa,EAClE,QAAQ,EAAE,aAAa,EACvB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAGnB;AAED,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI,CAGzE"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retry helper with exponential backoff
|
|
3
|
+
* @param fn - The async function to retry
|
|
4
|
+
* @param options - Retry configuration
|
|
5
|
+
* @returns The result of the function
|
|
6
|
+
* @throws The last error if all retries fail or AbortError if aborted
|
|
7
|
+
*/
|
|
8
|
+
export declare function retryWithBackoff<T>(fn: () => Promise<T>, options?: {
|
|
9
|
+
maxRetries?: number;
|
|
10
|
+
initialDelayMs?: number;
|
|
11
|
+
maxDelayMs?: number;
|
|
12
|
+
backoffFactor?: number;
|
|
13
|
+
signal?: AbortSignal;
|
|
14
|
+
}): Promise<T>;
|
|
15
|
+
//# sourceMappingURL=retry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../../../src/download/retry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EACtC,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,OAAO,GAAE;IACP,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,WAAW,CAAC;CACjB,GACL,OAAO,CAAC,CAAC,CAAC,CA2DZ"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { TTSModelType } from '../tts/types';
|
|
2
|
+
export declare enum ModelCategory {
|
|
3
|
+
Tts = "tts",
|
|
4
|
+
Stt = "stt",
|
|
5
|
+
Vad = "vad",
|
|
6
|
+
Diarization = "diarization",
|
|
7
|
+
Enhancement = "enhancement",
|
|
8
|
+
Separation = "separation",
|
|
9
|
+
Qnn = "qnn"
|
|
10
|
+
}
|
|
11
|
+
/** TTS model type for meta; 'unknown' when id could not be classified. */
|
|
12
|
+
export type TtsModelType = TTSModelType | 'unknown';
|
|
13
|
+
export type Quantization = 'fp16' | 'int8' | 'int8-quantized' | 'unknown';
|
|
14
|
+
export type SizeTier = 'tiny' | 'small' | 'medium' | 'large' | 'unknown';
|
|
15
|
+
export type ModelArchiveExt = 'tar.bz2' | 'onnx';
|
|
16
|
+
export type ModelMetaBase = {
|
|
17
|
+
id: string;
|
|
18
|
+
displayName: string;
|
|
19
|
+
downloadUrl: string;
|
|
20
|
+
archiveExt: ModelArchiveExt;
|
|
21
|
+
bytes: number;
|
|
22
|
+
sha256?: string;
|
|
23
|
+
category: ModelCategory;
|
|
24
|
+
};
|
|
25
|
+
export type TtsModelMeta = ModelMetaBase & {
|
|
26
|
+
type: TtsModelType;
|
|
27
|
+
languages: string[];
|
|
28
|
+
quantization: Quantization;
|
|
29
|
+
sizeTier: SizeTier;
|
|
30
|
+
category: ModelCategory.Tts;
|
|
31
|
+
};
|
|
32
|
+
export type DownloadProgress = {
|
|
33
|
+
bytesDownloaded: number;
|
|
34
|
+
totalBytes: number;
|
|
35
|
+
percent: number;
|
|
36
|
+
phase?: 'downloading' | 'extracting';
|
|
37
|
+
speed?: number;
|
|
38
|
+
eta?: number;
|
|
39
|
+
};
|
|
40
|
+
export type DownloadResult = {
|
|
41
|
+
modelId: string;
|
|
42
|
+
localPath: string;
|
|
43
|
+
};
|
|
44
|
+
export type DownloadState = {
|
|
45
|
+
modelId: string;
|
|
46
|
+
category: ModelCategory;
|
|
47
|
+
phase: 'downloading' | 'extracting';
|
|
48
|
+
startedAt: string;
|
|
49
|
+
archivePath: string;
|
|
50
|
+
model: ModelMetaBase;
|
|
51
|
+
bytesDownloaded?: number;
|
|
52
|
+
totalBytes?: number;
|
|
53
|
+
};
|
|
54
|
+
/** State for an in-progress or interrupted model extraction (archive --> model dir). */
|
|
55
|
+
export type ExtractionState = {
|
|
56
|
+
modelId: string;
|
|
57
|
+
category: ModelCategory;
|
|
58
|
+
phase: 'extracting';
|
|
59
|
+
startedAt: string;
|
|
60
|
+
archivePath: string;
|
|
61
|
+
modelDir: string;
|
|
62
|
+
model: ModelMetaBase;
|
|
63
|
+
};
|
|
64
|
+
export type DownloadProgressListener = (category: ModelCategory, modelId: string, progress: DownloadProgress) => void;
|
|
65
|
+
export type ModelsListUpdatedListener = (category: ModelCategory, models: ModelMetaBase[]) => void;
|
|
66
|
+
export type ModelManifest<T extends ModelMetaBase = ModelMetaBase> = {
|
|
67
|
+
downloadedAt: string;
|
|
68
|
+
lastUsed?: string;
|
|
69
|
+
model: T;
|
|
70
|
+
sizeOnDisk?: number;
|
|
71
|
+
};
|
|
72
|
+
export type ModelWithMetadata<T extends ModelMetaBase = ModelMetaBase> = {
|
|
73
|
+
model: T;
|
|
74
|
+
downloadedAt: string;
|
|
75
|
+
lastUsed: string | null;
|
|
76
|
+
sizeOnDisk?: number;
|
|
77
|
+
status: 'ready' | 'downloading' | 'extracting' | 'failed';
|
|
78
|
+
progress?: number;
|
|
79
|
+
};
|
|
80
|
+
export type ChecksumIssue = {
|
|
81
|
+
category: ModelCategory;
|
|
82
|
+
id: string;
|
|
83
|
+
archivePath: string;
|
|
84
|
+
expected?: string;
|
|
85
|
+
message: string;
|
|
86
|
+
reason: 'CHECKSUM_FAILED' | 'CHECKSUM_MISMATCH';
|
|
87
|
+
};
|
|
88
|
+
export type CachePayload<T extends ModelMetaBase> = {
|
|
89
|
+
lastUpdated: string;
|
|
90
|
+
models: T[];
|
|
91
|
+
};
|
|
92
|
+
export type CacheStatus = {
|
|
93
|
+
lastUpdated: string | null;
|
|
94
|
+
source: 'cache' | 'remote';
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/download/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -5,6 +5,11 @@ export declare class ValidationResult {
|
|
|
5
5
|
message?: string;
|
|
6
6
|
constructor(success: boolean, error?: ValidationError, message?: string);
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* Delete a directory and all contents. No-op if the path is missing.
|
|
10
|
+
* Best-effort: continues on per-entry errors (permissions, race).
|
|
11
|
+
*/
|
|
12
|
+
export declare function removeDirectoryRecursive(dirPath: string): Promise<void>;
|
|
8
13
|
/**
|
|
9
14
|
* Parse checksum.txt format into a Map of filename -> hash
|
|
10
15
|
* Expected format:
|
|
@@ -32,6 +37,20 @@ export declare function validateChecksum(filePath: string, expectedChecksum: str
|
|
|
32
37
|
* so we don't need to check for specific filenames here.
|
|
33
38
|
*/
|
|
34
39
|
export declare function validateExtractedFiles(modelDir: string, _category: string): Promise<ValidationResult>;
|
|
40
|
+
/**
|
|
41
|
+
* Resolve the directory that actually contains model files.
|
|
42
|
+
* After extracting a tarball, model files often end up in a single top-level subdirectory
|
|
43
|
+
* (e.g. installDir/modelId/encoder.onnx). Native APIs expect the path to the folder
|
|
44
|
+
* that directly contains encoder.onnx, decoder.onnx, etc.
|
|
45
|
+
*
|
|
46
|
+
* - If installDir itself contains native model files (.onnx/.bin), returns installDir.
|
|
47
|
+
* - If installDir has exactly one subdirectory that contains native model files, returns that subdirectory path.
|
|
48
|
+
* (Ignores our metadata: .ready, manifest.json.) This can produce paths like
|
|
49
|
+
* .../tts/vits-piper-de_DE-thorsten-medium-int8/vits-piper-de_DE-thorsten-medium-int8 when the
|
|
50
|
+
* archive extracts a top-level folder with the same name as the model id; that is intentional.
|
|
51
|
+
* - Otherwise returns installDir unchanged.
|
|
52
|
+
*/
|
|
53
|
+
export declare function resolveActualModelDir(installDir: string): Promise<string>;
|
|
35
54
|
/**
|
|
36
55
|
* Get available disk space (in bytes)
|
|
37
56
|
* This is a simplified version. For accurate values on Android/iOS, use native modules.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../../src/download/validation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../../src/download/validation.ts"],"names":[],"mappings":"AAUA,MAAM,MAAM,eAAe,GACvB,mBAAmB,GACnB,iBAAiB,GACjB,eAAe,GACf,yBAAyB,CAAC;AAE9B,qBAAa,gBAAgB;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;gBAEL,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,MAAM;CAKxE;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAyB7E;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAYtE;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,CACX,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,KACZ,IAAI,GACR,OAAO,CAAC,MAAM,CAAC,CAYjB;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,EAChB,gBAAgB,EAAE,MAAM,EACxB,UAAU,CAAC,EAAE,CACX,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,KACZ,IAAI,GACR,OAAO,CAAC,gBAAgB,CAAC,CAmB3B;AAED;;;;;;;;GAQG;AACH,wBAAsB,sBAAsB,CAC1C,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,gBAAgB,CAAC,CAyF3B;AA2BD;;;;;;;;;;;;GAYG;AACH,wBAAsB,qBAAqB,CACzC,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,CAAC,CA6BjB;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,MAAM,CAAC,CAe7D;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAClC,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,gBAAgB,CAAC,CAwB3B;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EAAE,GACf,IAAI,CAEN;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAGvE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractTarBz2.d.ts","sourceRoot":"","sources":["../../../../src/extraction/extractTarBz2.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAsB,aAAa,CACjC,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,KAAK,UAAO,EACZ,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,EAClD,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,aAAa,CAAC,CAyDxB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type ExtractProgressEvent = {
|
|
2
|
+
bytes: number;
|
|
3
|
+
totalBytes: number;
|
|
4
|
+
percent: number;
|
|
5
|
+
};
|
|
6
|
+
type ExtractResult = {
|
|
7
|
+
success: boolean;
|
|
8
|
+
path?: string;
|
|
9
|
+
sha256?: string;
|
|
10
|
+
reason?: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function extractTarZst(sourcePath: string, targetPath: string, force?: boolean, onProgress?: (event: ExtractProgressEvent) => void, signal?: AbortSignal): Promise<ExtractResult>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=extractTarZst.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractTarZst.d.ts","sourceRoot":"","sources":["../../../../src/extraction/extractTarZst.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAsB,aAAa,CACjC,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,KAAK,UAAO,EACZ,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,EAClD,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,aAAa,CAAC,CAwDxB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extraction subpath: list and extract compressed model archives (.tar.zst / .tar.bz2).
|
|
3
|
+
*
|
|
4
|
+
* Three entry points:
|
|
5
|
+
* - getBundledArchives(packName) – Android PAD packs (STORAGE_FILES or APK_ASSETS)
|
|
6
|
+
* - listBundledArchives(dirPath) – any filesystem directory (cross-platform)
|
|
7
|
+
* - extractArchive(archive, target) – unified extraction (auto-selects path or asset-stream)
|
|
8
|
+
*
|
|
9
|
+
* After extraction, use listModelsAtPath / autoModelPath from the main package.
|
|
10
|
+
*/
|
|
11
|
+
import type { BundledArchive, ExtractArchiveOptions, ExtractResult } from './types';
|
|
12
|
+
export type { BundledArchive, ExtractArchiveOptions, ExtractResult, ExtractProgressEvent, } from './types';
|
|
13
|
+
/**
|
|
14
|
+
* List compressed archives delivered via a **Play Asset Delivery** pack.
|
|
15
|
+
*
|
|
16
|
+
* - **STORAGE_FILES** packs: scans the pack directory on the filesystem.
|
|
17
|
+
* - **APK_ASSETS** packs: queries the Android AssetManager for embedded archive paths.
|
|
18
|
+
* Archives returned with `fromAsset: true` are extracted by streaming from the APK
|
|
19
|
+
* (no temp copy needed).
|
|
20
|
+
* - **iOS / unavailable pack**: returns `null`.
|
|
21
|
+
*
|
|
22
|
+
* @param packName Name of the PAD asset pack (e.g. `"sherpa_models"`)
|
|
23
|
+
*/
|
|
24
|
+
export declare function getBundledArchives(packName: string): Promise<BundledArchive[] | null>;
|
|
25
|
+
/**
|
|
26
|
+
* List `.tar.zst` and `.tar.bz2` archives in a filesystem directory.
|
|
27
|
+
*
|
|
28
|
+
* Works on **all platforms** — use for:
|
|
29
|
+
* - iOS main-bundle archives (`MainBundlePath + '/models'`)
|
|
30
|
+
* - Archives downloaded to the documents directory
|
|
31
|
+
* - Any other folder containing compressed model archives
|
|
32
|
+
*
|
|
33
|
+
* @param directoryPath Absolute path to the directory to scan
|
|
34
|
+
*/
|
|
35
|
+
export declare function listBundledArchives(directoryPath: string): Promise<BundledArchive[]>;
|
|
36
|
+
/**
|
|
37
|
+
* Extract a single archive to the target directory.
|
|
38
|
+
*
|
|
39
|
+
* Handles both source types transparently:
|
|
40
|
+
* - **Filesystem archives** (from `listBundledArchives` or PAD STORAGE_FILES) —
|
|
41
|
+
* uses the regular path-based extraction.
|
|
42
|
+
* - **APK asset archives** (`fromAsset: true`, from PAD APK_ASSETS) —
|
|
43
|
+
* streams directly from the APK without copying the archive to disk first.
|
|
44
|
+
*
|
|
45
|
+
* @param archive Descriptor returned by `getBundledArchives` or `listBundledArchives`
|
|
46
|
+
* @param targetPath Directory to extract into (e.g. `DocumentDirectoryPath + '/models'`)
|
|
47
|
+
* @param options `force` (default `true`), `onProgress`, `signal` (AbortSignal)
|
|
48
|
+
*/
|
|
49
|
+
export declare function extractArchive(archive: BundledArchive, targetPath: string, options?: ExtractArchiveOptions): Promise<ExtractResult>;
|
|
50
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/extraction/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAOH,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EACrB,aAAa,EAEd,MAAM,SAAS,CAAC;AAEjB,YAAY,EACV,cAAc,EACd,qBAAqB,EACrB,aAAa,EACb,oBAAoB,GACrB,MAAM,SAAS,CAAC;AAyDjB;;;;;;;;;;GAUG;AACH,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,cAAc,EAAE,GAAG,IAAI,CAAC,CAyBlC;AAED;;;;;;;;;GASG;AACH,wBAAsB,mBAAmB,CACvC,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,cAAc,EAAE,CAAC,CAE3B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,cAAc,EACvB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,aAAa,CAAC,CAoCxB"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the extraction subpath.
|
|
3
|
+
*
|
|
4
|
+
* A BundledArchive describes a compressed model archive (.tar.zst or .tar.bz2)
|
|
5
|
+
* that can come from two distinct sources:
|
|
6
|
+
*
|
|
7
|
+
* 1. **Filesystem** — a regular file on disk (PAD STORAGE_FILES, iOS bundle,
|
|
8
|
+
* downloaded archive, etc.). `fromAsset` is absent or `false`.
|
|
9
|
+
* 2. **Android APK asset** — embedded in the APK via PAD APK_ASSETS.
|
|
10
|
+
* `fromAsset` is `true`; extraction streams directly from the APK.
|
|
11
|
+
*
|
|
12
|
+
* The consumer does not need to distinguish between the two:
|
|
13
|
+
* `extractArchive()` handles both transparently.
|
|
14
|
+
*/
|
|
15
|
+
/** Describes one compressed model archive. */
|
|
16
|
+
export type BundledArchive = {
|
|
17
|
+
/** Identifier derived from the archive filename (filename minus the extension). */
|
|
18
|
+
modelId: string;
|
|
19
|
+
/**
|
|
20
|
+
* Path to the archive.
|
|
21
|
+
* - Filesystem archives: absolute path (e.g. `/data/.../models/whisper-tiny.tar.zst`).
|
|
22
|
+
* - APK assets: asset path (e.g. `asset_packs/sherpa_models/assets/whisper-tiny.tar.zst`).
|
|
23
|
+
*/
|
|
24
|
+
archivePath: string;
|
|
25
|
+
/** Compression format. */
|
|
26
|
+
format: 'tar.zst' | 'tar.bz2';
|
|
27
|
+
/** File size in bytes (available for filesystem archives; 0 or absent for APK assets). */
|
|
28
|
+
fileSize?: number;
|
|
29
|
+
/** `true` when the archive lives inside the APK (APK_ASSETS). Absent for filesystem archives. */
|
|
30
|
+
fromAsset?: boolean;
|
|
31
|
+
};
|
|
32
|
+
/** Progress event emitted during extraction. */
|
|
33
|
+
export type ExtractProgressEvent = {
|
|
34
|
+
/** Bytes extracted so far. */
|
|
35
|
+
bytes: number;
|
|
36
|
+
/** Total bytes of the archive (may be 0 when unknown). */
|
|
37
|
+
totalBytes: number;
|
|
38
|
+
/** Progress percentage 0–100. */
|
|
39
|
+
percent: number;
|
|
40
|
+
};
|
|
41
|
+
/** Result returned by `extractArchive`. */
|
|
42
|
+
export type ExtractResult = {
|
|
43
|
+
success: boolean;
|
|
44
|
+
/** Absolute path to the extracted directory (on success). */
|
|
45
|
+
path?: string;
|
|
46
|
+
/** SHA-256 hex digest of the source archive (when available). */
|
|
47
|
+
sha256?: string;
|
|
48
|
+
/** Error description (on failure). */
|
|
49
|
+
reason?: string;
|
|
50
|
+
};
|
|
51
|
+
/** Options for `extractArchive`. */
|
|
52
|
+
export type ExtractArchiveOptions = {
|
|
53
|
+
/** Overwrite existing files. Defaults to `true`. */
|
|
54
|
+
force?: boolean;
|
|
55
|
+
/** Callback for extraction progress. */
|
|
56
|
+
onProgress?: (event: ExtractProgressEvent) => void;
|
|
57
|
+
/** AbortSignal to cancel the extraction. */
|
|
58
|
+
signal?: AbortSignal;
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/extraction/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,8CAA8C;AAC9C,MAAM,MAAM,cAAc,GAAG;IAC3B,mFAAmF;IACnF,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,0BAA0B;IAC1B,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC;IAC9B,0FAA0F;IAC1F,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iGAAiG;IACjG,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,gDAAgD;AAChD,MAAM,MAAM,oBAAoB,GAAG;IACjC,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,iCAAiC;IACjC,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,2CAA2C;AAC3C,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,6DAA6D;IAC7D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,oCAAoC;AACpC,MAAM,MAAM,qBAAqB,GAAG;IAClC,oDAAoD;IACpD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,wCAAwC;IACxC,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,CAAC;IACnD,4CAA4C;IAC5C,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC"}
|
|
@@ -3,6 +3,7 @@ export type { AccelerationSupport } from './NativeSherpaOnnx';
|
|
|
3
3
|
export type { ModelPathConfig } from './types';
|
|
4
4
|
export { assetModelPath, autoModelPath, fileModelPath, getAssetPackPath, getDefaultModelPath, getPlayAssetDeliveryModelsPath, listAssetModels, listModelsAtPath, resolveModelPath, } from './utils';
|
|
5
5
|
export { copyFileToContentUri } from './tts';
|
|
6
|
+
export { getModelLicenses, type ModelLicense } from './licenses';
|
|
6
7
|
/**
|
|
7
8
|
* Test method to verify sherpa-onnx native library is loaded.
|
|
8
9
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAG9D,YAAY,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EACL,cAAc,EACd,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,8BAA8B,EAC9B,eAAe,EACf,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAG9D,YAAY,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EACL,cAAc,EACd,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,8BAA8B,EAC9B,eAAe,EACf,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,gBAAgB,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAWjE;;GAEG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,CAEhD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,mBAAmB,CAAC,CAE9B;AAED;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,wBAAgB,eAAe,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAE7D;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAEzD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,mBAAmB,CAAC,CAE9B;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,mBAAmB,CAAC,CAE9B;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,mBAAmB,CAAC,CAE9B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface ModelLicense {
|
|
2
|
+
asset_name: string;
|
|
3
|
+
license_type: string;
|
|
4
|
+
commercial_use: 'yes' | 'no' | 'conditional' | 'restricted' | 'unknown';
|
|
5
|
+
confidence: string;
|
|
6
|
+
detection_source: string;
|
|
7
|
+
license_file: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function getModelLicenses(): Promise<ModelLicense[]>;
|
|
10
|
+
//# sourceMappingURL=licenses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"licenses.d.ts","sourceRoot":"","sources":["../../../src/licenses.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,KAAK,GAAG,IAAI,GAAG,aAAa,GAAG,YAAY,GAAG,SAAS,CAAC;IACxE,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAwChE"}
|
|
@@ -6,7 +6,7 @@ import type { ModelPathConfig } from '../types';
|
|
|
6
6
|
*
|
|
7
7
|
* @param modelPath - Model path configuration (asset, file, or auto)
|
|
8
8
|
* @param options - Optional preferInt8 and modelType (default: auto)
|
|
9
|
-
* @returns Object with success, detectedModels (array of { type, modelDir }),
|
|
9
|
+
* @returns Object with success, detectedModels (array of { type, modelDir }), modelType (primary detected type), optional error when success is false, and optionally isHardwareSpecificUnsupported
|
|
10
10
|
* @example
|
|
11
11
|
* ```typescript
|
|
12
12
|
* const path = { type: 'asset' as const, path: 'models/sherpa-onnx-whisper-tiny-en' };
|
|
@@ -21,11 +21,14 @@ export declare function detectSttModel(modelPath: ModelPathConfig, options?: {
|
|
|
21
21
|
modelType?: STTModelType;
|
|
22
22
|
}): Promise<{
|
|
23
23
|
success: boolean;
|
|
24
|
+
/** Native validation/detect failure. */
|
|
25
|
+
error?: string;
|
|
24
26
|
detectedModels: Array<{
|
|
25
27
|
type: string;
|
|
26
28
|
modelDir: string;
|
|
27
29
|
}>;
|
|
28
30
|
modelType?: string;
|
|
31
|
+
isHardwareSpecificUnsupported?: boolean;
|
|
29
32
|
}>;
|
|
30
33
|
/**
|
|
31
34
|
* Create an STT engine instance. Call destroy() on the returned engine when done to free native resources.
|