@xrkseek/harness 0.7.6 → 0.7.8

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 (171) hide show
  1. package/node_modules/@xrkseek/a2a/dist/inbound.d.ts.map +1 -1
  2. package/node_modules/@xrkseek/a2a/dist/inbound.js +72 -2
  3. package/node_modules/@xrkseek/a2a/dist/inbound.js.map +1 -1
  4. package/node_modules/@xrkseek/core-tools/dist/subagent-prompt.d.ts.map +1 -1
  5. package/node_modules/@xrkseek/core-tools/dist/subagent-prompt.js +2 -0
  6. package/node_modules/@xrkseek/core-tools/dist/subagent-prompt.js.map +1 -1
  7. package/node_modules/@xrkseek/exec-voice/README.md +4 -3
  8. package/node_modules/@xrkseek/exec-voice/dist/browser/index.d.ts +1 -0
  9. package/node_modules/@xrkseek/exec-voice/dist/browser/index.d.ts.map +1 -1
  10. package/node_modules/@xrkseek/exec-voice/dist/browser/index.js +1 -0
  11. package/node_modules/@xrkseek/exec-voice/dist/browser/index.js.map +1 -1
  12. package/node_modules/@xrkseek/exec-voice/dist/browser/wav-capture.d.ts +91 -0
  13. package/node_modules/@xrkseek/exec-voice/dist/browser/wav-capture.d.ts.map +1 -0
  14. package/node_modules/@xrkseek/exec-voice/dist/browser/wav-capture.js +269 -0
  15. package/node_modules/@xrkseek/exec-voice/dist/browser/wav-capture.js.map +1 -0
  16. package/node_modules/@xrkseek/exec-voice/dist/download-http.d.ts +46 -0
  17. package/node_modules/@xrkseek/exec-voice/dist/download-http.d.ts.map +1 -0
  18. package/node_modules/@xrkseek/exec-voice/dist/download-http.js +223 -0
  19. package/node_modules/@xrkseek/exec-voice/dist/download-http.js.map +1 -0
  20. package/node_modules/@xrkseek/exec-voice/dist/engine-ids.d.ts +19 -0
  21. package/node_modules/@xrkseek/exec-voice/dist/engine-ids.d.ts.map +1 -0
  22. package/node_modules/@xrkseek/exec-voice/dist/engine-ids.js +36 -0
  23. package/node_modules/@xrkseek/exec-voice/dist/engine-ids.js.map +1 -0
  24. package/node_modules/@xrkseek/exec-voice/dist/engines.d.ts +60 -0
  25. package/node_modules/@xrkseek/exec-voice/dist/engines.d.ts.map +1 -0
  26. package/node_modules/@xrkseek/exec-voice/dist/engines.js +130 -0
  27. package/node_modules/@xrkseek/exec-voice/dist/engines.js.map +1 -0
  28. package/node_modules/@xrkseek/exec-voice/dist/format.d.ts +13 -0
  29. package/node_modules/@xrkseek/exec-voice/dist/format.d.ts.map +1 -1
  30. package/node_modules/@xrkseek/exec-voice/dist/format.js +22 -3
  31. package/node_modules/@xrkseek/exec-voice/dist/format.js.map +1 -1
  32. package/node_modules/@xrkseek/exec-voice/dist/index.d.ts +23 -31
  33. package/node_modules/@xrkseek/exec-voice/dist/index.d.ts.map +1 -1
  34. package/node_modules/@xrkseek/exec-voice/dist/index.js +17 -66
  35. package/node_modules/@xrkseek/exec-voice/dist/index.js.map +1 -1
  36. package/node_modules/@xrkseek/exec-voice/dist/readiness.d.ts +14 -8
  37. package/node_modules/@xrkseek/exec-voice/dist/readiness.d.ts.map +1 -1
  38. package/node_modules/@xrkseek/exec-voice/dist/readiness.js +36 -27
  39. package/node_modules/@xrkseek/exec-voice/dist/readiness.js.map +1 -1
  40. package/node_modules/@xrkseek/exec-voice/dist/sensevoice-assets.d.ts +48 -0
  41. package/node_modules/@xrkseek/exec-voice/dist/sensevoice-assets.d.ts.map +1 -0
  42. package/node_modules/@xrkseek/exec-voice/dist/sensevoice-assets.js +64 -0
  43. package/node_modules/@xrkseek/exec-voice/dist/sensevoice-assets.js.map +1 -0
  44. package/node_modules/@xrkseek/exec-voice/dist/sensevoice-local.d.ts +24 -0
  45. package/node_modules/@xrkseek/exec-voice/dist/sensevoice-local.d.ts.map +1 -1
  46. package/node_modules/@xrkseek/exec-voice/dist/sensevoice-local.js +66 -4
  47. package/node_modules/@xrkseek/exec-voice/dist/sensevoice-local.js.map +1 -1
  48. package/node_modules/@xrkseek/exec-voice/dist/sensevoice-runtime.d.ts +78 -0
  49. package/node_modules/@xrkseek/exec-voice/dist/sensevoice-runtime.d.ts.map +1 -0
  50. package/node_modules/@xrkseek/exec-voice/dist/sensevoice-runtime.js +332 -0
  51. package/node_modules/@xrkseek/exec-voice/dist/sensevoice-runtime.js.map +1 -0
  52. package/node_modules/@xrkseek/exec-voice/dist/system-tts.d.ts +40 -0
  53. package/node_modules/@xrkseek/exec-voice/dist/system-tts.d.ts.map +1 -0
  54. package/node_modules/@xrkseek/exec-voice/dist/system-tts.js +260 -0
  55. package/node_modules/@xrkseek/exec-voice/dist/system-tts.js.map +1 -0
  56. package/node_modules/@xrkseek/exec-voice/dist/tools.d.ts +13 -12
  57. package/node_modules/@xrkseek/exec-voice/dist/tools.d.ts.map +1 -1
  58. package/node_modules/@xrkseek/exec-voice/dist/tools.js +12 -6
  59. package/node_modules/@xrkseek/exec-voice/dist/tools.js.map +1 -1
  60. package/node_modules/@xrkseek/exec-voice/dist/types.d.ts +3 -1
  61. package/node_modules/@xrkseek/exec-voice/dist/types.d.ts.map +1 -1
  62. package/node_modules/@xrkseek/exec-voice/dist/types.js.map +1 -1
  63. package/node_modules/@xrkseek/exec-voice/package.json +39 -31
  64. package/node_modules/@xrkseek/preset-harness/dist/preset.d.ts +4 -3
  65. package/node_modules/@xrkseek/preset-harness/dist/preset.d.ts.map +1 -1
  66. package/node_modules/@xrkseek/preset-harness/dist/preset.js +31 -18
  67. package/node_modules/@xrkseek/preset-harness/dist/preset.js.map +1 -1
  68. package/node_modules/@xrkseek/preset-harness/dist/tsconfig.tsbuildinfo +1 -1
  69. package/node_modules/@xrkseek/preset-minimal/dist/tsconfig.tsbuildinfo +1 -1
  70. package/node_modules/@xrkseek/preset-server/dist/tsconfig.tsbuildinfo +1 -1
  71. package/node_modules/@xrkseek/protocol/dist/sidebar-previews.d.ts +2 -0
  72. package/node_modules/@xrkseek/protocol/dist/sidebar-previews.d.ts.map +1 -1
  73. package/node_modules/@xrkseek/protocol/dist/sidebar-previews.js.map +1 -1
  74. package/node_modules/@xrkseek/server-face/dist/adapt/subagent-notice.d.ts +21 -2
  75. package/node_modules/@xrkseek/server-face/dist/adapt/subagent-notice.d.ts.map +1 -1
  76. package/node_modules/@xrkseek/server-face/dist/adapt/subagent-notice.js +56 -7
  77. package/node_modules/@xrkseek/server-face/dist/adapt/subagent-notice.js.map +1 -1
  78. package/node_modules/@xrkseek/server-face/dist/agent-roster-store.d.ts.map +1 -1
  79. package/node_modules/@xrkseek/server-face/dist/agent-roster-store.js +26 -3
  80. package/node_modules/@xrkseek/server-face/dist/agent-roster-store.js.map +1 -1
  81. package/node_modules/@xrkseek/server-face/dist/agent-team-roles.d.ts.map +1 -1
  82. package/node_modules/@xrkseek/server-face/dist/agent-team-roles.js +4 -0
  83. package/node_modules/@xrkseek/server-face/dist/agent-team-roles.js.map +1 -1
  84. package/node_modules/@xrkseek/server-face/dist/dispatch.d.ts.map +1 -1
  85. package/node_modules/@xrkseek/server-face/dist/dispatch.js +16 -0
  86. package/node_modules/@xrkseek/server-face/dist/dispatch.js.map +1 -1
  87. package/node_modules/@xrkseek/server-face/dist/handlers/voice.d.ts +30 -0
  88. package/node_modules/@xrkseek/server-face/dist/handlers/voice.d.ts.map +1 -0
  89. package/node_modules/@xrkseek/server-face/dist/handlers/voice.js +195 -0
  90. package/node_modules/@xrkseek/server-face/dist/handlers/voice.js.map +1 -0
  91. package/node_modules/@xrkseek/server-face/dist/model-catalog.d.ts +15 -0
  92. package/node_modules/@xrkseek/server-face/dist/model-catalog.d.ts.map +1 -1
  93. package/node_modules/@xrkseek/server-face/dist/model-catalog.js +44 -10
  94. package/node_modules/@xrkseek/server-face/dist/model-catalog.js.map +1 -1
  95. package/node_modules/@xrkseek/server-face/dist/runtime.d.ts.map +1 -1
  96. package/node_modules/@xrkseek/server-face/dist/runtime.js +7 -2
  97. package/node_modules/@xrkseek/server-face/dist/runtime.js.map +1 -1
  98. package/node_modules/@xrkseek/server-face/dist/select-session-model.d.ts.map +1 -1
  99. package/node_modules/@xrkseek/server-face/dist/select-session-model.js +68 -1
  100. package/node_modules/@xrkseek/server-face/dist/select-session-model.js.map +1 -1
  101. package/node_modules/@xrkseek/server-face/dist/session-posture.js +1 -1
  102. package/node_modules/@xrkseek/server-face/dist/session-posture.js.map +1 -1
  103. package/node_modules/@xrkseek/server-face/dist/session-tool-copy.d.ts +4 -0
  104. package/node_modules/@xrkseek/server-face/dist/session-tool-copy.d.ts.map +1 -1
  105. package/node_modules/@xrkseek/server-face/dist/session-tool-copy.js +16 -0
  106. package/node_modules/@xrkseek/server-face/dist/session-tool-copy.js.map +1 -1
  107. package/node_modules/@xrkseek/server-face/dist/session-tools.d.ts.map +1 -1
  108. package/node_modules/@xrkseek/server-face/dist/session-tools.js +2 -0
  109. package/node_modules/@xrkseek/server-face/dist/session-tools.js.map +1 -1
  110. package/node_modules/@xrkseek/server-face/dist/settings-document.d.ts.map +1 -1
  111. package/node_modules/@xrkseek/server-face/dist/settings-document.js +56 -1
  112. package/node_modules/@xrkseek/server-face/dist/settings-document.js.map +1 -1
  113. package/node_modules/@xrkseek/server-face/dist/settings-schemas.d.ts.map +1 -1
  114. package/node_modules/@xrkseek/server-face/dist/settings-schemas.js +42 -12
  115. package/node_modules/@xrkseek/server-face/dist/settings-schemas.js.map +1 -1
  116. package/node_modules/@xrkseek/server-face/dist/subagent-tools.d.ts +43 -0
  117. package/node_modules/@xrkseek/server-face/dist/subagent-tools.d.ts.map +1 -1
  118. package/node_modules/@xrkseek/server-face/dist/subagent-tools.js +293 -24
  119. package/node_modules/@xrkseek/server-face/dist/subagent-tools.js.map +1 -1
  120. package/node_modules/@xrkseek/server-face/dist/wire/paths.d.ts.map +1 -1
  121. package/node_modules/@xrkseek/server-face/dist/wire/paths.js +6 -0
  122. package/node_modules/@xrkseek/server-face/dist/wire/paths.js.map +1 -1
  123. package/node_modules/@xrkseek/server-face/dist/workspace-orchestrate-tools.d.ts.map +1 -1
  124. package/node_modules/@xrkseek/server-face/dist/workspace-orchestrate-tools.js +4 -1
  125. package/node_modules/@xrkseek/server-face/dist/workspace-orchestrate-tools.js.map +1 -1
  126. package/node_modules/@xrkseek/server-face/package.json +1 -0
  127. package/node_modules/@xrkseek/server-host/dist/a2a-inbound-public.d.ts.map +1 -1
  128. package/node_modules/@xrkseek/server-host/dist/a2a-inbound-public.js +8 -1
  129. package/node_modules/@xrkseek/server-host/dist/a2a-inbound-public.js.map +1 -1
  130. package/node_modules/@xrkseek/server-host/dist/index.d.ts +1 -1
  131. package/node_modules/@xrkseek/server-host/dist/index.d.ts.map +1 -1
  132. package/node_modules/@xrkseek/server-host/dist/index.js +44 -45
  133. package/node_modules/@xrkseek/server-host/dist/index.js.map +1 -1
  134. package/node_modules/@xrkseek/server-host/dist/sidebar-face-bridge.d.ts.map +1 -1
  135. package/node_modules/@xrkseek/server-host/dist/sidebar-face-bridge.js +2 -0
  136. package/node_modules/@xrkseek/server-host/dist/sidebar-face-bridge.js.map +1 -1
  137. package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-tool-pre.d.ts.map +1 -1
  138. package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-tool-pre.js +5 -2
  139. package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-tool-pre.js.map +1 -1
  140. package/node_modules/@xrkseek/server-http/dist/dsh-compat/our-free-model-host.d.ts +15 -0
  141. package/node_modules/@xrkseek/server-http/dist/dsh-compat/our-free-model-host.d.ts.map +1 -1
  142. package/node_modules/@xrkseek/server-http/dist/dsh-compat/our-free-model-host.js +61 -3
  143. package/node_modules/@xrkseek/server-http/dist/dsh-compat/our-free-model-host.js.map +1 -1
  144. package/node_modules/sherpa-onnx-node/README.md +11 -0
  145. package/node_modules/sherpa-onnx-node/addon-static-import.js +76 -0
  146. package/node_modules/sherpa-onnx-node/addon.js +98 -0
  147. package/node_modules/sherpa-onnx-node/audio-tagg.js +45 -0
  148. package/node_modules/sherpa-onnx-node/keyword-spotter.js +68 -0
  149. package/node_modules/sherpa-onnx-node/non-streaming-asr.js +158 -0
  150. package/node_modules/sherpa-onnx-node/non-streaming-speaker-diarization.js +38 -0
  151. package/node_modules/sherpa-onnx-node/non-streaming-speech-denoiser.js +32 -0
  152. package/node_modules/sherpa-onnx-node/non-streaming-tts.js +117 -0
  153. package/node_modules/sherpa-onnx-node/online-speech-denoiser.js +46 -0
  154. package/node_modules/sherpa-onnx-node/package.json +68 -0
  155. package/node_modules/sherpa-onnx-node/punctuation.js +43 -0
  156. package/node_modules/sherpa-onnx-node/resampler.js +80 -0
  157. package/node_modules/sherpa-onnx-node/sherpa-onnx.js +49 -0
  158. package/node_modules/sherpa-onnx-node/speaker-identification.js +152 -0
  159. package/node_modules/sherpa-onnx-node/spoken-language-identification.js +38 -0
  160. package/node_modules/sherpa-onnx-node/streaming-asr.js +181 -0
  161. package/node_modules/sherpa-onnx-node/types.js +833 -0
  162. package/node_modules/sherpa-onnx-node/vad.js +134 -0
  163. package/node_modules/sherpa-onnx-win-x64/README.md +3 -0
  164. package/node_modules/sherpa-onnx-win-x64/index.js +1 -0
  165. package/node_modules/sherpa-onnx-win-x64/onnxruntime.dll +0 -0
  166. package/node_modules/sherpa-onnx-win-x64/onnxruntime_providers_shared.dll +0 -0
  167. package/node_modules/sherpa-onnx-win-x64/package.json +65 -0
  168. package/node_modules/sherpa-onnx-win-x64/sherpa-onnx-c-api.dll +0 -0
  169. package/node_modules/sherpa-onnx-win-x64/sherpa-onnx-cxx-api.dll +0 -0
  170. package/node_modules/sherpa-onnx-win-x64/sherpa-onnx.node +0 -0
  171. package/package.json +5 -1
