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.
Files changed (175) hide show
  1. package/README.md +232 -236
  2. package/SherpaOnnx.podspec +68 -64
  3. package/android/build.gradle +182 -192
  4. package/android/codegen.gradle +57 -0
  5. package/android/prebuilt-download.gradle +428 -0
  6. package/android/prebuilt-versions.gradle +43 -0
  7. package/android/proguard-rules.pro +10 -0
  8. package/android/src/main/assets/testModels/add_mul_add.onnx +28 -0
  9. package/android/src/main/assets/testModels/nnapi_internal_uint8_support.onnx +0 -0
  10. package/android/src/main/assets/testModels/qnn_multi_ctx_embed.onnx +0 -0
  11. package/android/src/main/cpp/CMakeLists.txt +166 -129
  12. package/android/src/main/cpp/CMakePresets.json +54 -0
  13. package/android/src/main/cpp/crypto/sha256.cpp +174 -0
  14. package/android/src/main/cpp/crypto/sha256.h +16 -0
  15. package/android/src/main/cpp/jni/archive/sherpa-onnx-archive-helper.cpp +404 -0
  16. package/android/src/main/cpp/jni/archive/sherpa-onnx-archive-helper.h +56 -0
  17. package/android/src/main/cpp/jni/archive/sherpa-onnx-archive-jni.cpp +181 -0
  18. package/android/src/main/cpp/jni/audio/sherpa-onnx-audio-convert-jni.cpp +888 -0
  19. package/{ios → android/src/main/cpp/jni/model_detect}/sherpa-onnx-common.h +18 -18
  20. package/android/src/main/cpp/jni/model_detect/sherpa-onnx-detect-jni-common.cpp +86 -0
  21. package/android/src/main/cpp/jni/model_detect/sherpa-onnx-detect-jni-common.h +20 -0
  22. package/android/src/main/cpp/jni/model_detect/sherpa-onnx-model-detect-helper.cpp +423 -0
  23. package/android/src/main/cpp/jni/model_detect/sherpa-onnx-model-detect-helper.h +55 -0
  24. package/android/src/main/cpp/jni/model_detect/sherpa-onnx-model-detect-stt.cpp +399 -0
  25. package/android/src/main/cpp/jni/model_detect/sherpa-onnx-model-detect-tts.cpp +238 -0
  26. package/{ios → android/src/main/cpp/jni/model_detect}/sherpa-onnx-model-detect.h +122 -89
  27. package/android/src/main/cpp/jni/model_detect/sherpa-onnx-stt-wrapper.cpp +99 -0
  28. package/android/src/main/cpp/jni/model_detect/sherpa-onnx-stt-wrapper.h +16 -0
  29. package/android/src/main/cpp/jni/model_detect/sherpa-onnx-tts-wrapper.cpp +78 -0
  30. package/android/src/main/cpp/jni/model_detect/sherpa-onnx-tts-wrapper.h +16 -0
  31. package/android/src/main/cpp/jni/module/sherpa-onnx-module-jni.cpp +190 -0
  32. package/android/src/main/cpp/jni/tts/sherpa-onnx-tts-zipvoice-jni.cpp +301 -0
  33. package/android/src/main/java/com/sherpaonnx/SherpaOnnxArchiveHelper.kt +94 -0
  34. package/android/src/main/java/com/sherpaonnx/{SherpaOnnxCoreHelper.kt → SherpaOnnxAssetHelper.kt} +350 -236
  35. package/android/src/main/java/com/sherpaonnx/SherpaOnnxModule.kt +791 -483
  36. package/android/src/main/java/com/sherpaonnx/SherpaOnnxSttHelper.kt +699 -109
  37. package/android/src/main/java/com/sherpaonnx/SherpaOnnxTtsHelper.kt +1123 -668
  38. package/android/src/main/java/com/sherpaonnx/ZipvoiceTtsWrapper.kt +187 -0
  39. package/ios/SherpaOnnx+Assets.h +11 -0
  40. package/ios/SherpaOnnx+Assets.mm +325 -0
  41. package/ios/SherpaOnnx+STT.mm +455 -118
  42. package/ios/SherpaOnnx+TTS.mm +1101 -712
  43. package/ios/SherpaOnnx.h +17 -6
  44. package/ios/SherpaOnnx.mm +206 -311
  45. package/ios/SherpaOnnx.xcconfig +19 -19
  46. package/ios/SherpaOnnxCoreMLHelper.swift +24 -0
  47. package/ios/archive/sherpa-onnx-archive-helper.h +21 -0
  48. package/ios/archive/sherpa-onnx-archive-helper.mm +296 -0
  49. package/ios/libarchive_darwin_config.h +153 -0
  50. package/{android/src/main/cpp/jni → ios/model_detect}/sherpa-onnx-common.h +18 -18
  51. package/ios/model_detect/sherpa-onnx-model-detect-helper.h +49 -0
  52. package/ios/model_detect/sherpa-onnx-model-detect-helper.mm +210 -0
  53. package/ios/model_detect/sherpa-onnx-model-detect-stt.mm +344 -0
  54. package/ios/model_detect/sherpa-onnx-model-detect-tts.mm +201 -0
  55. package/{android/src/main/cpp/jni → ios/model_detect}/sherpa-onnx-model-detect.h +117 -89
  56. package/ios/scripts/patch-libarchive-includes.sh +61 -0
  57. package/ios/scripts/setup-ios-libarchive.sh +98 -0
  58. package/ios/stt/sherpa-onnx-stt-wrapper.h +129 -0
  59. package/ios/stt/sherpa-onnx-stt-wrapper.mm +523 -0
  60. package/ios/{sherpa-onnx-tts-wrapper.h → tts/sherpa-onnx-tts-wrapper.h} +90 -85
  61. package/ios/{sherpa-onnx-tts-wrapper.mm → tts/sherpa-onnx-tts-wrapper.mm} +376 -345
  62. package/lib/module/NativeSherpaOnnx.js +3 -0
  63. package/lib/module/NativeSherpaOnnx.js.map +1 -1
  64. package/lib/module/audio/index.js +22 -0
  65. package/lib/module/audio/index.js.map +1 -0
  66. package/lib/module/diarization/index.js +1 -1
  67. package/lib/module/diarization/index.js.map +1 -1
  68. package/lib/module/download/ModelDownloadManager.js +918 -0
  69. package/lib/module/download/ModelDownloadManager.js.map +1 -0
  70. package/lib/module/download/extractTarBz2.js +53 -0
  71. package/lib/module/download/extractTarBz2.js.map +1 -0
  72. package/lib/module/download/index.js +6 -0
  73. package/lib/module/download/index.js.map +1 -0
  74. package/lib/module/download/validation.js +178 -0
  75. package/lib/module/download/validation.js.map +1 -0
  76. package/lib/module/enhancement/index.js +1 -1
  77. package/lib/module/enhancement/index.js.map +1 -1
  78. package/lib/module/index.js +41 -3
  79. package/lib/module/index.js.map +1 -1
  80. package/lib/module/separation/index.js +1 -1
  81. package/lib/module/separation/index.js.map +1 -1
  82. package/lib/module/stt/index.js +127 -60
  83. package/lib/module/stt/index.js.map +1 -1
  84. package/lib/module/stt/sttModelLanguages.js +512 -0
  85. package/lib/module/stt/sttModelLanguages.js.map +1 -0
  86. package/lib/module/stt/types.js +53 -1
  87. package/lib/module/stt/types.js.map +1 -1
  88. package/lib/module/tts/index.js +216 -289
  89. package/lib/module/tts/index.js.map +1 -1
  90. package/lib/module/tts/types.js +86 -1
  91. package/lib/module/tts/types.js.map +1 -1
  92. package/lib/module/types.js.map +1 -1
  93. package/lib/module/utils.js +86 -73
  94. package/lib/module/utils.js.map +1 -1
  95. package/lib/module/vad/index.js +1 -1
  96. package/lib/module/vad/index.js.map +1 -1
  97. package/lib/typescript/src/NativeSherpaOnnx.d.ts +192 -38
  98. package/lib/typescript/src/NativeSherpaOnnx.d.ts.map +1 -1
  99. package/lib/typescript/src/audio/index.d.ts +13 -0
  100. package/lib/typescript/src/audio/index.d.ts.map +1 -0
  101. package/lib/typescript/src/diarization/index.d.ts +3 -2
  102. package/lib/typescript/src/diarization/index.d.ts.map +1 -1
  103. package/lib/typescript/src/download/ModelDownloadManager.d.ts +108 -0
  104. package/lib/typescript/src/download/ModelDownloadManager.d.ts.map +1 -0
  105. package/lib/typescript/src/download/extractTarBz2.d.ts +14 -0
  106. package/lib/typescript/src/download/extractTarBz2.d.ts.map +1 -0
  107. package/lib/typescript/src/download/index.d.ts +7 -0
  108. package/lib/typescript/src/download/index.d.ts.map +1 -0
  109. package/lib/typescript/src/download/validation.d.ts +57 -0
  110. package/lib/typescript/src/download/validation.d.ts.map +1 -0
  111. package/lib/typescript/src/enhancement/index.d.ts +3 -2
  112. package/lib/typescript/src/enhancement/index.d.ts.map +1 -1
  113. package/lib/typescript/src/index.d.ts +26 -2
  114. package/lib/typescript/src/index.d.ts.map +1 -1
  115. package/lib/typescript/src/separation/index.d.ts +3 -2
  116. package/lib/typescript/src/separation/index.d.ts.map +1 -1
  117. package/lib/typescript/src/stt/index.d.ts +31 -43
  118. package/lib/typescript/src/stt/index.d.ts.map +1 -1
  119. package/lib/typescript/src/stt/sttModelLanguages.d.ts +52 -0
  120. package/lib/typescript/src/stt/sttModelLanguages.d.ts.map +1 -0
  121. package/lib/typescript/src/stt/types.d.ts +196 -9
  122. package/lib/typescript/src/stt/types.d.ts.map +1 -1
  123. package/lib/typescript/src/tts/index.d.ts +25 -211
  124. package/lib/typescript/src/tts/index.d.ts.map +1 -1
  125. package/lib/typescript/src/tts/types.d.ts +148 -25
  126. package/lib/typescript/src/tts/types.d.ts.map +1 -1
  127. package/lib/typescript/src/types.d.ts +0 -32
  128. package/lib/typescript/src/types.d.ts.map +1 -1
  129. package/lib/typescript/src/utils.d.ts +28 -13
  130. package/lib/typescript/src/utils.d.ts.map +1 -1
  131. package/lib/typescript/src/vad/index.d.ts +3 -2
  132. package/lib/typescript/src/vad/index.d.ts.map +1 -1
  133. package/package.json +250 -222
  134. package/scripts/check-qnn-support.sh +78 -0
  135. package/scripts/setup-ios-framework.sh +379 -282
  136. package/src/NativeSherpaOnnx.ts +474 -251
  137. package/src/audio/index.ts +32 -0
  138. package/src/diarization/index.ts +4 -2
  139. package/src/download/ModelDownloadManager.ts +1325 -0
  140. package/src/download/extractTarBz2.ts +78 -0
  141. package/src/download/index.ts +43 -0
  142. package/src/download/validation.ts +279 -0
  143. package/src/enhancement/index.ts +4 -2
  144. package/src/index.tsx +78 -27
  145. package/src/separation/index.ts +4 -2
  146. package/src/stt/index.ts +249 -89
  147. package/src/stt/sttModelLanguages.ts +237 -0
  148. package/src/stt/types.ts +263 -9
  149. package/src/tts/index.ts +470 -458
  150. package/src/tts/types.ts +373 -218
  151. package/src/types.ts +0 -44
  152. package/src/utils.ts +145 -131
  153. package/src/vad/index.ts +4 -2
  154. package/third_party/ffmpeg_prebuilt/ANDROID_RELEASE_TAG +1 -0
  155. package/third_party/libarchive_prebuilt/ANDROID_RELEASE_TAG +1 -0
  156. package/third_party/libarchive_prebuilt/IOS_RELEASE_TAG +1 -0
  157. package/third_party/sherpa-onnx-prebuilt/ANDROID_RELEASE_TAG +1 -0
  158. package/third_party/sherpa-onnx-prebuilt/IOS_RELEASE_TAG +1 -0
  159. package/android/src/main/cpp/include/sherpa-onnx/c-api/c-api.h +0 -1918
  160. package/android/src/main/cpp/include/sherpa-onnx/c-api/cxx-api.h +0 -841
  161. package/android/src/main/cpp/jni/sherpa-onnx-model-detect.cpp +0 -541
  162. package/android/src/main/cpp/jni/sherpa-onnx-stt-jni.cpp +0 -336
  163. package/android/src/main/cpp/jni/sherpa-onnx-stt-wrapper.cpp +0 -222
  164. package/android/src/main/cpp/jni/sherpa-onnx-stt-wrapper.h +0 -68
  165. package/android/src/main/cpp/jni/sherpa-onnx-tts-jni.cpp +0 -823
  166. package/android/src/main/cpp/jni/sherpa-onnx-tts-wrapper.cpp +0 -387
  167. package/android/src/main/cpp/jni/sherpa-onnx-tts-wrapper.h +0 -147
  168. package/ios/Frameworks/sherpa_onnx.xcframework.zip +0 -0
  169. package/ios/include/sherpa-onnx/c-api/c-api.h +0 -1918
  170. package/ios/include/sherpa-onnx/c-api/cxx-api.h +0 -841
  171. package/ios/sherpa-onnx-model-detect.mm +0 -441
  172. package/ios/sherpa-onnx-stt-wrapper.h +0 -48
  173. package/ios/sherpa-onnx-stt-wrapper.mm +0 -201
  174. package/scripts/copy-headers.js +0 -184
  175. package/scripts/setup-assets.js +0 -323
