react-native-sherpa-onnx 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +232 -236
- package/SherpaOnnx.podspec +68 -64
- package/android/build.gradle +182 -192
- package/android/codegen.gradle +57 -0
- package/android/prebuilt-download.gradle +428 -0
- package/android/prebuilt-versions.gradle +43 -0
- package/android/proguard-rules.pro +10 -0
- package/android/src/main/assets/testModels/add_mul_add.onnx +28 -0
- package/android/src/main/assets/testModels/nnapi_internal_uint8_support.onnx +0 -0
- package/android/src/main/assets/testModels/qnn_multi_ctx_embed.onnx +0 -0
- package/android/src/main/cpp/CMakeLists.txt +166 -129
- package/android/src/main/cpp/CMakePresets.json +54 -0
- package/android/src/main/cpp/crypto/sha256.cpp +174 -0
- package/android/src/main/cpp/crypto/sha256.h +16 -0
- package/android/src/main/cpp/jni/archive/sherpa-onnx-archive-helper.cpp +404 -0
- package/android/src/main/cpp/jni/archive/sherpa-onnx-archive-helper.h +56 -0
- package/android/src/main/cpp/jni/archive/sherpa-onnx-archive-jni.cpp +181 -0
- package/android/src/main/cpp/jni/audio/sherpa-onnx-audio-convert-jni.cpp +888 -0
- package/{ios → android/src/main/cpp/jni/model_detect}/sherpa-onnx-common.h +18 -18
- package/android/src/main/cpp/jni/model_detect/sherpa-onnx-detect-jni-common.cpp +86 -0
- package/android/src/main/cpp/jni/model_detect/sherpa-onnx-detect-jni-common.h +20 -0
- package/android/src/main/cpp/jni/model_detect/sherpa-onnx-model-detect-helper.cpp +423 -0
- package/android/src/main/cpp/jni/model_detect/sherpa-onnx-model-detect-helper.h +55 -0
- package/android/src/main/cpp/jni/model_detect/sherpa-onnx-model-detect-stt.cpp +399 -0
- package/android/src/main/cpp/jni/model_detect/sherpa-onnx-model-detect-tts.cpp +238 -0
- package/{ios → android/src/main/cpp/jni/model_detect}/sherpa-onnx-model-detect.h +122 -89
- package/android/src/main/cpp/jni/model_detect/sherpa-onnx-stt-wrapper.cpp +99 -0
- package/android/src/main/cpp/jni/model_detect/sherpa-onnx-stt-wrapper.h +16 -0
- package/android/src/main/cpp/jni/model_detect/sherpa-onnx-tts-wrapper.cpp +78 -0
- package/android/src/main/cpp/jni/model_detect/sherpa-onnx-tts-wrapper.h +16 -0
- package/android/src/main/cpp/jni/module/sherpa-onnx-module-jni.cpp +190 -0
- package/android/src/main/cpp/jni/tts/sherpa-onnx-tts-zipvoice-jni.cpp +301 -0
- package/android/src/main/java/com/sherpaonnx/SherpaOnnxArchiveHelper.kt +94 -0
- package/android/src/main/java/com/sherpaonnx/{SherpaOnnxCoreHelper.kt → SherpaOnnxAssetHelper.kt} +350 -236
- package/android/src/main/java/com/sherpaonnx/SherpaOnnxModule.kt +791 -483
- package/android/src/main/java/com/sherpaonnx/SherpaOnnxSttHelper.kt +699 -109
- package/android/src/main/java/com/sherpaonnx/SherpaOnnxTtsHelper.kt +1123 -668
- package/android/src/main/java/com/sherpaonnx/ZipvoiceTtsWrapper.kt +187 -0
- package/ios/SherpaOnnx+Assets.h +11 -0
- package/ios/SherpaOnnx+Assets.mm +325 -0
- package/ios/SherpaOnnx+STT.mm +455 -118
- package/ios/SherpaOnnx+TTS.mm +1101 -712
- package/ios/SherpaOnnx.h +17 -6
- package/ios/SherpaOnnx.mm +206 -311
- package/ios/SherpaOnnx.xcconfig +19 -19
- package/ios/SherpaOnnxCoreMLHelper.swift +24 -0
- package/ios/archive/sherpa-onnx-archive-helper.h +21 -0
- package/ios/archive/sherpa-onnx-archive-helper.mm +296 -0
- package/ios/libarchive_darwin_config.h +153 -0
- package/{android/src/main/cpp/jni → ios/model_detect}/sherpa-onnx-common.h +18 -18
- package/ios/model_detect/sherpa-onnx-model-detect-helper.h +49 -0
- package/ios/model_detect/sherpa-onnx-model-detect-helper.mm +210 -0
- package/ios/model_detect/sherpa-onnx-model-detect-stt.mm +344 -0
- package/ios/model_detect/sherpa-onnx-model-detect-tts.mm +201 -0
- package/{android/src/main/cpp/jni → ios/model_detect}/sherpa-onnx-model-detect.h +117 -89
- package/ios/scripts/patch-libarchive-includes.sh +61 -0
- package/ios/scripts/setup-ios-libarchive.sh +98 -0
- package/ios/stt/sherpa-onnx-stt-wrapper.h +129 -0
- package/ios/stt/sherpa-onnx-stt-wrapper.mm +523 -0
- package/ios/{sherpa-onnx-tts-wrapper.h → tts/sherpa-onnx-tts-wrapper.h} +90 -85
- package/ios/{sherpa-onnx-tts-wrapper.mm → tts/sherpa-onnx-tts-wrapper.mm} +376 -345
- package/lib/module/NativeSherpaOnnx.js +3 -0
- package/lib/module/NativeSherpaOnnx.js.map +1 -1
- package/lib/module/audio/index.js +22 -0
- package/lib/module/audio/index.js.map +1 -0
- package/lib/module/diarization/index.js +1 -1
- package/lib/module/diarization/index.js.map +1 -1
- package/lib/module/download/ModelDownloadManager.js +918 -0
- package/lib/module/download/ModelDownloadManager.js.map +1 -0
- package/lib/module/download/extractTarBz2.js +53 -0
- package/lib/module/download/extractTarBz2.js.map +1 -0
- package/lib/module/download/index.js +6 -0
- package/lib/module/download/index.js.map +1 -0
- package/lib/module/download/validation.js +178 -0
- package/lib/module/download/validation.js.map +1 -0
- package/lib/module/enhancement/index.js +1 -1
- package/lib/module/enhancement/index.js.map +1 -1
- package/lib/module/index.js +41 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/separation/index.js +1 -1
- package/lib/module/separation/index.js.map +1 -1
- package/lib/module/stt/index.js +127 -60
- package/lib/module/stt/index.js.map +1 -1
- package/lib/module/stt/sttModelLanguages.js +512 -0
- package/lib/module/stt/sttModelLanguages.js.map +1 -0
- package/lib/module/stt/types.js +53 -1
- package/lib/module/stt/types.js.map +1 -1
- package/lib/module/tts/index.js +216 -289
- package/lib/module/tts/index.js.map +1 -1
- package/lib/module/tts/types.js +86 -1
- package/lib/module/tts/types.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils.js +86 -73
- package/lib/module/utils.js.map +1 -1
- package/lib/module/vad/index.js +1 -1
- package/lib/module/vad/index.js.map +1 -1
- package/lib/typescript/src/NativeSherpaOnnx.d.ts +192 -38
- package/lib/typescript/src/NativeSherpaOnnx.d.ts.map +1 -1
- package/lib/typescript/src/audio/index.d.ts +13 -0
- package/lib/typescript/src/audio/index.d.ts.map +1 -0
- package/lib/typescript/src/diarization/index.d.ts +3 -2
- package/lib/typescript/src/diarization/index.d.ts.map +1 -1
- package/lib/typescript/src/download/ModelDownloadManager.d.ts +108 -0
- package/lib/typescript/src/download/ModelDownloadManager.d.ts.map +1 -0
- package/lib/typescript/src/download/extractTarBz2.d.ts +14 -0
- package/lib/typescript/src/download/extractTarBz2.d.ts.map +1 -0
- package/lib/typescript/src/download/index.d.ts +7 -0
- package/lib/typescript/src/download/index.d.ts.map +1 -0
- package/lib/typescript/src/download/validation.d.ts +57 -0
- package/lib/typescript/src/download/validation.d.ts.map +1 -0
- package/lib/typescript/src/enhancement/index.d.ts +3 -2
- package/lib/typescript/src/enhancement/index.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +26 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/separation/index.d.ts +3 -2
- package/lib/typescript/src/separation/index.d.ts.map +1 -1
- package/lib/typescript/src/stt/index.d.ts +31 -43
- package/lib/typescript/src/stt/index.d.ts.map +1 -1
- package/lib/typescript/src/stt/sttModelLanguages.d.ts +52 -0
- package/lib/typescript/src/stt/sttModelLanguages.d.ts.map +1 -0
- package/lib/typescript/src/stt/types.d.ts +196 -9
- package/lib/typescript/src/stt/types.d.ts.map +1 -1
- package/lib/typescript/src/tts/index.d.ts +25 -211
- package/lib/typescript/src/tts/index.d.ts.map +1 -1
- package/lib/typescript/src/tts/types.d.ts +148 -25
- package/lib/typescript/src/tts/types.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +0 -32
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/utils.d.ts +28 -13
- package/lib/typescript/src/utils.d.ts.map +1 -1
- package/lib/typescript/src/vad/index.d.ts +3 -2
- package/lib/typescript/src/vad/index.d.ts.map +1 -1
- package/package.json +250 -222
- package/scripts/check-qnn-support.sh +78 -0
- package/scripts/setup-ios-framework.sh +379 -282
- package/src/NativeSherpaOnnx.ts +474 -251
- package/src/audio/index.ts +32 -0
- package/src/diarization/index.ts +4 -2
- package/src/download/ModelDownloadManager.ts +1325 -0
- package/src/download/extractTarBz2.ts +78 -0
- package/src/download/index.ts +43 -0
- package/src/download/validation.ts +279 -0
- package/src/enhancement/index.ts +4 -2
- package/src/index.tsx +78 -27
- package/src/separation/index.ts +4 -2
- package/src/stt/index.ts +249 -89
- package/src/stt/sttModelLanguages.ts +237 -0
- package/src/stt/types.ts +263 -9
- package/src/tts/index.ts +470 -458
- package/src/tts/types.ts +373 -218
- package/src/types.ts +0 -44
- package/src/utils.ts +145 -131
- package/src/vad/index.ts +4 -2
- package/third_party/ffmpeg_prebuilt/ANDROID_RELEASE_TAG +1 -0
- package/third_party/libarchive_prebuilt/ANDROID_RELEASE_TAG +1 -0
- package/third_party/libarchive_prebuilt/IOS_RELEASE_TAG +1 -0
- package/third_party/sherpa-onnx-prebuilt/ANDROID_RELEASE_TAG +1 -0
- package/third_party/sherpa-onnx-prebuilt/IOS_RELEASE_TAG +1 -0
- package/android/src/main/cpp/include/sherpa-onnx/c-api/c-api.h +0 -1918
- package/android/src/main/cpp/include/sherpa-onnx/c-api/cxx-api.h +0 -841
- package/android/src/main/cpp/jni/sherpa-onnx-model-detect.cpp +0 -541
- package/android/src/main/cpp/jni/sherpa-onnx-stt-jni.cpp +0 -336
- package/android/src/main/cpp/jni/sherpa-onnx-stt-wrapper.cpp +0 -222
- package/android/src/main/cpp/jni/sherpa-onnx-stt-wrapper.h +0 -68
- package/android/src/main/cpp/jni/sherpa-onnx-tts-jni.cpp +0 -823
- package/android/src/main/cpp/jni/sherpa-onnx-tts-wrapper.cpp +0 -387
- package/android/src/main/cpp/jni/sherpa-onnx-tts-wrapper.h +0 -147
- package/ios/Frameworks/sherpa_onnx.xcframework.zip +0 -0
- package/ios/include/sherpa-onnx/c-api/c-api.h +0 -1918
- package/ios/include/sherpa-onnx/c-api/cxx-api.h +0 -841
- package/ios/sherpa-onnx-model-detect.mm +0 -441
- package/ios/sherpa-onnx-stt-wrapper.h +0 -48
- package/ios/sherpa-onnx-stt-wrapper.mm +0 -201
- package/scripts/copy-headers.js +0 -184
- package/scripts/setup-assets.js +0 -323
|
@@ -10,15 +10,16 @@
|
|
|
10
10
|
* // Future usage:
|
|
11
11
|
* import { initializeEnhancement, enhanceAudio } from 'react-native-sherpa-onnx/enhancement';
|
|
12
12
|
*
|
|
13
|
-
* await initializeEnhancement({ modelPath: 'models/enhancement-model' });
|
|
13
|
+
* await initializeEnhancement({ modelPath: { type: 'auto', path: 'models/enhancement-model' } });
|
|
14
14
|
* const enhancedPath = await enhanceAudio('path/to/noisy-audio.wav');
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
|
+
import type { ModelPathConfig } from '../types';
|
|
17
18
|
/**
|
|
18
19
|
* Enhancement initialization options (placeholder)
|
|
19
20
|
*/
|
|
20
21
|
export interface EnhancementInitializeOptions {
|
|
21
|
-
modelPath:
|
|
22
|
+
modelPath: ModelPathConfig;
|
|
22
23
|
}
|
|
23
24
|
/**
|
|
24
25
|
* Enhancement result
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/enhancement/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/enhancement/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,SAAS,EAAE,eAAe,CAAC;CAE5B;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;CAEpB;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,4BAA4B,GACrC,OAAO,CAAC,IAAI,CAAC,CAIf;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAI1E;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAIjD"}
|
|
@@ -1,7 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
1
|
+
import type { AccelerationSupport } from './NativeSherpaOnnx';
|
|
2
|
+
export type { AccelerationSupport } from './NativeSherpaOnnx';
|
|
3
|
+
export type { ModelPathConfig } from './types';
|
|
4
|
+
export { assetModelPath, autoModelPath, fileModelPath, getAssetPackPath, getDefaultModelPath, getPlayAssetDeliveryModelsPath, listAssetModels, listModelsAtPath, resolveModelPath, } from './utils';
|
|
3
5
|
/**
|
|
4
6
|
* Test method to verify sherpa-onnx native library is loaded.
|
|
5
7
|
*/
|
|
6
8
|
export declare function testSherpaInit(): Promise<string>;
|
|
9
|
+
/**
|
|
10
|
+
* QNN support (Android). Optional modelBase64 for canInit (session test); if omitted, SDK uses embedded test model.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getQnnSupport(modelBase64?: string): Promise<AccelerationSupport>;
|
|
13
|
+
/**
|
|
14
|
+
* Return the list of available ONNX Runtime execution providers
|
|
15
|
+
* (e.g. "CPU", "NNAPI", "QNN", "XNNPACK").
|
|
16
|
+
* Requires the ORT Java bridge from the onnxruntime AAR.
|
|
17
|
+
*/
|
|
18
|
+
export declare function getAvailableProviders(): Promise<string[]>;
|
|
19
|
+
/**
|
|
20
|
+
* NNAPI support (Android). Optional modelBase64 for canInit (session test). On iOS returns all false.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getNnapiSupport(modelBase64?: string): Promise<AccelerationSupport>;
|
|
23
|
+
/**
|
|
24
|
+
* XNNPACK support. hasAccelerator = true when providerCompiled (CPU-optimized). Optional modelBase64 for canInit. On iOS returns all false.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getXnnpackSupport(modelBase64?: string): Promise<AccelerationSupport>;
|
|
27
|
+
/**
|
|
28
|
+
* Core ML support (iOS). providerCompiled = true (Core ML on iOS 11+), hasAccelerator = Apple Neural Engine. Optional modelBase64 for canInit. On Android returns all false.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getCoreMlSupport(modelBase64?: string): Promise<AccelerationSupport>;
|
|
7
31
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"
|
|
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;AAWjB;;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;;;;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"}
|
|
@@ -10,15 +10,16 @@
|
|
|
10
10
|
* // Future usage:
|
|
11
11
|
* import { initializeSeparation, separateSources } from 'react-native-sherpa-onnx/separation';
|
|
12
12
|
*
|
|
13
|
-
* await initializeSeparation({ modelPath: 'models/separation-model' });
|
|
13
|
+
* await initializeSeparation({ modelPath: { type: 'auto', path: 'models/separation-model' } });
|
|
14
14
|
* const sources = await separateSources('path/to/mixed-audio.wav');
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
|
+
import type { ModelPathConfig } from '../types';
|
|
17
18
|
/**
|
|
18
19
|
* Separation initialization options (placeholder)
|
|
19
20
|
*/
|
|
20
21
|
export interface SeparationInitializeOptions {
|
|
21
|
-
modelPath:
|
|
22
|
+
modelPath: ModelPathConfig;
|
|
22
23
|
}
|
|
23
24
|
/**
|
|
24
25
|
* Separated audio source
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/separation/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/separation/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,SAAS,EAAE,eAAe,CAAC;CAE5B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CAEpB;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,2BAA2B,GACpC,OAAO,CAAC,IAAI,CAAC,CAIf;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAI7E;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAIhD"}
|
|
@@ -1,62 +1,50 @@
|
|
|
1
|
-
import type { STTInitializeOptions } from './types';
|
|
2
|
-
import type {
|
|
1
|
+
import type { STTInitializeOptions, STTModelType, SttEngine } from './types';
|
|
2
|
+
import type { ModelPathConfig } from '../types';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Detect STT model type and structure without initializing the recognizer.
|
|
5
|
+
* Uses the same native file-based detection as createSTT. Stateless; no instance required.
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
* -
|
|
8
|
-
*
|
|
9
|
-
* - Auto-detection (tries asset first, then file system)
|
|
10
|
-
*
|
|
11
|
-
* @param options - STT initialization options or model path configuration
|
|
12
|
-
* @returns Object with success status and array of detected models (each with type and modelDir)
|
|
7
|
+
* @param modelPath - Model path configuration (asset, file, or auto)
|
|
8
|
+
* @param options - Optional preferInt8 and modelType (default: auto)
|
|
9
|
+
* @returns Object with success, detectedModels (array of { type, modelDir }), and modelType (primary detected type)
|
|
13
10
|
* @example
|
|
14
11
|
* ```typescript
|
|
15
|
-
*
|
|
16
|
-
* const result = await
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* // Asset model
|
|
21
|
-
* const result = await initializeSTT({
|
|
22
|
-
* modelPath: { type: 'asset', path: 'models/sherpa-onnx-model' }
|
|
23
|
-
* });
|
|
24
|
-
*
|
|
25
|
-
* // File system model with preferInt8 option
|
|
26
|
-
* const result = await initializeSTT({
|
|
27
|
-
* modelPath: { type: 'file', path: '/path/to/model' },
|
|
28
|
-
* preferInt8: true // Prefer quantized int8 models (smaller, faster)
|
|
29
|
-
* });
|
|
30
|
-
*
|
|
31
|
-
* // With explicit model type
|
|
32
|
-
* const result = await initializeSTT({
|
|
33
|
-
* modelPath: { type: 'asset', path: 'models/sherpa-onnx-nemo-parakeet-tdt-ctc-en' },
|
|
34
|
-
* modelType: 'nemo_ctc'
|
|
35
|
-
* });
|
|
12
|
+
* const path = { type: 'asset' as const, path: 'models/sherpa-onnx-whisper-tiny-en' };
|
|
13
|
+
* const result = await detectSttModel(path);
|
|
14
|
+
* if (result.success && result.detectedModels.length > 0) {
|
|
15
|
+
* console.log('Detected type:', result.modelType, result.detectedModels);
|
|
16
|
+
* }
|
|
36
17
|
* ```
|
|
37
18
|
*/
|
|
38
|
-
export declare function
|
|
19
|
+
export declare function detectSttModel(modelPath: ModelPathConfig, options?: {
|
|
20
|
+
preferInt8?: boolean;
|
|
21
|
+
modelType?: STTModelType;
|
|
22
|
+
}): Promise<{
|
|
39
23
|
success: boolean;
|
|
40
24
|
detectedModels: Array<{
|
|
41
25
|
type: string;
|
|
42
26
|
modelDir: string;
|
|
43
27
|
}>;
|
|
28
|
+
modelType?: string;
|
|
44
29
|
}>;
|
|
45
30
|
/**
|
|
46
|
-
*
|
|
31
|
+
* Create an STT engine instance. Call destroy() on the returned engine when done to free native resources.
|
|
47
32
|
*
|
|
48
|
-
* @param
|
|
49
|
-
* @returns Promise resolving to
|
|
33
|
+
* @param options - STT initialization options or model path configuration
|
|
34
|
+
* @returns Promise resolving to an SttEngine instance
|
|
50
35
|
* @example
|
|
51
36
|
* ```typescript
|
|
52
|
-
* const
|
|
53
|
-
*
|
|
37
|
+
* const stt = await createSTT({
|
|
38
|
+
* modelPath: { type: 'asset', path: 'models/whisper-tiny' },
|
|
39
|
+
* });
|
|
40
|
+
* const result = await stt.transcribeFile('/path/to/audio.wav');
|
|
41
|
+
* console.log(result.text);
|
|
42
|
+
* await stt.destroy();
|
|
54
43
|
* ```
|
|
55
44
|
*/
|
|
56
|
-
export declare function
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
export
|
|
61
|
-
export type { STTInitializeOptions, TranscriptionResult } from './types';
|
|
45
|
+
export declare function createSTT(options: STTInitializeOptions | ModelPathConfig): Promise<SttEngine>;
|
|
46
|
+
export type { STTInitializeOptions, STTModelType, SttModelOptions, SttRecognitionResult, SttRuntimeConfig, SttEngine, SttInitResult, } from './types';
|
|
47
|
+
export { STT_MODEL_TYPES, STT_HOTWORDS_MODEL_TYPES, sttSupportsHotwords, } from './types';
|
|
48
|
+
export { getWhisperLanguages, WHISPER_LANGUAGES, getSenseVoiceLanguages, SENSEVOICE_LANGUAGES, getCanaryLanguages, CANARY_LANGUAGES, getFunasrNanoLanguages, FUNASR_NANO_LANGUAGES, getFunasrMltNanoLanguages, FUNASR_MLT_NANO_LANGUAGES, } from './sttModelLanguages';
|
|
49
|
+
export type { SttModelLanguage, WhisperLanguage } from './sttModelLanguages';
|
|
62
50
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/stt/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/stt/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,oBAAoB,EACpB,YAAY,EACZ,SAAS,EAIV,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AA2BhD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,cAAc,CAClC,SAAS,EAAE,eAAe,EAC1B,OAAO,CAAC,EAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,YAAY,CAAA;CAAE,GAC3D,OAAO,CAAC;IACT,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC,CAOD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,SAAS,CAC7B,OAAO,EAAE,oBAAoB,GAAG,eAAe,GAC9C,OAAO,CAAC,SAAS,CAAC,CAsIpB;AAGD,YAAY,EACV,oBAAoB,EACpB,YAAY,EACZ,eAAe,EACf,oBAAoB,EACpB,gBAAgB,EAChB,SAAS,EACT,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* STT model language codes and display names.
|
|
3
|
+
* Per-model lists for Whisper, SenseVoice, and others. Use these for language-hint
|
|
4
|
+
* dropdowns so users only pick valid codes (invalid codes can crash the app, e.g. Whisper).
|
|
5
|
+
*/
|
|
6
|
+
export interface SttModelLanguage {
|
|
7
|
+
/**
|
|
8
|
+
* Value to pass as language (e.g. "en" for Whisper, "中文" for FunASR Nano).
|
|
9
|
+
* Use as modelOptions.<model>.language (or srcLang/tgtLang where applicable).
|
|
10
|
+
*/
|
|
11
|
+
id: string;
|
|
12
|
+
/** Display name in English (e.g. "english", "chinese"). */
|
|
13
|
+
name: string;
|
|
14
|
+
}
|
|
15
|
+
/** @deprecated Use SttModelLanguage. Kept for backward compatibility. */
|
|
16
|
+
export type WhisperLanguage = SttModelLanguage;
|
|
17
|
+
/** Ordered list of all Whisper-supported language codes and names. */
|
|
18
|
+
export declare const WHISPER_LANGUAGES: readonly SttModelLanguage[];
|
|
19
|
+
/**
|
|
20
|
+
* Returns the list of Whisper-supported language codes and display names.
|
|
21
|
+
* Use for building a language-hint dropdown so users only pick valid codes (invalid codes can crash the app).
|
|
22
|
+
*/
|
|
23
|
+
export declare function getWhisperLanguages(): readonly SttModelLanguage[];
|
|
24
|
+
/** Ordered list of SenseVoice-supported language codes and names. */
|
|
25
|
+
export declare const SENSEVOICE_LANGUAGES: readonly SttModelLanguage[];
|
|
26
|
+
/**
|
|
27
|
+
* Returns the list of SenseVoice-supported language codes and display names.
|
|
28
|
+
* Use for modelOptions.senseVoice.language so users only pick valid codes.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getSenseVoiceLanguages(): readonly SttModelLanguage[];
|
|
31
|
+
/** Canary: en, es, de, fr. */
|
|
32
|
+
export declare const CANARY_LANGUAGES: readonly SttModelLanguage[];
|
|
33
|
+
/**
|
|
34
|
+
* Returns the list of Canary-supported language codes and display names.
|
|
35
|
+
* Use for modelOptions.canary.srcLang and modelOptions.canary.tgtLang.
|
|
36
|
+
*/
|
|
37
|
+
export declare function getCanaryLanguages(): readonly SttModelLanguage[];
|
|
38
|
+
/** Fun-ASR-Nano-2512: Chinese, English, Japanese. */
|
|
39
|
+
export declare const FUNASR_NANO_LANGUAGES: readonly SttModelLanguage[];
|
|
40
|
+
/** Fun-ASR-MLT-Nano-2512: multilingual list. */
|
|
41
|
+
export declare const FUNASR_MLT_NANO_LANGUAGES: readonly SttModelLanguage[];
|
|
42
|
+
/**
|
|
43
|
+
* Returns languages for Fun-ASR-Nano-2512 (中文, 英文, 日文).
|
|
44
|
+
* Id is the value for modelOptions.funasrNano.language (e.g. "中文").
|
|
45
|
+
*/
|
|
46
|
+
export declare function getFunasrNanoLanguages(): readonly SttModelLanguage[];
|
|
47
|
+
/**
|
|
48
|
+
* Returns languages for Fun-ASR-MLT-Nano-2512 (multilingual).
|
|
49
|
+
* Id is the value for modelOptions.funasrNano.language (e.g. "中文").
|
|
50
|
+
*/
|
|
51
|
+
export declare function getFunasrMltNanoLanguages(): readonly SttModelLanguage[];
|
|
52
|
+
//# sourceMappingURL=sttModelLanguages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sttModelLanguages.d.ts","sourceRoot":"","sources":["../../../../src/stt/sttModelLanguages.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,EAAE,EAAE,MAAM,CAAC;IACX,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAC;CACd;AAED,yEAAyE;AACzE,MAAM,MAAM,eAAe,GAAG,gBAAgB,CAAC;AAK/C,sEAAsE;AACtE,eAAO,MAAM,iBAAiB,EAAE,SAAS,gBAAgB,EAqG/C,CAAC;AAEX;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,SAAS,gBAAgB,EAAE,CAEjE;AAKD,qEAAqE;AACrE,eAAO,MAAM,oBAAoB,EAAE,SAAS,gBAAgB,EAOlD,CAAC;AAEX;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,SAAS,gBAAgB,EAAE,CAEpE;AAOD,8BAA8B;AAC9B,eAAO,MAAM,gBAAgB,EAAE,SAAS,gBAAgB,EAK9C,CAAC;AAEX;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,SAAS,gBAAgB,EAAE,CAEhE;AAMD,qDAAqD;AACrD,eAAO,MAAM,qBAAqB,EAAE,SAAS,gBAAgB,EAInD,CAAC;AAEX,gDAAgD;AAChD,eAAO,MAAM,yBAAyB,EAAE,SAAS,gBAAgB,EAgCvD,CAAC;AAEX;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,SAAS,gBAAgB,EAAE,CAEpE;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,IAAI,SAAS,gBAAgB,EAAE,CAEvE"}
|
|
@@ -1,4 +1,88 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ModelPathConfig } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Supported STT model types.
|
|
4
|
+
* Must match ParseSttModelType() in android/.../sherpa-onnx-model-detect-stt.cpp.
|
|
5
|
+
*/
|
|
6
|
+
export type STTModelType = 'transducer' | 'nemo_transducer' | 'paraformer' | 'nemo_ctc' | 'wenet_ctc' | 'sense_voice' | 'zipformer_ctc' | 'ctc' | 'whisper' | 'funasr_nano' | 'fire_red_asr' | 'moonshine' | 'dolphin' | 'canary' | 'omnilingual' | 'medasr' | 'telespeech_ctc' | 'auto';
|
|
7
|
+
/** Model types that support hotwords (contextual biasing). Transducer and NeMo transducer support hotwords in sherpa-onnx (NeMo: see k2-fsa/sherpa-onnx#3077). */
|
|
8
|
+
export declare const STT_HOTWORDS_MODEL_TYPES: readonly STTModelType[];
|
|
9
|
+
/**
|
|
10
|
+
* Returns true only for model types that support hotwords (transducer, nemo_transducer).
|
|
11
|
+
* Use this to show/hide hotword options in the UI or to validate before init/setSttConfig.
|
|
12
|
+
*/
|
|
13
|
+
export declare function sttSupportsHotwords(modelType: STTModelType | string): boolean;
|
|
14
|
+
/** Runtime list of supported STT model types (must match ParseSttModelType in native). */
|
|
15
|
+
export declare const STT_MODEL_TYPES: readonly STTModelType[];
|
|
16
|
+
/** Result of initializeSTT(). decodingMethod is set when init succeeds (e.g. "greedy_search" or "modified_beam_search"; auto-set when hotwords are used). */
|
|
17
|
+
export interface SttInitResult {
|
|
18
|
+
success: boolean;
|
|
19
|
+
detectedModels: Array<{
|
|
20
|
+
type: string;
|
|
21
|
+
modelDir: string;
|
|
22
|
+
}>;
|
|
23
|
+
modelType?: string;
|
|
24
|
+
decodingMethod?: string;
|
|
25
|
+
}
|
|
26
|
+
/** Options for Whisper models. Applied only when modelType is 'whisper'. */
|
|
27
|
+
export interface SttWhisperModelOptions {
|
|
28
|
+
/** Language code (e.g. "en", "de"). Used with multilingual models. Default: "en". */
|
|
29
|
+
language?: string;
|
|
30
|
+
/** "transcribe" or "translate". Default: "transcribe". With "translate", result text is English. */
|
|
31
|
+
task?: 'transcribe' | 'translate';
|
|
32
|
+
/** Padding at end of samples. Kotlin default 1000; C++ default -1. */
|
|
33
|
+
tailPaddings?: number;
|
|
34
|
+
/** Token-level timestamps. Android only; ignored on iOS. */
|
|
35
|
+
enableTokenTimestamps?: boolean;
|
|
36
|
+
/** Segment-level timestamps. Android only; ignored on iOS. */
|
|
37
|
+
enableSegmentTimestamps?: boolean;
|
|
38
|
+
}
|
|
39
|
+
/** Options for SenseVoice models. Applied only when modelType is 'sense_voice'. */
|
|
40
|
+
export interface SttSenseVoiceModelOptions {
|
|
41
|
+
/** Language hint. */
|
|
42
|
+
language?: string;
|
|
43
|
+
/** Inverse text normalization. Default: true (Kotlin), false (C++). */
|
|
44
|
+
useItn?: boolean;
|
|
45
|
+
}
|
|
46
|
+
/** Options for Canary models. Applied only when modelType is 'canary'. */
|
|
47
|
+
export interface SttCanaryModelOptions {
|
|
48
|
+
/** Source language code. Default: "en". */
|
|
49
|
+
srcLang?: string;
|
|
50
|
+
/** Target language code. Default: "en". */
|
|
51
|
+
tgtLang?: string;
|
|
52
|
+
/** Use punctuation. Default: true. */
|
|
53
|
+
usePnc?: boolean;
|
|
54
|
+
}
|
|
55
|
+
/** Options for FunASR Nano models. Applied only when modelType is 'funasr_nano'. */
|
|
56
|
+
export interface SttFunAsrNanoModelOptions {
|
|
57
|
+
/** System prompt. Default: "You are a helpful assistant." */
|
|
58
|
+
systemPrompt?: string;
|
|
59
|
+
/** User prompt prefix. Default: "语音转写:" */
|
|
60
|
+
userPrompt?: string;
|
|
61
|
+
/** Max new tokens. Default: 512. */
|
|
62
|
+
maxNewTokens?: number;
|
|
63
|
+
/** Temperature. Default: 1e-6. */
|
|
64
|
+
temperature?: number;
|
|
65
|
+
/** Top-p. Default: 0.8. */
|
|
66
|
+
topP?: number;
|
|
67
|
+
/** Random seed. Default: 42. */
|
|
68
|
+
seed?: number;
|
|
69
|
+
/** Language hint. */
|
|
70
|
+
language?: string;
|
|
71
|
+
/** Inverse text normalization. Default: true. */
|
|
72
|
+
itn?: boolean;
|
|
73
|
+
/** Hotwords string. */
|
|
74
|
+
hotwords?: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Model-specific STT options. Only the block for the actually loaded model type is applied;
|
|
78
|
+
* others are ignored (e.g. whisper options have no effect when a paraformer model is loaded).
|
|
79
|
+
*/
|
|
80
|
+
export interface SttModelOptions {
|
|
81
|
+
whisper?: SttWhisperModelOptions;
|
|
82
|
+
senseVoice?: SttSenseVoiceModelOptions;
|
|
83
|
+
canary?: SttCanaryModelOptions;
|
|
84
|
+
funasrNano?: SttFunAsrNanoModelOptions;
|
|
85
|
+
}
|
|
2
86
|
/**
|
|
3
87
|
* STT-specific initialization options
|
|
4
88
|
*/
|
|
@@ -6,7 +90,7 @@ export interface STTInitializeOptions {
|
|
|
6
90
|
/**
|
|
7
91
|
* Model directory path configuration
|
|
8
92
|
*/
|
|
9
|
-
modelPath:
|
|
93
|
+
modelPath: ModelPathConfig;
|
|
10
94
|
/**
|
|
11
95
|
* Model quantization preference
|
|
12
96
|
* - true: Prefer int8 quantized models (model.int8.onnx) - smaller, faster
|
|
@@ -16,24 +100,127 @@ export interface STTInitializeOptions {
|
|
|
16
100
|
preferInt8?: boolean;
|
|
17
101
|
/**
|
|
18
102
|
* Explicit model type specification for STT models
|
|
19
|
-
* - 'transducer': Force detection as
|
|
103
|
+
* - 'transducer': Force detection as Transducer model
|
|
104
|
+
* - 'zipformer_ctc' | 'ctc': Force detection as Zipformer CTC model
|
|
20
105
|
* - 'paraformer': Force detection as Paraformer model
|
|
21
106
|
* - 'nemo_ctc': Force detection as NeMo CTC model
|
|
22
107
|
* - 'whisper': Force detection as Whisper model
|
|
23
108
|
* - 'wenet_ctc': Force detection as WeNet CTC model
|
|
24
109
|
* - 'sense_voice': Force detection as SenseVoice model
|
|
25
110
|
* - 'funasr_nano': Force detection as FunASR Nano model
|
|
111
|
+
* - 'fire_red_asr': FireRed ASR (encoder/decoder)
|
|
112
|
+
* - 'moonshine': Moonshine (preprocess, encode, uncached_decode, cached_decode)
|
|
113
|
+
* - 'dolphin': Dolphin (single model)
|
|
114
|
+
* - 'canary': Canary (encoder/decoder)
|
|
115
|
+
* - 'omnilingual': Omnilingual CTC (single model)
|
|
116
|
+
* - 'medasr': MedASR CTC (single model)
|
|
117
|
+
* - 'telespeech_ctc': TeleSpeech CTC (single model)
|
|
26
118
|
* - 'auto': Automatic detection based on files (default)
|
|
27
119
|
*/
|
|
28
|
-
modelType?:
|
|
120
|
+
modelType?: STTModelType;
|
|
121
|
+
/**
|
|
122
|
+
* Enable debug logging in native layer and sherpa-onnx (config.model_config.debug).
|
|
123
|
+
* When true, wrapper and JNI emit verbose logs (config dumps, file checks, init/transcribe flow).
|
|
124
|
+
* Default: false.
|
|
125
|
+
*/
|
|
126
|
+
debug?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Path to hotwords file for keyword boosting (Kotlin OfflineRecognizerConfig.hotwordsFile).
|
|
129
|
+
*/
|
|
130
|
+
hotwordsFile?: string;
|
|
131
|
+
/**
|
|
132
|
+
* Hotwords score/weight (Kotlin OfflineRecognizerConfig.hotwordsScore).
|
|
133
|
+
* Default in Kotlin: 1.5.
|
|
134
|
+
*/
|
|
135
|
+
hotwordsScore?: number;
|
|
136
|
+
/**
|
|
137
|
+
* Modeling unit for hotwords tokenization (Kotlin OfflineModelConfig.modelingUnit).
|
|
138
|
+
* Only used when hotwords are set and model is transducer/nemo_transducer.
|
|
139
|
+
* Must match how the model was trained: 'bpe' (e.g. English zipformer), 'cjkchar' (e.g. Chinese conformer), 'cjkchar+bpe' (bilingual zh-en).
|
|
140
|
+
* See docs/stt.md "When to use which modelingUnit" and sherpa-onnx hotwords docs.
|
|
141
|
+
*/
|
|
142
|
+
modelingUnit?: 'cjkchar' | 'bpe' | 'cjkchar+bpe';
|
|
143
|
+
/**
|
|
144
|
+
* Path to BPE vocabulary file for hotwords (Kotlin OfflineModelConfig.bpeVocab).
|
|
145
|
+
* Required when modelingUnit is 'bpe' or 'cjkchar+bpe'. Sentencepiece .vocab export (bpe.vocab), not the hotwords file.
|
|
146
|
+
*/
|
|
147
|
+
bpeVocab?: string;
|
|
148
|
+
/**
|
|
149
|
+
* Number of threads for inference (Kotlin OfflineModelConfig.numThreads).
|
|
150
|
+
* Default in Kotlin: 1.
|
|
151
|
+
*/
|
|
152
|
+
numThreads?: number;
|
|
153
|
+
/**
|
|
154
|
+
* Provider string (e.g. "cpu"). Stored in config only; no special logic on change.
|
|
155
|
+
* Kotlin OfflineModelConfig.provider.
|
|
156
|
+
*/
|
|
157
|
+
provider?: string;
|
|
158
|
+
/**
|
|
159
|
+
* Path to rule FSTs (Kotlin OfflineRecognizerConfig.ruleFsts).
|
|
160
|
+
*/
|
|
161
|
+
ruleFsts?: string;
|
|
162
|
+
/**
|
|
163
|
+
* Path to rule FARs (Kotlin OfflineRecognizerConfig.ruleFars).
|
|
164
|
+
*/
|
|
165
|
+
ruleFars?: string;
|
|
166
|
+
/**
|
|
167
|
+
* Dither for feature extraction (Kotlin FeatureConfig.dither). Default 0.
|
|
168
|
+
*/
|
|
169
|
+
dither?: number;
|
|
170
|
+
/**
|
|
171
|
+
* Model-specific options. Only options for the loaded model type are applied.
|
|
172
|
+
* E.g. when modelType is 'whisper', only modelOptions.whisper is used.
|
|
173
|
+
*/
|
|
174
|
+
modelOptions?: SttModelOptions;
|
|
29
175
|
}
|
|
30
176
|
/**
|
|
31
|
-
*
|
|
177
|
+
* Full recognition result from offline STT (maps to Kotlin OfflineRecognizerResult).
|
|
32
178
|
*/
|
|
33
|
-
export interface
|
|
34
|
-
/**
|
|
35
|
-
* Transcribed text
|
|
36
|
-
*/
|
|
179
|
+
export interface SttRecognitionResult {
|
|
180
|
+
/** Transcribed text. */
|
|
37
181
|
text: string;
|
|
182
|
+
/** Token strings. */
|
|
183
|
+
tokens: string[];
|
|
184
|
+
/** Timestamps per token (model-dependent). */
|
|
185
|
+
timestamps: number[];
|
|
186
|
+
/** Detected or specified language (model-dependent). */
|
|
187
|
+
lang: string;
|
|
188
|
+
/** Emotion label (model-dependent, e.g. SenseVoice). */
|
|
189
|
+
emotion: string;
|
|
190
|
+
/** Event label (model-dependent). */
|
|
191
|
+
event: string;
|
|
192
|
+
/** Durations (valid for TDT models). */
|
|
193
|
+
durations: number[];
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Instance-based STT engine returned by createSTT().
|
|
197
|
+
* Call destroy() when done to free native resources.
|
|
198
|
+
*/
|
|
199
|
+
export interface SttEngine {
|
|
200
|
+
readonly instanceId: string;
|
|
201
|
+
transcribeFile(filePath: string): Promise<SttRecognitionResult>;
|
|
202
|
+
transcribeSamples(samples: number[], sampleRate: number): Promise<SttRecognitionResult>;
|
|
203
|
+
setConfig(options: SttRuntimeConfig): Promise<void>;
|
|
204
|
+
destroy(): Promise<void>;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Runtime config for the offline recognizer (Kotlin OfflineRecognizerConfig).
|
|
208
|
+
* Only fields that can be updated via setConfig are included.
|
|
209
|
+
*/
|
|
210
|
+
export interface SttRuntimeConfig {
|
|
211
|
+
/** Decoding method (e.g. greedy_search). */
|
|
212
|
+
decodingMethod?: string;
|
|
213
|
+
/** Max active paths (beam search). */
|
|
214
|
+
maxActivePaths?: number;
|
|
215
|
+
/** Path to hotwords file. */
|
|
216
|
+
hotwordsFile?: string;
|
|
217
|
+
/** Hotwords score. */
|
|
218
|
+
hotwordsScore?: number;
|
|
219
|
+
/** Blank penalty. */
|
|
220
|
+
blankPenalty?: number;
|
|
221
|
+
/** Path to rule FSTs. */
|
|
222
|
+
ruleFsts?: string;
|
|
223
|
+
/** Path to rule FARs. */
|
|
224
|
+
ruleFars?: string;
|
|
38
225
|
}
|
|
39
226
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/stt/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/stt/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD;;;GAGG;AACH,MAAM,MAAM,YAAY,GACpB,YAAY,GACZ,iBAAiB,GACjB,YAAY,GACZ,UAAU,GACV,WAAW,GACX,aAAa,GACb,eAAe,GACf,KAAK,GACL,SAAS,GACT,aAAa,GACb,cAAc,GACd,WAAW,GACX,SAAS,GACT,QAAQ,GACR,aAAa,GACb,QAAQ,GACR,gBAAgB,GAChB,MAAM,CAAC;AAEX,kKAAkK;AAClK,eAAO,MAAM,wBAAwB,EAAE,SAAS,YAAY,EAGlD,CAAC;AAEX;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,YAAY,GAAG,MAAM,GAAG,OAAO,CAE7E;AAED,0FAA0F;AAC1F,eAAO,MAAM,eAAe,EAAE,SAAS,YAAY,EAmBzC,CAAC;AAEX,6JAA6J;AAC7J,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAID,4EAA4E;AAC5E,MAAM,WAAW,sBAAsB;IACrC,qFAAqF;IACrF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oGAAoG;IACpG,IAAI,CAAC,E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