react-native-sherpa-onnx 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/android/src/main/assets/model_licenses/alignment-models-license-status.csv +5 -0
- package/android/src/main/cpp/CMakeLists.txt +3 -0
- package/android/src/main/cpp/jni/model_detect/sherpa-onnx-alignment-wrapper.cpp +66 -0
- package/android/src/main/cpp/jni/model_detect/sherpa-onnx-alignment-wrapper.h +17 -0
- package/android/src/main/cpp/jni/model_detect/sherpa-onnx-model-detect-alignment.cpp +108 -0
- package/android/src/main/cpp/jni/model_detect/sherpa-onnx-model-detect.h +30 -0
- package/android/src/main/cpp/jni/model_detect/sherpa-onnx-validate-alignment.cpp +66 -0
- package/android/src/main/cpp/jni/model_detect/sherpa-onnx-validate-alignment.h +30 -0
- package/android/src/main/cpp/jni/module/sherpa-onnx-module-jni.cpp +21 -0
- package/android/src/main/java/com/sherpaonnx/SherpaOnnxAlignmentHelper.kt +555 -0
- package/android/src/main/java/com/sherpaonnx/SherpaOnnxModule.kt +76 -0
- package/android/src/main/java/com/sherpaonnx/SherpaOnnxTextSegmenter.kt +330 -0
- package/android/src/main/java/com/sherpaonnx/SherpaOnnxTtsHelper.kt +180 -23
- package/ios/Resources/model_licenses/alignment-models-license-status.csv +5 -0
- package/ios/SherpaOnnx+Alignment.mm +704 -0
- package/ios/SherpaOnnx+STT.mm +6 -0
- package/ios/SherpaOnnx+TTS.mm +624 -50
- package/ios/model_detect/sherpa-onnx-model-detect-alignment.mm +108 -0
- package/ios/model_detect/sherpa-onnx-model-detect.h +31 -0
- package/ios/model_detect/sherpa-onnx-validate-alignment.h +30 -0
- package/ios/model_detect/sherpa-onnx-validate-alignment.mm +66 -0
- package/ios/stt/sherpa-onnx-stt-wrapper.h +3 -1
- package/ios/stt/sherpa-onnx-stt-wrapper.mm +6 -0
- package/lib/module/NativeSherpaOnnx.js.map +1 -1
- package/lib/module/alignment/index.js +27 -0
- package/lib/module/alignment/index.js.map +1 -0
- package/lib/module/alignment/types.js +2 -0
- package/lib/module/alignment/types.js.map +1 -0
- package/lib/module/alignment/vocab.js +40 -0
- package/lib/module/alignment/vocab.js.map +1 -0
- package/lib/module/download/paths.js +9 -1
- package/lib/module/download/paths.js.map +1 -1
- package/lib/module/download/registry.js +17 -1
- package/lib/module/download/registry.js.map +1 -1
- package/lib/module/download/types.js +1 -0
- package/lib/module/download/types.js.map +1 -1
- package/lib/module/index.js +6 -4
- package/lib/module/index.js.map +1 -1
- package/lib/module/licenses.js +8 -2
- package/lib/module/licenses.js.map +1 -1
- package/lib/module/stt/types.js.map +1 -1
- package/lib/module/tts/index.js +68 -2
- package/lib/module/tts/index.js.map +1 -1
- package/lib/module/tts/subtitles.js +400 -0
- package/lib/module/tts/subtitles.js.map +1 -0
- package/lib/module/tts/tempAudio.js +17 -0
- package/lib/module/tts/tempAudio.js.map +1 -0
- package/lib/module/tts/types.js.map +1 -1
- package/lib/typescript/src/NativeSherpaOnnx.d.ts +34 -3
- package/lib/typescript/src/NativeSherpaOnnx.d.ts.map +1 -1
- package/lib/typescript/src/alignment/index.d.ts +8 -0
- package/lib/typescript/src/alignment/index.d.ts.map +1 -0
- package/lib/typescript/src/alignment/types.d.ts +23 -0
- package/lib/typescript/src/alignment/types.d.ts.map +1 -0
- package/lib/typescript/src/alignment/vocab.d.ts +5 -0
- package/lib/typescript/src/alignment/vocab.d.ts.map +1 -0
- package/lib/typescript/src/download/paths.d.ts +5 -2
- package/lib/typescript/src/download/paths.d.ts.map +1 -1
- package/lib/typescript/src/download/registry.d.ts.map +1 -1
- package/lib/typescript/src/download/types.d.ts +2 -1
- package/lib/typescript/src/download/types.d.ts.map +1 -1
- 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.map +1 -1
- package/lib/typescript/src/stt/types.d.ts +5 -2
- package/lib/typescript/src/stt/types.d.ts.map +1 -1
- package/lib/typescript/src/tts/index.d.ts +2 -1
- package/lib/typescript/src/tts/index.d.ts.map +1 -1
- package/lib/typescript/src/tts/subtitles.d.ts +24 -0
- package/lib/typescript/src/tts/subtitles.d.ts.map +1 -0
- package/lib/typescript/src/tts/tempAudio.d.ts +3 -0
- package/lib/typescript/src/tts/tempAudio.d.ts.map +1 -0
- package/lib/typescript/src/tts/types.d.ts +68 -2
- package/lib/typescript/src/tts/types.d.ts.map +1 -1
- package/package.json +6 -1
- package/scripts/alignment-models/README.md +90 -0
- package/scripts/alignment-models/build_and_upload.js +724 -0
- package/scripts/alignment-models/sources.csv +5 -0
- package/scripts/alignment-models/sync_alignment_license_status.js +123 -0
- package/src/NativeSherpaOnnx.ts +35 -3
- package/src/alignment/index.ts +41 -0
- package/src/alignment/types.ts +22 -0
- package/src/alignment/vocab.ts +38 -0
- package/src/download/paths.ts +18 -5
- package/src/download/registry.ts +23 -3
- package/src/download/types.ts +1 -0
- package/src/index.tsx +6 -4
- package/src/licenses.ts +12 -1
- package/src/stt/types.ts +5 -2
- package/src/tts/index.ts +110 -3
- package/src/tts/subtitles.ts +611 -0
- package/src/tts/tempAudio.ts +31 -0
- package/src/tts/types.ts +79 -2
- package/third_party/sherpa-onnx-prebuilt/IOS_RELEASE_TAG +1 -1
package/src/tts/types.ts
CHANGED
|
@@ -179,6 +179,40 @@ export interface TtsUpdateOptions {
|
|
|
179
179
|
modelOptions?: TtsModelOptions;
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
+
export type SubtitleMode = 'off' | 'fast' | 'accurate';
|
|
183
|
+
|
|
184
|
+
export type SubtitleGranularity = 'sentence' | 'word' | 'character';
|
|
185
|
+
|
|
186
|
+
export interface SubtitleOptions {
|
|
187
|
+
/**
|
|
188
|
+
* Subtitle generation mode.
|
|
189
|
+
*
|
|
190
|
+
* - 'off': Do not generate subtitles/timestamps
|
|
191
|
+
* - 'fast': Estimated timing based on callback chunks (default)
|
|
192
|
+
* - 'accurate': wav2vec2 CTC forced alignment
|
|
193
|
+
*
|
|
194
|
+
* @default 'fast'
|
|
195
|
+
*/
|
|
196
|
+
mode?: SubtitleMode;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Subtitle granularity.
|
|
200
|
+
*
|
|
201
|
+
* - 'sentence': sentence-level subtitles
|
|
202
|
+
* - 'word': word-level subtitles
|
|
203
|
+
* - 'character': character-level subtitles (only supported with mode: 'accurate')
|
|
204
|
+
*
|
|
205
|
+
* @default 'sentence'
|
|
206
|
+
*/
|
|
207
|
+
granularity?: SubtitleGranularity;
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Optional absolute path to an alignment ONNX model.
|
|
211
|
+
* Required when `mode: 'accurate'`.
|
|
212
|
+
*/
|
|
213
|
+
alignmentModelPath?: string;
|
|
214
|
+
}
|
|
215
|
+
|
|
182
216
|
/**
|
|
183
217
|
* Options for TTS generation. Maps to Kotlin GenerationConfig when reference
|
|
184
218
|
* audio or advanced options are used; otherwise simple sid/speed are used.
|
|
@@ -235,6 +269,11 @@ export interface TtsGenerationOptions {
|
|
|
235
269
|
* Model-specific (e.g. temperature, chunk_size for Pocket).
|
|
236
270
|
*/
|
|
237
271
|
extra?: Record<string, string>;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Subtitle/timestamp generation options.
|
|
275
|
+
*/
|
|
276
|
+
subtitles?: SubtitleOptions;
|
|
238
277
|
}
|
|
239
278
|
|
|
240
279
|
/**
|
|
@@ -288,9 +327,47 @@ export interface GeneratedAudioWithTimestamps extends GeneratedAudio {
|
|
|
288
327
|
subtitles: TtsSubtitleItem[];
|
|
289
328
|
|
|
290
329
|
/**
|
|
291
|
-
*
|
|
330
|
+
* Subtitle timing mode.
|
|
331
|
+
*
|
|
332
|
+
* - 'off': No subtitle timing requested/generated
|
|
333
|
+
* - 'estimated': Fast mode estimation
|
|
334
|
+
* - 'aligned': Accurate forced alignment mode
|
|
335
|
+
*/
|
|
336
|
+
timingMode: 'off' | 'estimated' | 'aligned';
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
export interface SubtitleFromAudioOptions {
|
|
340
|
+
/**
|
|
341
|
+
* Subtitle generation mode.
|
|
342
|
+
*/
|
|
343
|
+
mode: 'fast' | 'accurate';
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Subtitle granularity.
|
|
347
|
+
*
|
|
348
|
+
* - 'sentence': sentence-level subtitles
|
|
349
|
+
* - 'word': word-level subtitles
|
|
350
|
+
* - 'character': character-level subtitles (only supported with mode: 'accurate')
|
|
351
|
+
*
|
|
352
|
+
* @default 'sentence'
|
|
292
353
|
*/
|
|
293
|
-
|
|
354
|
+
granularity?: SubtitleGranularity;
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Optional language hint for future multi-language alignment variants.
|
|
358
|
+
*/
|
|
359
|
+
language?: string;
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Optional absolute path to an alignment ONNX model.
|
|
363
|
+
* Required when `mode: 'accurate'`.
|
|
364
|
+
*/
|
|
365
|
+
alignmentModelPath?: string;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
export interface SubtitleResult {
|
|
369
|
+
subtitles: TtsSubtitleItem[];
|
|
370
|
+
timingMode: 'estimated' | 'aligned';
|
|
294
371
|
}
|
|
295
372
|
|
|
296
373
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
sherpa-onnx-ios-v1.12.34-
|
|
1
|
+
sherpa-onnx-ios-v1.12.34-2
|