@@ -2,81 +2,148 @@
2
2
 
3
3
  import SherpaOnnx from "../NativeSherpaOnnx.js";
4
4
  import { resolveModelPath } from "../utils.js";
5
+ let sttInstanceCounter = 0;
6
+ function normalizeSttResult(raw) {
7
+ return {
8
+ text: typeof raw.text === 'string' ? raw.text : '',
9
+ tokens: Array.isArray(raw.tokens) ? raw.tokens : [],
10
+ timestamps: Array.isArray(raw.timestamps) ? raw.timestamps : [],
11
+ lang: typeof raw.lang === 'string' ? raw.lang : '',
12
+ emotion: typeof raw.emotion === 'string' ? raw.emotion : '',
13
+ event: typeof raw.event === 'string' ? raw.event : '',
14
+ durations: Array.isArray(raw.durations) ? raw.durations : []
15
+ };
16
+ }
17
+
18
+ /**
19
+ * Detect STT model type and structure without initializing the recognizer.
20
+ * Uses the same native file-based detection as createSTT. Stateless; no instance required.
21
+ *
22
+ * @param modelPath - Model path configuration (asset, file, or auto)
23
+ * @param options - Optional preferInt8 and modelType (default: auto)
24
+ * @returns Object with success, detectedModels (array of { type, modelDir }), and modelType (primary detected type)
25
+ * @example
26
+ * ```typescript
27
+ * const path = { type: 'asset' as const, path: 'models/sherpa-onnx-whisper-tiny-en' };
28
+ * const result = await detectSttModel(path);
29
+ * if (result.success && result.detectedModels.length > 0) {
30
+ * console.log('Detected type:', result.modelType, result.detectedModels);
31
+ * }
32
+ * ```
33
+ */
34
+ export async function detectSttModel(modelPath, options) {
35
+ const resolvedPath = await resolveModelPath(modelPath);
36
+ return SherpaOnnx.detectSttModel(resolvedPath, options?.preferInt8, options?.modelType);
37
+ }
5
38
 