@@ -0,0 +1,158 @@
1
+ /** @typedef {import('./types').OfflineStreamObject} OfflineStreamObject */
2
+ /** @typedef {import('./types').OfflineStreamHandle} OfflineStreamHandle */
3
+ /** @typedef {import('./types').OfflineRecognizerHandle} OfflineRecognizerHandle */
4
+ /** @typedef {import('./types').Waveform} Waveform */
5
+ /**
6
+ * @typedef {import('./types').OfflineRecognizerConfig} OfflineRecognizerConfig
7
+ */
8
+ /**
9
+ * @typedef {import('./types').OfflineRecognizerResult} OfflineRecognizerResult
10
+ */
11
+
12
+ const addon = require('./addon.js');
13
+
14
+ /**
15
+ * Internal symbol to mark async-created recognizers.
16
+ * Not accessible unless someone has a reference to this Symbol.
17
+ */
18
+ const kFromAsyncFactory = Symbol('OfflineRecognizer.fromAsync');
19
+
20
+ /**
21
+ * OfflineStream represents a synchronous offline audio stream.
22
+ */
23
+ class OfflineStream {
24
+ /**
25
+ * @param {OfflineStreamObject|Object} handle
26
+ */
27
+ constructor(handle) {
28
+ this.handle = handle;
29
+ }
30
+
31
+ /**
32
+ * Accept a chunk of waveform samples.
33
+ * @param {Waveform} obj - { samples: Float32Array, sampleRate: number }
34
+ */
35
+ acceptWaveform(obj) {
36
+ addon.acceptWaveformOffline(this.handle, obj);
37
+ }
38
+
39
+ /**
40
+ * Set a string option on the underlying offline stream.
41
+ * @param {string} key
42
+ * @param {string} value
43
+ */
44
+ setOption(key, value) {
45
+ addon.offlineStreamSetOption(this.handle, key, value);
46
+ }
47
+ }
48
+
49
+ /**
50
+ * OfflineRecognizer wraps the native offline recognizer.
51
+ */
52
+ class OfflineRecognizer {
53
+ /**
54
+ * Constructor (SYNC path).
55
+ *
56
+ * Users call:
57
+ * new OfflineRecognizer(config)
58
+ *
59
+ * Async factory calls this with an internal descriptor.
60
+ *
61
+ * @param {OfflineRecognizerConfig | Object} configOrInternal
62
+ */
63
+ constructor(configOrInternal) {
64
+ // ----- async factory path -----
65
+ if (configOrInternal && typeof configOrInternal === 'object' &&
66
+ configOrInternal[kFromAsyncFactory]) {
67
+ this.handle = configOrInternal.handle;
68
+ this.config = configOrInternal.config;
69
+ return;
70
+ }
71
+
72
+ // ----- sync constructor path -----
73
+ this.config = configOrInternal;
74
+ this.handle = addon.createOfflineRecognizer(this.config);
75
+ }
76
+
77
+ /**
78
+ * Create an OfflineRecognizer asynchronously (non-blocking).
79
+ *
80
+ * @param {OfflineRecognizerConfig} config
81
+ * @returns {Promise<OfflineRecognizer>}
82
+ */
83
+ static async createAsync(config) {
84
+ const handle = await addon.createOfflineRecognizerAsync(config);
85
+
86
+ return new OfflineRecognizer({
87
+ [kFromAsyncFactory]: true,
88
+ handle,
89
+ config,
90
+ });
91
+ }
92
+
93
+ /**
94
+ * Create a new OfflineStream bound to this recognizer.
95
+ *
96
+ * The optional hotwords argument enables contextual biasing for this
97
+ * stream only. Hotwords are supported only by transducer models decoded
98
+ * with decodingMethod 'modified_beam_search'. Separate multiple phrases
99
+ * with '/', and optionally append a per-phrase boosting score, e.g.
100
+ * 'PHOEBE :2.0/DON QUIXOTE'. When modelConfig.modelingUnit and
101
+ * modelConfig.bpeVocab are set, phrases are given as normal words;
102
+ * otherwise each phrase must be a sequence of tokens from tokens.txt
103
+ * separated by spaces. See also
104
+ * https://k2-fsa.github.io/sherpa/onnx/hotwords/index.html
105
+ *
106
+ * @param {string} [hotwords] Optional hotwords for this stream.
107
+ * @returns {OfflineStream}
108
+ */
109
+ createStream(hotwords) {
110
+ const handle = hotwords === undefined ?
111
+ addon.createOfflineStream(this.handle) :
112
+ addon.createOfflineStream(this.handle, hotwords);
113
+ return new OfflineStream(handle);
114
+ }
115
+
116
+ /**
117
+ * Replace the recognizer config at runtime.
118
+ * @param {OfflineRecognizerConfig} config
119
+ */
120
+ setConfig(config) {
121
+ this.config = config;
122
+ addon.offlineRecognizerSetConfig(this.handle, config);
123
+ }
124
+
125
+ /**
126
+ * Decode an offline stream (synchronous).
127
+ * @param {OfflineStream} stream
128
+ */
129
+ decode(stream) {
130
+ addon.decodeOfflineStream(this.handle, stream.handle);
131
+ }
132
+
133
+ /**
134
+ * Decode an offline stream asynchronously (non-blocking).
135
+ * @param {OfflineStream} stream
136
+ * @returns {Promise<OfflineRecognizerResult>}
137
+ */
138
+ async decodeAsync(stream) {
139
+ const jsonStr =
140
+ await addon.decodeOfflineStreamAsync(this.handle, stream.handle);
141
+ return JSON.parse(jsonStr);
142
+ }
143
+
144
+ /**
145
+ * Get recognition result for a stream.
146
+ * @param {OfflineStream} stream
147
+ * @returns {OfflineRecognizerResult}
148
+ */
149
+ getResult(stream) {
150
+ const jsonStr = addon.getOfflineStreamResultAsJson(stream.handle);
151
+ return JSON.parse(jsonStr);
152
+ }
153
+ }
154
+
155
+ module.exports = {
156
+ OfflineRecognizer,
157
+ OfflineStream,
158
+ };
@@ -0,0 +1,38 @@
1
+ /** @typedef {import('./types').OfflineSpeakerDiarizationConfig} OfflineSpeakerDiarizationConfig */
2
+ /** @typedef {import('./types').OfflineSpeakerDiarizationHandle} OfflineSpeakerDiarizationHandle */
3
+ /** @typedef {import('./types').SpeakerDiarizationSegment} SpeakerDiarizationSegment */
4
+
5
+ const addon = require('./addon.js');
6
+
7
+ class OfflineSpeakerDiarization {
8
+ /**
9
+ * @param {OfflineSpeakerDiarizationConfig} config
10
+ */
11
+ constructor(config) {
12
+ this.handle = addon.createOfflineSpeakerDiarization(config);
13
+ this.config = config;
14
+
15
+ this.sampleRate = addon.getOfflineSpeakerDiarizationSampleRate(this.handle);
16
+ }
17
+
18
+ /**
19
+ * @param {Float32Array} samples - 1-D float32 array in [-1, 1]
20
+ * @returns {SpeakerDiarizationSegment[]}
21
+ */
22
+ process(samples) {
23
+ return addon.offlineSpeakerDiarizationProcess(this.handle, samples);
24
+ }
25
+
26
+ /**
27
+ * Set clustering configuration.
28
+ * @param {{clustering: import('./types').FastClusteringConfig}} config
29
+ */
30
+ setConfig(config) {
31
+ addon.offlineSpeakerDiarizationSetConfig(this.handle, config);
32
+ this.config.clustering = config.clustering;
33
+ }
34
+ }
35
+
36
+ module.exports = {
37
+ OfflineSpeakerDiarization,
38
+ }
@@ -0,0 +1,32 @@
1
+ /** @typedef {import('./types').OfflineSpeechDenoiserConfig} OfflineSpeechDenoiserConfig */
2
+ /** @typedef {import('./types').OfflineSpeechDenoiserHandle} OfflineSpeechDenoiserHandle */
3
+ /** @typedef {import('./types').GeneratedAudio} GeneratedAudio */
4
+ /** @typedef {import('./types').AudioProcessRequest} AudioProcessRequest */
5
+
6
+ const addon = require('./addon.js');
7
+
8
+ class OfflineSpeechDenoiser {
9
+ /**
10
+ * @param {OfflineSpeechDenoiserConfig} config
11
+ */
12
+ constructor(config) {
13
+ this.handle = addon.createOfflineSpeechDenoiser(config);
14
+ this.config = config;
15
+
16
+ this.sampleRate =
17
+ addon.offlineSpeechDenoiserGetSampleRateWrapper(this.handle);
18
+ }
19
+
20
+ /**
21
+ * Run denoiser synchronously.
22
+ * @param {AudioProcessRequest} obj - { samples: Float32Array, sampleRate: number, enableExternalBuffer?: boolean }
23
+ * @returns {GeneratedAudio}
24
+ */
25
+ run(obj) {
26
+ return addon.offlineSpeechDenoiserRunWrapper(this.handle, obj);
27
+ }
28
+ }
29
+
30
+ module.exports = {
31
+ OfflineSpeechDenoiser,
32
+ }
@@ -0,0 +1,117 @@
1
+ /** @typedef {import('./types').OfflineTtsConfig} OfflineTtsConfig */
2
+ /** @typedef {import('./types').OfflineTtsHandle} OfflineTtsHandle */
3
+ /** @typedef {import('./types').TtsRequest} TtsRequest */
4
+ /** @typedef {import('./types').GeneratedAudio} GeneratedAudio */
5
+
6
+ const addon = require('./addon.js');
7
+
8
+ /**
9
+ * Internal symbol to mark async-created TTS instances.
10
+ */
11
+ const kFromAsyncFactory = Symbol('OfflineTts.fromAsync');
12
+
13
+
14
+ class GenerationConfig {
15
+ constructor(opts = {}) {
16
+ Object.assign(this, opts);
17
+ }
18
+ }
19
+
20
+
21
+ class OfflineTts {
22
+ /**
23
+ * Constructor (sync path).
24
+ *
25
+ * Users call:
26
+ * new OfflineTts(config)
27
+ *
28
+ * Async factory calls this with an internal descriptor.
29
+ *
30
+ * @param {OfflineTtsConfig|Object} configOrInternal
31
+ */
32
+ constructor(configOrInternal) {
33
+ if (configOrInternal && typeof configOrInternal === 'object' &&
34
+ configOrInternal[kFromAsyncFactory]) {
35
+ // ----- async factory path -----
36
+ this.handle = configOrInternal.handle;
37
+ this.config = configOrInternal.config;
38
+ } else {
39
+ // ----- sync constructor path -----
40
+ this.config = configOrInternal;
41
+ this.handle = addon.createOfflineTts(this.config);
42
+ }
43
+
44
+ // Common initialization
45
+ this.numSpeakers = addon.getOfflineTtsNumSpeakers(this.handle);
46
+ this.sampleRate = addon.getOfflineTtsSampleRate(this.handle);
47
+ this.lang = addon.getOfflineTtsLang(this.handle);
48
+ }
49
+
50
+ /**
51
+ * Create an OfflineTts asynchronously (non-blocking).
52
+ * @param {OfflineTtsConfig} config
53
+ * @returns {Promise<OfflineTts>}
54
+ */
55
+ static async createAsync(config) {
56
+ const handle = await addon.createOfflineTtsAsync(config);
57
+ return new OfflineTts({
58
+ [kFromAsyncFactory]: true,
59
+ handle,
60
+ config,
61
+ });
62
+ }
63
+
64
+ /**
65
+ * Generate audio synchronously.
66
+ * @param {TtsRequest} obj
67
+ * @returns {GeneratedAudio}
68
+ */
69
+ generate(obj) {
70
+ if (!obj || typeof obj !== 'object') {
71
+ throw new TypeError('generate() expects an object');
72
+ }
73
+
74
+ // If generationConfig is present, use new API
75
+ if (obj.generationConfig !== undefined) {
76
+ return addon.offlineTtsGenerateWithConfig(this.handle, obj);
77
+ }
78
+
79
+ // Fallback to legacy path
80
+ return addon.offlineTtsGenerate(this.handle, obj);
81
+ }
82
+ /**
83
+ * Generate audio asynchronously with optional generationConfig and progress
84
+ * callback
85
+ *
86
+ * The progress callback receives streaming audio chunks.
87
+ *
88
+ * @param {TtsRequest & { generationConfig?: GenerationConfig, onProgress?: (info: {
89
+ * samples: Float32Array, progress: number }) => number | boolean | void
90
+ * }} obj
91
+ * @returns {Promise<GeneratedAudio>}
92
+ */
93
+ generateAsync(obj) {
94
+ const {onProgress, ...rest} = obj;
95
+
96
+ const hasConfig = obj.generationConfig !== undefined;
97
+
98
+ const fn = hasConfig ? addon.offlineTtsGenerateAsyncWithConfig :
99
+ addon.offlineTtsGenerateAsync;
100
+
101
+ return fn(this.handle, {
102
+ ...rest,
103
+ callback: typeof onProgress === 'function' ?
104
+ (info) => {
105
+ const ret = onProgress(info);
106
+ return ret === 0 || ret === false ? 0 : 1;
107
+ } :
108
+ undefined,
109
+ });
110
+ }
111
+ }
112
+
113
+
114
+ module.exports = {
115
+ OfflineTts,
116
+ GenerationConfig,
117
+ }
@@ -0,0 +1,46 @@
1
+ /** @typedef {import('./types').OnlineSpeechDenoiserConfig} OnlineSpeechDenoiserConfig */
2
+ /** @typedef {import('./types').OnlineSpeechDenoiserHandle} OnlineSpeechDenoiserHandle */
3
+ /** @typedef {import('./types').GeneratedAudio} GeneratedAudio */
4
+ /** @typedef {import('./types').AudioProcessRequest} AudioProcessRequest */
5
+
6
+ const addon = require('./addon.js');
7
+
8
+ class OnlineSpeechDenoiser {
9
+ /**
10
+ * @param {OnlineSpeechDenoiserConfig} config
11
+ */
12
+ constructor(config) {
13
+ this.handle = addon.createOnlineSpeechDenoiser(config);
14
+ this.config = config;
15
+
16
+ this.sampleRate =
17
+ addon.onlineSpeechDenoiserGetSampleRateWrapper(this.handle);
18
+ this.frameShiftInSamples =
19
+ addon.onlineSpeechDenoiserGetFrameShiftInSamplesWrapper(this.handle);
20
+ }
21
+
22
+ /**
23
+ * @param {AudioProcessRequest} obj
24
+ * @returns {GeneratedAudio}
25
+ */
26
+ run(obj) {
27
+ return addon.onlineSpeechDenoiserRunWrapper(this.handle, obj);
28
+ }
29
+
30
+ /**
31
+ * @param {boolean} [enableExternalBuffer=true]
32
+ * @returns {GeneratedAudio}
33
+ */
34
+ flush(enableExternalBuffer = true) {
35
+ return addon.onlineSpeechDenoiserFlushWrapper(
36
+ this.handle, enableExternalBuffer);
37
+ }
38
+
39
+ reset() {
40
+ addon.onlineSpeechDenoiserResetWrapper(this.handle);
41
+ }
42
+ }
43
+
44
+ module.exports = {
45
+ OnlineSpeechDenoiser,
46
+ };
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "sherpa-onnx-node",
3
+ "version": "2.0.1",
4
+ "description": "Speech-to-text, text-to-speech, speaker diarization, and speech enhancement using Next-gen Kaldi without internet connection",
5
+ "main": "sherpa-onnx.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/csukuangfj/sherpa-onnx.git"
12
+ },
13
+ "keywords": [
14
+ "speech to text",
15
+ "text to speech",
16
+ "transcription",
17
+ "real-time speech recognition",
18
+ "without internet connection",
19
+ "locally",
20
+ "local",
21
+ "embedded systems",
22
+ "open source",
23
+ "diarization",
24
+ "speaker diarization",
25
+ "speaker recognition",
26
+ "speaker",
27
+ "speaker segmentation",
28
+ "speaker verification",
29
+ "spoken language identification",
30
+ "sherpa",
31
+ "zipformer",
32
+ "asr",
33
+ "tts",
34
+ "stt",
35
+ "c++",
36
+ "onnxruntime",
37
+ "onnx",
38
+ "ai",
39
+ "next-gen kaldi",
40
+ "offline",
41
+ "privacy",
42
+ "open source",
43
+ "streaming speech recognition",
44
+ "speech",
45
+ "recognition",
46
+ "vad",
47
+ "node-addon-api",
48
+ "speaker id",
49
+ "language id",
50
+ "speech enhancement",
51
+ "denoising"
52
+ ],
53
+ "author": "The next-gen Kaldi team",
54
+ "license": "Apache-2.0",
55
+ "bugs": {
56
+ "url": "https://github.com/csukuangfj/sherpa-onnx/issues"
57
+ },
58
+ "homepage": "https://github.com/csukuangfj/sherpa-onnx#readme",
59
+ "optionalDependencies": {
60
+ "sherpa-onnx-darwin-arm64": "2.0.1",
61
+ "sherpa-onnx-darwin-x64": "2.0.1",
62
+ "sherpa-onnx-linux-x64": "2.0.1",
63
+ "sherpa-onnx-linux-arm64": "2.0.1",
64
+ "sherpa-onnx-win-x64": "2.0.1",
65
+ "sherpa-onnx-win-arm64": "2.0.1",
66
+ "sherpa-onnx-win-ia32": "2.0.1"
67
+ }
68
+ }
@@ -0,0 +1,43 @@
1
+ /** @typedef {import('./types').OfflinePunctuationHandle} OfflinePunctuationHandle */
2
+ /** @typedef {import('./types').OfflinePunctuationConfig} OfflinePunctuationConfig */
3
+ /** @typedef {import('./types').OnlinePunctuationConfig} OnlinePunctuationConfig */
4
+ /** @typedef {import('./types').OnlinePunctuationHandle} OnlinePunctuationHandle */
5
+
6
+ const addon = require('./addon.js');
7
+
8
+ class OfflinePunctuation {
9
+ /**
10
+ * @param {OfflinePunctuationConfig} config
11
+ */
12
+ constructor(config) {
13
+ this.handle = addon.createOfflinePunctuation(config);
14
+ this.config = config;
15
+ }
16
+ /**
17
+ * Add punctuation to `text` and return the punctuated text.
18
+ * @param {string} text
19
+ * @returns {string}
20
+ */
21
+ addPunct(text) {
22
+ return addon.offlinePunctuationAddPunct(this.handle, text);
23
+ }
24
+ }
25
+
26
+ class OnlinePunctuation {
27
+ /**
28
+ * @param {OnlinePunctuationConfig} config
29
+ */
30
+ constructor(config) {
31
+ this.handle = addon.createOnlinePunctuation(config);
32
+ this.config = config;
33
+ }
34
+ /** @param {string} text @returns {string} */
35
+ addPunct(text) {
36
+ return addon.onlinePunctuationAddPunct(this.handle, text);
37
+ }
38
+ }
39
+
40
+ module.exports = {
41
+ OfflinePunctuation,
42
+ OnlinePunctuation,
43
+ }
@@ -0,0 +1,80 @@
1
+ /** @typedef {import('./types').LinearResamplerHandle} LinearResamplerHandle */
2
+
3
+ const addon = require('./addon.js');
4
+
5
+ /**
6
+ * A linear resampler that converts audio from one sample rate to another.
7
+ */
8
+ class LinearResampler {
9
+ /**
10
+ * Create a linear resampler.
11
+ *
12
+ * @param {number} inputSampleRate - Input sample rate in Hz.
13
+ * @param {number} outputSampleRate - Output sample rate in Hz.
14
+ */
15
+ constructor(inputSampleRate, outputSampleRate) {
16
+ /** @type {LinearResamplerHandle} */
17
+ this.handle =
18
+ addon.createLinearResampler(inputSampleRate, outputSampleRate);
19
+ this.inputSampleRate = inputSampleRate;
20
+ this.outputSampleRate = outputSampleRate;
21
+ }
22
+
23
+ /**
24
+ * Resample a chunk of audio samples.
25
+ *
26
+ * Call this for each chunk of input audio. For the final chunk, call
27
+ * {@link flush} instead so that any internally buffered samples are
28
+ * emitted.
29
+ *
30
+ * @param {Float32Array} samples - Input audio samples.
31
+ * @returns {Float32Array} Resampled audio samples.
32
+ */
33
+ resample(samples) {
34
+ return addon.resampleLinear(this.handle, samples, 0);
35
+ }
36
+
37
+ /**
38
+ * Resample the final chunk of audio and flush internal buffers.
39
+ *
40
+ * This is the same as {@link resample} but sets flush=1 so that any
41
+ * remaining samples buffered inside the resampler are emitted. Call
42
+ * this once after the last chunk of input audio.
43
+ *
44
+ * @param {Float32Array} samples - The final chunk of input audio samples.
45
+ * @returns {Float32Array} Resampled audio samples including buffered tail.
46
+ */
47
+ flush(samples) {
48
+ return addon.resampleLinear(this.handle, samples, 1);
49
+ }
50
+
51
+ /**
52
+ * Reset the resampler to its initial state, discarding any internal
53
+ * buffered samples.
54
+ */
55
+ reset() {
56
+ addon.linearResamplerReset(this.handle);
57
+ }
58
+
59
+ /**
60
+ * Get the input sample rate.
61
+ *
62
+ * @returns {number} Input sample rate in Hz.
63
+ */
64
+ getInputSampleRate() {
65
+ return addon.linearResamplerGetInputSampleRate(this.handle);
66
+ }
67
+
68
+ /**
69
+ * Get the output sample rate.
70
+ *
71
+ * @returns {number} Output sample rate in Hz.
72
+ */
73
+ getOutputSampleRate() {
74
+ return addon.linearResamplerGetOutputSampleRate(this.handle);
75
+ }
76
+ }
77
+
78
+ module.exports = {
79
+ LinearResampler,
80
+ }
@@ -0,0 +1,49 @@
1
+ /** @typedef {import('./types').WaveObject} WaveObject */
2
+ /**
3
+ * @typedef {import('./types').OnlineRecognizerResult} OnlineRecognizerResult
4
+ */
5
+ /**
6
+ * @typedef {import('./types').OfflineRecognizerResult} OfflineRecognizerResult
7
+ */
8
+
9
+ const addon = require('./addon.js')
10
+ const streaming_asr = require('./streaming-asr.js');
11
+ const non_streaming_asr = require('./non-streaming-asr.js');
12
+ const non_streaming_tts = require('./non-streaming-tts.js');
13
+ const vad = require('./vad.js');
14
+ const slid = require('./spoken-language-identification.js');
15
+ const sid = require('./speaker-identification.js');
16
+ const at = require('./audio-tagg.js');
17
+ const punct = require('./punctuation.js');
18
+ const kws = require('./keyword-spotter.js');
19
+ const sd = require('./non-streaming-speaker-diarization.js');
20
+ const speech_denoiser = require('./non-streaming-speech-denoiser.js');
21
+ const online_speech_denoiser = require('./online-speech-denoiser.js');
22
+ const resampler = require('./resampler.js');
23
+
24
+ module.exports = {
25
+ OnlineRecognizer : streaming_asr.OnlineRecognizer,
26
+ OfflineRecognizer : non_streaming_asr.OfflineRecognizer,
27
+ OfflineTts : non_streaming_tts.OfflineTts,
28
+ GenerationConfig : non_streaming_tts.GenerationConfig,
29
+ readWave : addon.readWave,
30
+ writeWave : addon.writeWave,
31
+ Display : streaming_asr.Display,
32
+ Vad : vad.Vad,
33
+ CircularBuffer : vad.CircularBuffer,
34
+ SpokenLanguageIdentification : slid.SpokenLanguageIdentification,
35
+ SpeakerEmbeddingExtractor : sid.SpeakerEmbeddingExtractor,
36
+ SpeakerEmbeddingManager : sid.SpeakerEmbeddingManager,
37
+ AudioTagging : at.AudioTagging,
38
+ OfflinePunctuation : punct.OfflinePunctuation,
39
+ OnlinePunctuation : punct.OnlinePunctuation,
40
+ KeywordSpotter : kws.KeywordSpotter,
41
+ OfflineSpeakerDiarization : sd.OfflineSpeakerDiarization,
42
+ OfflineSpeechDenoiser : speech_denoiser.OfflineSpeechDenoiser,
43
+ OnlineSpeechDenoiser : online_speech_denoiser.OnlineSpeechDenoiser,
44
+ LinearResampler : resampler.LinearResampler,
45
+ version : addon.version,
46
+ gitSha1 : addon.gitSha1,
47
+ gitDate : addon.gitDate,
48
+ onnxruntimeVersion : addon.onnxruntimeVersion,
49
+ }