react-native-sherpa-onnx 0.1.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 (83) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +402 -0
  3. package/SherpaOnnx.podspec +84 -0
  4. package/android/build.gradle +193 -0
  5. package/android/src/main/AndroidManifest.xml +2 -0
  6. package/android/src/main/cpp/CMakeLists.txt +121 -0
  7. package/android/src/main/cpp/include/sherpa-onnx/c-api/c-api.h +1918 -0
  8. package/android/src/main/cpp/include/sherpa-onnx/c-api/cxx-api.h +841 -0
  9. package/android/src/main/cpp/jni/sherpa-onnx-jni.cpp +129 -0
  10. package/android/src/main/cpp/jni/sherpa-onnx-wrapper.cpp +649 -0
  11. package/android/src/main/cpp/jni/sherpa-onnx-wrapper.h +56 -0
  12. package/android/src/main/java/com/sherpaonnx/SherpaOnnxModule.kt +316 -0
  13. package/android/src/main/java/com/sherpaonnx/SherpaOnnxPackage.kt +33 -0
  14. package/ios/Frameworks/sherpa_onnx.xcframework.zip +0 -0
  15. package/ios/SherpaOnnx.h +5 -0
  16. package/ios/SherpaOnnx.mm +293 -0
  17. package/ios/SherpaOnnx.xcconfig +19 -0
  18. package/ios/include/sherpa-onnx/c-api/c-api.h +1918 -0
  19. package/ios/include/sherpa-onnx/c-api/cxx-api.h +841 -0
  20. package/ios/sherpa-onnx-wrapper.h +57 -0
  21. package/ios/sherpa-onnx-wrapper.mm +432 -0
  22. package/lib/module/NativeSherpaOnnx.js +5 -0
  23. package/lib/module/NativeSherpaOnnx.js.map +1 -0
  24. package/lib/module/diarization/index.js +54 -0
  25. package/lib/module/diarization/index.js.map +1 -0
  26. package/lib/module/enhancement/index.js +54 -0
  27. package/lib/module/enhancement/index.js.map +1 -0
  28. package/lib/module/index.js +25 -0
  29. package/lib/module/index.js.map +1 -0
  30. package/lib/module/package.json +1 -0
  31. package/lib/module/separation/index.js +54 -0
  32. package/lib/module/separation/index.js.map +1 -0
  33. package/lib/module/stt/index.js +79 -0
  34. package/lib/module/stt/index.js.map +1 -0
  35. package/lib/module/stt/types.js +4 -0
  36. package/lib/module/stt/types.js.map +1 -0
  37. package/lib/module/tts/index.js +54 -0
  38. package/lib/module/tts/index.js.map +1 -0
  39. package/lib/module/types.js +2 -0
  40. package/lib/module/types.js.map +1 -0
  41. package/lib/module/utils.js +93 -0
  42. package/lib/module/utils.js.map +1 -0
  43. package/lib/module/vad/index.js +54 -0
  44. package/lib/module/vad/index.js.map +1 -0
  45. package/lib/typescript/package.json +1 -0
  46. package/lib/typescript/src/NativeSherpaOnnx.d.ts +39 -0
  47. package/lib/typescript/src/NativeSherpaOnnx.d.ts.map +1 -0
  48. package/lib/typescript/src/diarization/index.d.ts +49 -0
  49. package/lib/typescript/src/diarization/index.d.ts.map +1 -0
  50. package/lib/typescript/src/enhancement/index.d.ts +47 -0
  51. package/lib/typescript/src/enhancement/index.d.ts.map +1 -0
  52. package/lib/typescript/src/index.d.ts +9 -0
  53. package/lib/typescript/src/index.d.ts.map +1 -0
  54. package/lib/typescript/src/separation/index.d.ts +48 -0
  55. package/lib/typescript/src/separation/index.d.ts.map +1 -0
  56. package/lib/typescript/src/stt/index.d.ts +53 -0
  57. package/lib/typescript/src/stt/index.d.ts.map +1 -0
  58. package/lib/typescript/src/stt/types.d.ts +39 -0
  59. package/lib/typescript/src/stt/types.d.ts.map +1 -0
  60. package/lib/typescript/src/tts/index.d.ts +47 -0
  61. package/lib/typescript/src/tts/index.d.ts.map +1 -0
  62. package/lib/typescript/src/types.d.ts +59 -0
  63. package/lib/typescript/src/types.d.ts.map +1 -0
  64. package/lib/typescript/src/utils.d.ts +53 -0
  65. package/lib/typescript/src/utils.d.ts.map +1 -0
  66. package/lib/typescript/src/vad/index.d.ts +48 -0
  67. package/lib/typescript/src/vad/index.d.ts.map +1 -0
  68. package/package.json +221 -0
  69. package/scripts/copy-headers.js +184 -0
  70. package/scripts/setup-assets.js +323 -0
  71. package/scripts/setup-ios-framework.sh +282 -0
  72. package/scripts/switch-registry.js +75 -0
  73. package/src/NativeSherpaOnnx.ts +44 -0
  74. package/src/diarization/index.ts +69 -0
  75. package/src/enhancement/index.ts +67 -0
  76. package/src/index.tsx +30 -0
  77. package/src/separation/index.ts +68 -0
  78. package/src/stt/index.ts +83 -0
  79. package/src/stt/types.ts +42 -0
  80. package/src/tts/index.ts +67 -0
  81. package/src/types.ts +73 -0
  82. package/src/utils.ts +97 -0
  83. package/src/vad/index.ts +70 -0
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Source Separation feature module
5
+ *
6
+ * @remarks
7
+ * This feature is not yet implemented. This module serves as a placeholder
8
+ * for future source separation functionality.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * // Future usage:
13
+ * import { initializeSeparation, separateSources } from 'react-native-sherpa-onnx/separation';
14
+ *
15
+ * await initializeSeparation({ modelPath: 'models/separation-model' });
16
+ * const sources = await separateSources('path/to/mixed-audio.wav');
17
+ * ```
18
+ */
19
+
20
+ /**
21
+ * Separation initialization options (placeholder)
22
+ */
23
+
24
+ /**
25
+ * Separated audio source
26
+ */
27
+
28
+ /**
29
+ * Initialize Source Separation with model directory.
30
+ *
31
+ * @throws {Error} Not yet implemented
32
+ */
33
+ export async function initializeSeparation(_options) {
34
+ throw new Error('Source Separation feature is not yet implemented. This is a placeholder module.');
35
+ }
36
+
37
+ /**
38
+ * Separate audio sources from a mixed audio file.
39
+ *
40
+ * @throws {Error} Not yet implemented
41
+ */
42
+ export function separateSources(_filePath) {
43
+ throw new Error('Source Separation feature is not yet implemented. This is a placeholder module.');
44
+ }
45
+
46
+ /**
47
+ * Release separation resources.
48
+ *
49
+ * @throws {Error} Not yet implemented
50
+ */
51
+ export function unloadSeparation() {
52
+ throw new Error('Source Separation feature is not yet implemented. This is a placeholder module.');
53
+ }
54
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["initializeSeparation","_options","Error","separateSources","_filePath","unloadSeparation"],"sourceRoot":"..\\..\\..\\src","sources":["separation/index.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAMA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeA,oBAAoBA,CACxCC,QAAqC,EACtB;EACf,MAAM,IAAIC,KAAK,CACb,iFACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAACC,SAAiB,EAA8B;EAC7E,MAAM,IAAIF,KAAK,CACb,iFACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASG,gBAAgBA,CAAA,EAAkB;EAChD,MAAM,IAAIH,KAAK,CACb,iFACF,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+
3
+ import SherpaOnnx from "../NativeSherpaOnnx.js";
4
+ import { resolveModelPath } from "../utils.js";
5
+
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
+ * @example
16
+ * ```typescript
17
+ * // Simple string (auto-detect)
18
+ * await initializeSTT('models/sherpa-onnx-model');
19
+ *
20
+ * // Asset model
21
+ * await initializeSTT({
22
+ * modelPath: { type: 'asset', path: 'models/sherpa-onnx-model' }
23
+ * });
24
+ *
25
+ * // File system model with preferInt8 option
26
+ * 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
+ * await initializeSTT({
33
+ * modelPath: { type: 'asset', path: 'models/sherpa-onnx-nemo-parakeet-tdt-ctc-en' },
34
+ * modelType: 'nemo_ctc'
35
+ * });
36
+ * ```
37
+ */
38
+ export async function initializeSTT(options) {
39
+ // Handle both object syntax and direct path syntax
40
+ let modelPath;
41
+ let preferInt8;
42
+ let modelType;
43
+ if (typeof options === 'object' && 'modelPath' in options) {
44
+ modelPath = options.modelPath;
45
+ preferInt8 = options.preferInt8;
46
+ modelType = options.modelType;
47
+ } else {
48
+ modelPath = options;
49
+ preferInt8 = undefined;
50
+ modelType = undefined;
51
+ }
52
+ const resolvedPath = await resolveModelPath(modelPath);
53
+ return SherpaOnnx.initializeSherpaOnnx(resolvedPath, preferInt8, modelType);
54
+ }
55
+
56
+ /**
57
+ * Transcribe an audio file.
58
+ *
59
+ * @param filePath - Path to WAV file (16kHz, mono, 16-bit PCM)
60
+ * @returns Promise resolving to transcribed text
61
+ * @example
62
+ * ```typescript
63
+ * const transcription = await transcribeFile('path/to/audio.wav');
64
+ * console.log('Transcription:', transcription);
65
+ * ```
66
+ */
67
+ export function transcribeFile(filePath) {
68
+ return SherpaOnnx.transcribeFile(filePath);
69
+ }
70
+
71
+ /**
72
+ * Release STT resources.
73
+ */
74
+ export function unloadSTT() {
75
+ return SherpaOnnx.unloadSherpaOnnx();
76
+ }
77
+
78
+ // Export types
79
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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,OAAO,eAAeC,aAAaA,CACjCC,OAA8D,EAC/C;EACf;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":[]}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export {};
4
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"..\\..\\..\\src","sources":["stt/types.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Text-to-Speech (TTS) feature module
5
+ *
6
+ * @remarks
7
+ * This feature is not yet implemented. This module serves as a placeholder
8
+ * for future TTS functionality.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * // Future usage:
13
+ * import { initializeTTS, synthesizeText } from 'react-native-sherpa-onnx/tts';
14
+ *
15
+ * await initializeTTS({ modelPath: 'models/tts-model' });
16
+ * const audioPath = await synthesizeText('Hello, world!');
17
+ * ```
18
+ */
19
+
20
+ /**
21
+ * TTS initialization options (placeholder)
22
+ */
23
+
24
+ /**
25
+ * TTS synthesis result (placeholder)
26
+ */
27
+
28
+ /**
29
+ * Initialize Text-to-Speech (TTS) with model directory.
30
+ *
31
+ * @throws {Error} Not yet implemented
32
+ */
33
+ export async function initializeTTS(_options) {
34
+ throw new Error('TTS feature is not yet implemented. This is a placeholder module.');
35
+ }
36
+
37
+ /**
38
+ * Synthesize text to speech audio.
39
+ *
40
+ * @throws {Error} Not yet implemented
41
+ */
42
+ export function synthesizeText(_text) {
43
+ throw new Error('TTS feature is not yet implemented. This is a placeholder module.');
44
+ }
45
+
46
+ /**
47
+ * Release TTS resources.
48
+ *
49
+ * @throws {Error} Not yet implemented
50
+ */
51
+ export function unloadTTS() {
52
+ throw new Error('TTS feature is not yet implemented. This is a placeholder module.');
53
+ }
54
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["initializeTTS","_options","Error","synthesizeText","_text","unloadTTS"],"sourceRoot":"..\\..\\..\\src","sources":["tts/index.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAMA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeA,aAAaA,CACjCC,QAA8B,EACf;EACf,MAAM,IAAIC,KAAK,CACb,mEACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAACC,KAAa,EAAmB;EAC7D,MAAM,IAAIF,KAAK,CACb,mEACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASG,SAASA,CAAA,EAAkB;EACzC,MAAM,IAAIH,KAAK,CACb,mEACF,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"..\\..\\src","sources":["types.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+
3
+ import { Platform } from 'react-native';
4
+ import SherpaOnnx from "./NativeSherpaOnnx.js";
5
+
6
+ /**
7
+ * Utility functions for model path handling
8
+ */
9
+
10
+ /**
11
+ * Predefined model identifiers
12
+ */
13
+ export const MODELS = {
14
+ ZIPFORMER_EN: 'sherpa-onnx-zipformer-small-en',
15
+ PARAFORMER_ZH: 'sherpa-onnx-paraformer-zh-small'
16
+ };
17
+ /**
18
+ * Get the default model directory path for the current platform.
19
+ * This is a helper for apps that want to use a standard location.
20
+ *
21
+ * @returns Platform-specific default path
22
+ */
23
+ export function getDefaultModelPath() {
24
+ if (Platform.OS === 'ios') {
25
+ // iOS: Documents directory
26
+ return 'Documents/models';
27
+ } else {
28
+ // Android: Internal storage
29
+ return 'models';
30
+ }
31
+ }
32
+
33
+ /**
34
+ * Create a model path configuration for asset models.
35
+ * Use this when models are bundled in your app's assets.
36
+ *
37
+ * @param assetPath - Path relative to assets (e.g., "models/sherpa-onnx-model")
38
+ * @returns Model path configuration
39
+ */
40
+ export function assetModelPath(assetPath) {
41
+ return {
42
+ type: 'asset',
43
+ path: assetPath
44
+ };
45
+ }
46
+
47
+ /**
48
+ * Create a model path configuration for file system models.
49
+ * Use this when models are downloaded or stored in file system.
50
+ *
51
+ * @param filePath - Absolute path to model directory
52
+ * @returns Model path configuration
53
+ */
54
+ export function fileModelPath(filePath) {
55
+ return {
56
+ type: 'file',
57
+ path: filePath
58
+ };
59
+ }
60
+
61
+ /**
62
+ * Create a model path configuration with auto-detection.
63
+ * Tries asset first, then file system.
64
+ *
65
+ * @param path - Path to try (will be checked as both asset and file)
66
+ * @returns Model path configuration
67
+ */
68
+ export function autoModelPath(path) {
69
+ return {
70
+ type: 'auto',
71
+ path: path
72
+ };
73
+ }
74
+
75
+ /**
76
+ * Resolve model path based on configuration.
77
+ * This handles different path types (asset, file, auto) and returns
78
+ * a platform-specific absolute path that can be used by native code.
79
+ *
80
+ * @param config - Model path configuration or simple string path
81
+ * @returns Promise resolving to absolute path usable by native code
82
+ */
83
+ export async function resolveModelPath(config) {
84
+ // Backward compatibility: if string is passed, treat as auto
85
+ if (typeof config === 'string') {
86
+ return SherpaOnnx.resolveModelPath({
87
+ type: 'auto',
88
+ path: config
89
+ });
90
+ }
91
+ return SherpaOnnx.resolveModelPath(config);
92
+ }
93
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Platform","SherpaOnnx","MODELS","ZIPFORMER_EN","PARAFORMER_ZH","getDefaultModelPath","OS","assetModelPath","assetPath","type","path","fileModelPath","filePath","autoModelPath","resolveModelPath","config"],"sourceRoot":"..\\..\\src","sources":["utils.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,OAAOC,UAAU,MAAM,uBAAoB;;AAE3C;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO,MAAMC,MAAM,GAAG;EACpBC,YAAY,EAAE,gCAAgC;EAC9CC,aAAa,EAAE;AACjB,CAAU;AAIV;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CAAA,EAAW;EAC5C,IAAIL,QAAQ,CAACM,EAAE,KAAK,KAAK,EAAE;IACzB;IACA,OAAO,kBAAkB;EAC3B,CAAC,MAAM;IACL;IACA,OAAO,QAAQ;EACjB;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAACC,SAAiB,EAAmB;EACjE,OAAO;IACLC,IAAI,EAAE,OAAO;IACbC,IAAI,EAAEF;EACR,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASG,aAAaA,CAACC,QAAgB,EAAmB;EAC/D,OAAO;IACLH,IAAI,EAAE,MAAM;IACZC,IAAI,EAAEE;EACR,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAACH,IAAY,EAAmB;EAC3D,OAAO;IACLD,IAAI,EAAE,MAAM;IACZC,IAAI,EAAEA;EACR,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeI,gBAAgBA,CACpCC,MAAgC,EACf;EACjB;EACA,IAAI,OAAOA,MAAM,KAAK,QAAQ,EAAE;IAC9B,OAAOd,UAAU,CAACa,gBAAgB,CAAC;MACjCL,IAAI,EAAE,MAAM;MACZC,IAAI,EAAEK;IACR,CAAC,CAAC;EACJ;EAEA,OAAOd,UAAU,CAACa,gBAAgB,CAACC,MAAM,CAAC;AAC5C","ignoreList":[]}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Voice Activity Detection (VAD) feature module
5
+ *
6
+ * @remarks
7
+ * This feature is not yet implemented. This module serves as a placeholder
8
+ * for future VAD functionality.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * // Future usage:
13
+ * import { initializeVAD, detectVoiceActivity } from 'react-native-sherpa-onnx/vad';
14
+ *
15
+ * await initializeVAD({ modelPath: 'models/vad-model' });
16
+ * const segments = await detectVoiceActivity('path/to/audio.wav');
17
+ * ```
18
+ */
19
+
20
+ /**
21
+ * VAD initialization options (placeholder)
22
+ */
23
+
24
+ /**
25
+ * Voice activity segment
26
+ */
27
+
28
+ /**
29
+ * Initialize Voice Activity Detection (VAD) with model directory.
30
+ *
31
+ * @throws {Error} Not yet implemented
32
+ */
33
+ export async function initializeVAD(_options) {
34
+ throw new Error('VAD feature is not yet implemented. This is a placeholder module.');
35
+ }
36
+
37
+ /**
38
+ * Detect voice activity in an audio file.
39
+ *
40
+ * @throws {Error} Not yet implemented
41
+ */
42
+ export function detectVoiceActivity(_filePath) {
43
+ throw new Error('VAD feature is not yet implemented. This is a placeholder module.');
44
+ }
45
+
46
+ /**
47
+ * Release VAD resources.
48
+ *
49
+ * @throws {Error} Not yet implemented
50
+ */
51
+ export function unloadVAD() {
52
+ throw new Error('VAD feature is not yet implemented. This is a placeholder module.');
53
+ }
54
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["initializeVAD","_options","Error","detectVoiceActivity","_filePath","unloadVAD"],"sourceRoot":"..\\..\\..\\src","sources":["vad/index.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAMA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeA,aAAaA,CACjCC,QAA8B,EACf;EACf,MAAM,IAAIC,KAAK,CACb,mEACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CACjCC,SAAiB,EACQ;EACzB,MAAM,IAAIF,KAAK,CACb,mEACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASG,SAASA,CAAA,EAAkB;EACzC,MAAM,IAAIH,KAAK,CACb,mEACF,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,39 @@
1
+ import { type TurboModule } from 'react-native';
2
+ export interface Spec extends TurboModule {
3
+ /**
4
+ * Test method to verify sherpa-onnx native library is loaded.
5
+ * Phase 1: Minimal "Hello World" test.
6
+ */
7
+ testSherpaInit(): Promise<string>;
8
+ /**
9
+ * Resolve model path based on configuration.
10
+ * Handles asset paths, file system paths, and auto-detection.
11
+ * Returns an absolute path that can be used by native code.
12
+ *
13
+ * @param config - Object with 'type' ('asset' | 'file' | 'auto') and 'path' (string)
14
+ */
15
+ resolveModelPath(config: {
16
+ type: string;
17
+ path: string;
18
+ }): Promise<string>;
19
+ /**
20
+ * Initialize sherpa-onnx with model directory.
21
+ * Expects an absolute path (use resolveModelPath first for asset/file paths).
22
+ * @param modelDir - Absolute path to model directory
23
+ * @param preferInt8 - Optional: true = prefer int8 models, false = prefer regular models, undefined = try int8 first (default)
24
+ * @param modelType - Optional: explicit model type ('transducer', 'paraformer', 'nemo_ctc', 'auto'), undefined = auto (default)
25
+ */
26
+ initializeSherpaOnnx(modelDir: string, preferInt8?: boolean, modelType?: string): Promise<void>;
27
+ /**
28
+ * Transcribe an audio file.
29
+ * Phase 1: Stub implementation.
30
+ */
31
+ transcribeFile(filePath: string): Promise<string>;
32
+ /**
33
+ * Release sherpa-onnx resources.
34
+ */
35
+ unloadSherpaOnnx(): Promise<void>;
36
+ }
37
+ declare const _default: Spec;
38
+ export default _default;
39
+ //# sourceMappingURL=NativeSherpaOnnx.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeSherpaOnnx.d.ts","sourceRoot":"","sources":["../../../src/NativeSherpaOnnx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAErE,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC;;;OAGG;IACH,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAElC;;;;;;OAMG;IACH,gBAAgB,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE1E;;;;;;OAMG;IACH,oBAAoB,CAClB,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,OAAO,EACpB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB;;;OAGG;IACH,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAElD;;OAEG;IACH,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACnC;;AAED,wBAAoE"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Speaker Diarization feature module
3
+ *
4
+ * @remarks
5
+ * This feature is not yet implemented. This module serves as a placeholder
6
+ * for future speaker diarization functionality.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * // Future usage:
11
+ * import { initializeDiarization, diarizeAudio } from 'react-native-sherpa-onnx/diarization';
12
+ *
13
+ * await initializeDiarization({ modelPath: 'models/diarization-model' });
14
+ * const segments = await diarizeAudio('path/to/audio.wav');
15
+ * ```
16
+ */
17
+ /**
18
+ * Diarization initialization options (placeholder)
19
+ */
20
+ export interface DiarizationInitializeOptions {
21
+ modelPath: string;
22
+ }
23
+ /**
24
+ * Speaker segment with speaker ID
25
+ */
26
+ export interface SpeakerSegment {
27
+ speakerId: string;
28
+ start: number;
29
+ end: number;
30
+ }
31
+ /**
32
+ * Initialize Speaker Diarization with model directory.
33
+ *
34
+ * @throws {Error} Not yet implemented
35
+ */
36
+ export declare function initializeDiarization(_options: DiarizationInitializeOptions): Promise<void>;
37
+ /**
38
+ * Perform speaker diarization on an audio file.
39
+ *
40
+ * @throws {Error} Not yet implemented
41
+ */
42
+ export declare function diarizeAudio(_filePath: string): Promise<SpeakerSegment[]>;
43
+ /**
44
+ * Release diarization resources.
45
+ *
46
+ * @throws {Error} Not yet implemented
47
+ */
48
+ export declare function unloadDiarization(): Promise<void>;
49
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/diarization/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,SAAS,EAAE,MAAM,CAAC;CAEnB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CAEb;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,cAAc,EAAE,CAAC,CAIzE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAIjD"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Speech Enhancement feature module
3
+ *
4
+ * @remarks
5
+ * This feature is not yet implemented. This module serves as a placeholder
6
+ * for future speech enhancement functionality.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * // Future usage:
11
+ * import { initializeEnhancement, enhanceAudio } from 'react-native-sherpa-onnx/enhancement';
12
+ *
13
+ * await initializeEnhancement({ modelPath: 'models/enhancement-model' });
14
+ * const enhancedPath = await enhanceAudio('path/to/noisy-audio.wav');
15
+ * ```
16
+ */
17
+ /**
18
+ * Enhancement initialization options (placeholder)
19
+ */
20
+ export interface EnhancementInitializeOptions {
21
+ modelPath: string;
22
+ }
23
+ /**
24
+ * Enhancement result
25
+ */
26
+ export interface EnhancementResult {
27
+ outputPath: string;
28
+ }
29
+ /**
30
+ * Initialize Speech Enhancement with model directory.
31
+ *
32
+ * @throws {Error} Not yet implemented
33
+ */
34
+ export declare function initializeEnhancement(_options: EnhancementInitializeOptions): Promise<void>;
35
+ /**
36
+ * Enhance speech quality in an audio file.
37
+ *
38
+ * @throws {Error} Not yet implemented
39
+ */
40
+ export declare function enhanceAudio(_filePath: string): Promise<EnhancementResult>;
41
+ /**
42
+ * Release enhancement resources.
43
+ *
44
+ * @throws {Error} Not yet implemented
45
+ */
46
+ export declare function unloadEnhancement(): Promise<void>;
47
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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,MAAM,CAAC;CAEnB;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"}
@@ -0,0 +1,9 @@
1
+ export type { InitializeOptions, ModelPathConfig, ModelType } from './types';
2
+ export { assetModelPath, autoModelPath, fileModelPath, getDefaultModelPath, resolveModelPath, } from './utils';
3
+ export { initializeSTT, transcribeFile, unloadSTT } from './stt';
4
+ export type { STTInitializeOptions, TranscriptionResult } from './stt';
5
+ /**
6
+ * Test method to verify sherpa-onnx native library is loaded.
7
+ */
8
+ export declare function testSherpaInit(): Promise<string>;
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAGA,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EACL,cAAc,EACd,aAAa,EACb,aAAa,EACb,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACjE,YAAY,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAUvE;;GAEG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,CAEhD"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Source Separation feature module
3
+ *
4
+ * @remarks
5
+ * This feature is not yet implemented. This module serves as a placeholder
6
+ * for future source separation functionality.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * // Future usage:
11
+ * import { initializeSeparation, separateSources } from 'react-native-sherpa-onnx/separation';
12
+ *
13
+ * await initializeSeparation({ modelPath: 'models/separation-model' });
14
+ * const sources = await separateSources('path/to/mixed-audio.wav');
15
+ * ```
16
+ */
17
+ /**
18
+ * Separation initialization options (placeholder)
19
+ */
20
+ export interface SeparationInitializeOptions {
21
+ modelPath: string;
22
+ }
23
+ /**
24
+ * Separated audio source
25
+ */
26
+ export interface SeparatedSource {
27
+ sourceId: string;
28
+ outputPath: string;
29
+ }
30
+ /**
31
+ * Initialize Source Separation with model directory.
32
+ *
33
+ * @throws {Error} Not yet implemented
34
+ */
35
+ export declare function initializeSeparation(_options: SeparationInitializeOptions): Promise<void>;
36
+ /**
37
+ * Separate audio sources from a mixed audio file.
38
+ *
39
+ * @throws {Error} Not yet implemented
40
+ */
41
+ export declare function separateSources(_filePath: string): Promise<SeparatedSource[]>;
42
+ /**
43
+ * Release separation resources.
44
+ *
45
+ * @throws {Error} Not yet implemented
46
+ */
47
+ export declare function unloadSeparation(): Promise<void>;
48
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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,MAAM,CAAC;CAEnB;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"}
@@ -0,0 +1,53 @@
1
+ import type { STTInitializeOptions } from './types';
2
+ import type { InitializeOptions } from '../types';
3
+ /**
4
+ * Initialize Speech-to-Text (STT) with model directory.
5
+ *
6
+ * Supports multiple model source types:
7
+ * - Asset models (bundled in app)
8
+ * - File system models (downloaded or user-provided)
9
+ * - Auto-detection (tries asset first, then file system)
10
+ *
11
+ * @param options - STT initialization options or model path configuration
12
+ * @example
13
+ * ```typescript
14
+ * // Simple string (auto-detect)
15
+ * await initializeSTT('models/sherpa-onnx-model');
16
+ *
17
+ * // Asset model
18
+ * await initializeSTT({
19
+ * modelPath: { type: 'asset', path: 'models/sherpa-onnx-model' }
20
+ * });
21
+ *
22
+ * // File system model with preferInt8 option
23
+ * await initializeSTT({
24
+ * modelPath: { type: 'file', path: '/path/to/model' },
25
+ * preferInt8: true // Prefer quantized int8 models (smaller, faster)
26
+ * });
27
+ *
28
+ * // With explicit model type
29
+ * await initializeSTT({
30
+ * modelPath: { type: 'asset', path: 'models/sherpa-onnx-nemo-parakeet-tdt-ctc-en' },
31
+ * modelType: 'nemo_ctc'
32
+ * });
33
+ * ```
34
+ */
35
+ export declare function initializeSTT(options: STTInitializeOptions | InitializeOptions['modelPath']): Promise<void>;
36
+ /**
37
+ * Transcribe an audio file.
38
+ *
39
+ * @param filePath - Path to WAV file (16kHz, mono, 16-bit PCM)
40
+ * @returns Promise resolving to transcribed text
41
+ * @example
42
+ * ```typescript
43
+ * const transcription = await transcribeFile('path/to/audio.wav');
44
+ * console.log('Transcription:', transcription);
45
+ * ```
46
+ */
47
+ export declare function transcribeFile(filePath: string): Promise<string>;
48
+ /**
49
+ * Release STT resources.
50
+ */
51
+ export declare function unloadSTT(): Promise<void>;
52
+ export type { STTInitializeOptions, TranscriptionResult } from './types';
53
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/stt/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAGlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,oBAAoB,GAAG,iBAAiB,CAAC,WAAW,CAAC,GAC7D,OAAO,CAAC,IAAI,CAAC,CAkBf;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAEhE;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAEzC;AAGD,YAAY,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC"}