6
- /**
7
- * Initialize Speech-to-Text (STT) with model directory.
8
- *
9
- * Supports multiple model source types:
10
- * - Asset models (bundled in app)
11
- * - File system models (downloaded or user-provided)
12
- * - Auto-detection (tries asset first, then file system)
13
- *
14
- * @param options - STT initialization options or model path configuration
15
- * @returns Object with success status and array of detected models (each with type and modelDir)
16
- * @example
17
- * ```typescript
18
- * // Simple string (auto-detect)
19
- * const result = await initializeSTT('models/sherpa-onnx-model');
20
- * console.log('Detected models:', result.detectedModels);
21
- * // result.detectedModels = [{ type: 'transducer', modelDir: '/path/to/model' }]
22
- *
23
- * // Asset model
24
- * const result = await initializeSTT({
25
- * modelPath: { type: 'asset', path: 'models/sherpa-onnx-model' }
26
- * });
27
- *
28
- * // File system model with preferInt8 option
29
- * const result = await initializeSTT({
30
- * modelPath: { type: 'file', path: '/path/to/model' },
31
- * preferInt8: true // Prefer quantized int8 models (smaller, faster)
32
- * });
33
- *
34
- * // With explicit model type
35
- * const result = await initializeSTT({
36
- * modelPath: { type: 'asset', path: 'models/sherpa-onnx-nemo-parakeet-tdt-ctc-en' },
37
- * modelType: 'nemo_ctc'
38
- * });
39
- * ```
39
+ /**
40
+ * Create an STT engine instance. Call destroy() on the returned engine when done to free native resources.
41
+ *
42
+ * @param options - STT initialization options or model path configuration
43
+ * @returns Promise resolving to an SttEngine instance
44
+ * @example
45
+ * ```typescript
46
+ * const stt = await createSTT({
47
+ * modelPath: { type: 'asset', path: 'models/whisper-tiny' },
48
+ * });
49
+ * const result = await stt.transcribeFile('/path/to/audio.wav');
50
+ * console.log(result.text);
51
+ * await stt.destroy();
52
+ * ```
40
53
  */
41
- export async function initializeSTT(options) {
42
- // Handle both object syntax and direct path syntax
54
+ export async function createSTT(options) {
55
+ const instanceId = `stt_${++sttInstanceCounter}`;
43
56
  let modelPath;
44
57
  let preferInt8;
45
58
  let modelType;
46
- if (typeof options === 'object' && 'modelPath' in options) {
59
+ let hotwordsFile;
60
+ let hotwordsScore;
61
+ let numThreads;
62
+ let provider;
63
+ let ruleFsts;
64
+ let ruleFars;
65
+ let dither;
66
+ let modelOptions;
67
+ let modelingUnit;
68
+ let bpeVocab;
69
+ if ('modelPath' in options) {
47
70
  modelPath = options.modelPath;
48
71
  preferInt8 = options.preferInt8;
49
72
  modelType = options.modelType;
73
+ hotwordsFile = options.hotwordsFile;
74
+ hotwordsScore = options.hotwordsScore;
75
+ numThreads = options.numThreads;
76
+ provider = options.provider;
77
+ ruleFsts = options.ruleFsts;
78
+ ruleFars = options.ruleFars;
79
+ dither = options.dither;
80
+ modelOptions = options.modelOptions;
81
+ modelingUnit = options.modelingUnit;
82
+ bpeVocab = options.bpeVocab;
50
83
  } else {
51
84
  modelPath = options;
52
85
  preferInt8 = undefined;
53
86
  modelType = undefined;
87
+ hotwordsFile = undefined;
88
+ hotwordsScore = undefined;
89
+ numThreads = undefined;
90
+ provider = undefined;
91
+ ruleFsts = undefined;
92
+ ruleFars = undefined;
93
+ dither = undefined;
94
+ modelOptions = undefined;
95
+ modelingUnit = undefined;
96
+ bpeVocab = undefined;
54
97
  }
98
+ const debug = 'modelPath' in options ? options.debug : undefined;
55
99
  const resolvedPath = await resolveModelPath(modelPath);
56
- return SherpaOnnx.initializeSherpaOnnx(resolvedPath, preferInt8, modelType);
57
- }
58
-
59
- /**
60
- * Transcribe an audio file.
61
- *
62
- * @param filePath - Path to WAV file (16kHz, mono, 16-bit PCM)
63
- * @returns Promise resolving to transcribed text
64
- * @example
65
- * ```typescript
66
- * const transcription = await transcribeFile('path/to/audio.wav');
67
- * console.log('Transcription:', transcription);
68
- * ```
69
- */
70
- export function transcribeFile(filePath) {
71
- return SherpaOnnx.transcribeFile(filePath);
100
+ const result = await SherpaOnnx.initializeStt(instanceId, resolvedPath, preferInt8, modelType, debug, hotwordsFile, hotwordsScore, numThreads, provider, ruleFsts, ruleFars, dither, modelOptions, modelingUnit, bpeVocab);
101
+ if (!result.success) {
102
+ throw new Error(`STT initialization failed: ${JSON.stringify(result.detectedModels ?? [])}`);
103
+ }
104
+ let destroyed = false;
105
+ const guard = () => {
106
+ if (destroyed) {
107
+ throw new Error(`STT instance ${instanceId} has been destroyed; cannot call methods on it.`);
108
+ }
109
+ };
110
+ const engine = {
111
+ get instanceId() {
112
+ return instanceId;
113
+ },
114
+ async transcribeFile(filePath) {
115
+ guard();
116
+ const raw = await SherpaOnnx.transcribeFile(instanceId, filePath);
117
+ return normalizeSttResult(raw);
118
+ },
119
+ async transcribeSamples(samples, sampleRate) {
120
+ guard();
121
+ const raw = await SherpaOnnx.transcribeSamples(instanceId, samples, sampleRate);
122
+ return normalizeSttResult(raw);
123
+ },
124
+ async setConfig(config) {
125
+ guard();
126
+ const map = {};
127
+ if (config.decodingMethod != null) map.decodingMethod = config.decodingMethod;
128
+ if (config.maxActivePaths != null) map.maxActivePaths = config.maxActivePaths;
129
+ if (config.hotwordsFile != null) map.hotwordsFile = config.hotwordsFile;
130
+ if (config.hotwordsScore != null) map.hotwordsScore = config.hotwordsScore;
131
+ if (config.blankPenalty != null) map.blankPenalty = config.blankPenalty;
132
+ if (config.ruleFsts != null) map.ruleFsts = config.ruleFsts;
133
+ if (config.ruleFars != null) map.ruleFars = config.ruleFars;
134
+ return SherpaOnnx.setSttConfig(instanceId, map);
135
+ },
136
+ async destroy() {
137
+ if (destroyed) return;
138
+ destroyed = true;
139
+ await SherpaOnnx.unloadStt(instanceId);
140
+ }
141
+ };
142
+ return engine;
72
143
  }
73
144
 
74
- /**
75
- * Release STT resources.
76
- */
77
- export function unloadSTT() {
78
- return SherpaOnnx.unloadSherpaOnnx();
79
- }
145
+ // Export types and runtime type list
80
146
 
81
- // Export types
147
+ export { STT_MODEL_TYPES, STT_HOTWORDS_MODEL_TYPES, sttSupportsHotwords } from "./types.js";
148
+ export { getWhisperLanguages, WHISPER_LANGUAGES, getSenseVoiceLanguages, SENSEVOICE_LANGUAGES, getCanaryLanguages, CANARY_LANGUAGES, getFunasrNanoLanguages, FUNASR_NANO_LANGUAGES, getFunasrMltNanoLanguages, FUNASR_MLT_NANO_LANGUAGES } from "./sttModelLanguages.js";
82
149
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["SherpaOnnx","resolveModelPath","initializeSTT","options","modelPath","preferInt8","modelType","undefined","resolvedPath","initializeSherpaOnnx","transcribeFile","filePath","unloadSTT","unloadSherpaOnnx"],"sourceRoot":"..\\..\\..\\src","sources":["stt/index.ts"],"mappings":";;AAAA,OAAOA,UAAU,MAAM,wBAAqB;AAG5C,SAASC,gBAAgB,QAAQ,aAAU;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,aAAaA,CACjCC,OAA8D,EAI7D;EACD;EACA,IAAIC,SAAyC;EAC7C,IAAIC,UAA+B;EACnC,IAAIC,SAA6B;EAEjC,IAAI,OAAOH,OAAO,KAAK,QAAQ,IAAI,WAAW,IAAIA,OAAO,EAAE;IACzDC,SAAS,GAAGD,OAAO,CAACC,SAAS;IAC7BC,UAAU,GAAGF,OAAO,CAACE,UAAU;IAC/BC,SAAS,GAAGH,OAAO,CAACG,SAAS;EAC/B,CAAC,MAAM;IACLF,SAAS,GAAGD,OAAyC;IACrDE,UAAU,GAAGE,SAAS;IACtBD,SAAS,GAAGC,SAAS;EACvB;EAEA,MAAMC,YAAY,GAAG,MAAMP,gBAAgB,CAACG,SAAS,CAAC;EACtD,OAAOJ,UAAU,CAACS,oBAAoB,CAACD,YAAY,EAAEH,UAAU,EAAEC,SAAS,CAAC;AAC7E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,cAAcA,CAACC,QAAgB,EAAmB;EAChE,OAAOX,UAAU,CAACU,cAAc,CAACC,QAAQ,CAAC;AAC5C;;AAEA;AACA;AACA;AACA,OAAO,SAASC,SAASA,CAAA,EAAkB;EACzC,OAAOZ,UAAU,CAACa,gBAAgB,CAAC,CAAC;AACtC;;AAEA","ignoreList":[]}
1
+ {"version":3,"names":["SherpaOnnx","resolveModelPath","sttInstanceCounter","normalizeSttResult","raw","text","tokens","Array","isArray","timestamps","lang","emotion","event","durations","detectSttModel","modelPath","options","resolvedPath","preferInt8","modelType","createSTT","instanceId","hotwordsFile","hotwordsScore","numThreads","provider","ruleFsts","ruleFars","dither","modelOptions","modelingUnit","bpeVocab","undefined","debug","result","initializeStt","success","Error","JSON","stringify","detectedModels","destroyed","guard","engine","transcribeFile","filePath","transcribeSamples","samples","sampleRate","setConfig","config","map","decodingMethod","maxActivePaths","blankPenalty","setSttConfig","destroy","unloadStt","STT_MODEL_TYPES","STT_HOTWORDS_MODEL_TYPES","sttSupportsHotwords","getWhisperLanguages","WHISPER_LANGUAGES","getSenseVoiceLanguages","SENSEVOICE_LANGUAGES","getCanaryLanguages","CANARY_LANGUAGES","getFunasrNanoLanguages","FUNASR_NANO_LANGUAGES","getFunasrMltNanoLanguages","FUNASR_MLT_NANO_LANGUAGES"],"sourceRoot":"../../../src","sources":["stt/index.ts"],"mappings":";;AAAA,OAAOA,UAAU,MAAM,wBAAqB;AAU5C,SAASC,gBAAgB,Q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