@xrkseek/harness 0.7.7 → 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.
- package/node_modules/@xrkseek/exec-voice/dist/download-http.d.ts +25 -6
- package/node_modules/@xrkseek/exec-voice/dist/download-http.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-voice/dist/download-http.js +55 -11
- package/node_modules/@xrkseek/exec-voice/dist/download-http.js.map +1 -1
- package/node_modules/@xrkseek/exec-voice/dist/index.d.ts +1 -0
- package/node_modules/@xrkseek/exec-voice/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-voice/dist/index.js +1 -0
- package/node_modules/@xrkseek/exec-voice/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/exec-voice/dist/sensevoice-runtime.d.ts +3 -1
- package/node_modules/@xrkseek/exec-voice/dist/sensevoice-runtime.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-voice/dist/sensevoice-runtime.js +18 -1
- package/node_modules/@xrkseek/exec-voice/dist/sensevoice-runtime.js.map +1 -1
- package/node_modules/@xrkseek/exec-voice/package.json +3 -0
- package/node_modules/@xrkseek/preset-harness/dist/tsconfig.tsbuildinfo +1 -1
- package/node_modules/@xrkseek/server-face/dist/handlers/voice.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/handlers/voice.js +16 -2
- package/node_modules/@xrkseek/server-face/dist/handlers/voice.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/session-posture.js +1 -1
- package/node_modules/@xrkseek/server-face/dist/session-posture.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/settings-schemas.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/settings-schemas.js +8 -0
- package/node_modules/@xrkseek/server-face/dist/settings-schemas.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/workspace-orchestrate-tools.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/workspace-orchestrate-tools.js +4 -1
- package/node_modules/@xrkseek/server-face/dist/workspace-orchestrate-tools.js.map +1 -1
- package/node_modules/sherpa-onnx-node/README.md +11 -0
- package/node_modules/sherpa-onnx-node/addon-static-import.js +76 -0
- package/node_modules/sherpa-onnx-node/addon.js +98 -0
- package/node_modules/sherpa-onnx-node/audio-tagg.js +45 -0
- package/node_modules/sherpa-onnx-node/keyword-spotter.js +68 -0
- package/node_modules/sherpa-onnx-node/non-streaming-asr.js +158 -0
- package/node_modules/sherpa-onnx-node/non-streaming-speaker-diarization.js +38 -0
- package/node_modules/sherpa-onnx-node/non-streaming-speech-denoiser.js +32 -0
- package/node_modules/sherpa-onnx-node/non-streaming-tts.js +117 -0
- package/node_modules/sherpa-onnx-node/online-speech-denoiser.js +46 -0
- package/node_modules/sherpa-onnx-node/package.json +68 -0
- package/node_modules/sherpa-onnx-node/punctuation.js +43 -0
- package/node_modules/sherpa-onnx-node/resampler.js +80 -0
- package/node_modules/sherpa-onnx-node/sherpa-onnx.js +49 -0
- package/node_modules/sherpa-onnx-node/speaker-identification.js +152 -0
- package/node_modules/sherpa-onnx-node/spoken-language-identification.js +38 -0
- package/node_modules/sherpa-onnx-node/streaming-asr.js +181 -0
- package/node_modules/sherpa-onnx-node/types.js +833 -0
- package/node_modules/sherpa-onnx-node/vad.js +134 -0
- package/node_modules/sherpa-onnx-win-x64/README.md +3 -0
- package/node_modules/sherpa-onnx-win-x64/index.js +1 -0
- package/node_modules/sherpa-onnx-win-x64/onnxruntime.dll +0 -0
- package/node_modules/sherpa-onnx-win-x64/onnxruntime_providers_shared.dll +0 -0
- package/node_modules/sherpa-onnx-win-x64/package.json +65 -0
- package/node_modules/sherpa-onnx-win-x64/sherpa-onnx-c-api.dll +0 -0
- package/node_modules/sherpa-onnx-win-x64/sherpa-onnx-cxx-api.dll +0 -0
- package/node_modules/sherpa-onnx-win-x64/sherpa-onnx.node +0 -0
- package/package.json +5 -1
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/** @typedef {import('./types').SpeakerEmbeddingEntry} SpeakerEmbeddingEntry */
|
|
2
|
+
/** @typedef {import('./types').SpeakerEmbeddingManagerSearchObj} SpeakerEmbeddingManagerSearchObj */
|
|
3
|
+
/** @typedef {import('./types').SpeakerEmbeddingManagerVerifyObj} SpeakerEmbeddingManagerVerifyObj */
|
|
4
|
+
/** @typedef {import('./types').SpeakerEmbeddingExtractorConfig} SpeakerEmbeddingExtractorConfig */
|
|
5
|
+
/** @typedef {import('./types').SpeakerEmbeddingExtractorHandle} SpeakerEmbeddingExtractorHandle */
|
|
6
|
+
/** @typedef {import('./types').SpeakerEmbeddingManagerHandle} SpeakerEmbeddingManagerHandle */
|
|
7
|
+
/** @typedef {import('./streaming-asr').OnlineStream} OnlineStream */
|
|
8
|
+
|
|
9
|
+
const addon = require('./addon.js');
|
|
10
|
+
const streaming_asr = require('./streaming-asr.js');
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* SpeakerEmbeddingExtractor wraps native speaker embedding extractor.
|
|
14
|
+
*/
|
|
15
|
+
class SpeakerEmbeddingExtractor {
|
|
16
|
+
/**
|
|
17
|
+
* @param {SpeakerEmbeddingExtractorConfig} config
|
|
18
|
+
*/
|
|
19
|
+
constructor(config) {
|
|
20
|
+
this.handle = addon.createSpeakerEmbeddingExtractor(config);
|
|
21
|
+
this.config = config;
|
|
22
|
+
this.dim = addon.speakerEmbeddingExtractorDim(this.handle);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @returns {OnlineStream}
|
|
27
|
+
*/
|
|
28
|
+
createStream() {
|
|
29
|
+
return new streaming_asr.OnlineStream(
|
|
30
|
+
addon.speakerEmbeddingExtractorCreateStream(this.handle));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @param {OnlineStream} stream
|
|
35
|
+
* @returns {boolean}
|
|
36
|
+
*/
|
|
37
|
+
isReady(stream) {
|
|
38
|
+
return addon.speakerEmbeddingExtractorIsReady(this.handle, stream.handle);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Compute embedding and return a Float32Array
|
|
43
|
+
* @param {OnlineStream} stream
|
|
44
|
+
* @param {boolean} [enableExternalBuffer=true]
|
|
45
|
+
* @returns {Float32Array}
|
|
46
|
+
*/
|
|
47
|
+
compute(stream, enableExternalBuffer = true) {
|
|
48
|
+
return addon.speakerEmbeddingExtractorComputeEmbedding(
|
|
49
|
+
this.handle, stream.handle, enableExternalBuffer);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Flattens an array of Float32Arrays into a single Float32Array.
|
|
55
|
+
* @param {Float32Array[]} arrayList
|
|
56
|
+
* @returns {Float32Array}
|
|
57
|
+
*/
|
|
58
|
+
function flatten(arrayList) {
|
|
59
|
+
let n = 0;
|
|
60
|
+
for (let i = 0; i < arrayList.length; ++i) {
|
|
61
|
+
n += arrayList[i].length;
|
|
62
|
+
}
|
|
63
|
+
let ans = new Float32Array(n);
|
|
64
|
+
|
|
65
|
+
let offset = 0;
|
|
66
|
+
for (let i = 0; i < arrayList.length; ++i) {
|
|
67
|
+
ans.set(arrayList[i], offset);
|
|
68
|
+
offset += arrayList[i].length;
|
|
69
|
+
}
|
|
70
|
+
return ans;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Manager for speaker embeddings.
|
|
75
|
+
*/
|
|
76
|
+
class SpeakerEmbeddingManager {
|
|
77
|
+
/**
|
|
78
|
+
* @param {number} dim - The embedding dimension
|
|
79
|
+
*/
|
|
80
|
+
constructor(dim) {
|
|
81
|
+
this.handle = addon.createSpeakerEmbeddingManager(dim);
|
|
82
|
+
this.dim = dim;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @param {SpeakerEmbeddingEntry} obj
|
|
87
|
+
* @returns {boolean}
|
|
88
|
+
*/
|
|
89
|
+
add(obj) {
|
|
90
|
+
return addon.speakerEmbeddingManagerAdd(this.handle, obj);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @param {{name:string, v: Float32Array[]}} obj
|
|
95
|
+
* @returns {boolean}
|
|
96
|
+
*/
|
|
97
|
+
addMulti(obj) {
|
|
98
|
+
const c = {
|
|
99
|
+
name: obj.name,
|
|
100
|
+
vv: flatten(obj.v),
|
|
101
|
+
n: obj.v.length,
|
|
102
|
+
};
|
|
103
|
+
return addon.speakerEmbeddingManagerAddListFlattened(this.handle, c);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* @param {string} name
|
|
108
|
+
* @returns {boolean}
|
|
109
|
+
*/
|
|
110
|
+
remove(name) {
|
|
111
|
+
return addon.speakerEmbeddingManagerRemove(this.handle, name);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* @param {SpeakerEmbeddingManagerSearchObj} obj
|
|
116
|
+
* @returns {string}
|
|
117
|
+
*/
|
|
118
|
+
search(obj) {
|
|
119
|
+
return addon.speakerEmbeddingManagerSearch(this.handle, obj);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* @param {SpeakerEmbeddingManagerVerifyObj} obj
|
|
124
|
+
* @returns {boolean}
|
|
125
|
+
*/
|
|
126
|
+
verify(obj) {
|
|
127
|
+
return addon.speakerEmbeddingManagerVerify(this.handle, obj);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* @param {string} name
|
|
132
|
+
* @returns {boolean}
|
|
133
|
+
*/
|
|
134
|
+
contains(name) {
|
|
135
|
+
return addon.speakerEmbeddingManagerContains(this.handle, name);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** @returns {number} */
|
|
139
|
+
getNumSpeakers() {
|
|
140
|
+
return addon.speakerEmbeddingManagerNumSpeakers(this.handle);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** @returns {string[]} */
|
|
144
|
+
getAllSpeakerNames() {
|
|
145
|
+
return addon.speakerEmbeddingManagerGetAllSpeakers(this.handle);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
module.exports = {
|
|
150
|
+
SpeakerEmbeddingExtractor,
|
|
151
|
+
SpeakerEmbeddingManager,
|
|
152
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** @typedef {import('./types').SpokenLanguageIdentificationConfig} SpokenLanguageIdentificationConfig */
|
|
2
|
+
/** @typedef {import('./types').SpokenLanguageIdentificationHandle} SpokenLanguageIdentificationHandle */
|
|
3
|
+
/** @typedef {import('./non-streaming-asr').OfflineStream} OfflineStream */
|
|
4
|
+
|
|
5
|
+
const addon = require('./addon.js');
|
|
6
|
+
const non_streaming_asr = require('./non-streaming-asr.js');
|
|
7
|
+
|
|
8
|
+
class SpokenLanguageIdentification {
|
|
9
|
+
/**
|
|
10
|
+
* @param {SpokenLanguageIdentificationConfig} config
|
|
11
|
+
*/
|
|
12
|
+
constructor(config) {
|
|
13
|
+
this.handle = addon.createSpokenLanguageIdentification(config);
|
|
14
|
+
this.config = config;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @returns {OfflineStream}
|
|
19
|
+
*/
|
|
20
|
+
createStream() {
|
|
21
|
+
return new non_streaming_asr.OfflineStream(
|
|
22
|
+
addon.createSpokenLanguageIdentificationOfflineStream(this.handle));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Return a 2-letter language code, e.g. 'en', 'de', 'fr', 'es', 'zh'
|
|
27
|
+
* @param {OfflineStream} stream
|
|
28
|
+
* @returns {string}
|
|
29
|
+
*/
|
|
30
|
+
compute(stream) {
|
|
31
|
+
return addon.spokenLanguageIdentificationCompute(
|
|
32
|
+
this.handle, stream.handle);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
module.exports = {
|
|
37
|
+
SpokenLanguageIdentification,
|
|
38
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/** @typedef {import('./types').OnlineStreamObject} OnlineStreamObject */
|
|
2
|
+
/** @typedef {import('./types').OnlineRecognizerHandle} OnlineRecognizerHandle */
|
|
3
|
+
/** @typedef {import('./types').OnlineStreamHandle} OnlineStreamHandle */
|
|
4
|
+
/** @typedef {import('./types').DisplayHandle} DisplayHandle */
|
|
5
|
+
/** @typedef {import('./types').DisplayObject} DisplayObject */
|
|
6
|
+
/** @typedef {import('./types').OnlineRecognizerConfig} OnlineRecognizerConfig */
|
|
7
|
+
/** @typedef {import('./types').Waveform} Waveform */
|
|
8
|
+
/** @typedef {import('./types').OnlineRecognizerResult} OnlineRecognizerResult */
|
|
9
|
+
|
|
10
|
+
const addon = require('./addon.js');
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Display helper for printing recognized words.
|
|
14
|
+
*/
|
|
15
|
+
class Display {
|
|
16
|
+
/**
|
|
17
|
+
* @param {number} maxWordPerline
|
|
18
|
+
*/
|
|
19
|
+
constructor(maxWordPerline) {
|
|
20
|
+
this.handle = addon.createDisplay(maxWordPerline);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Print text to display.
|
|
25
|
+
* @param {number} idx
|
|
26
|
+
* @param {string} text
|
|
27
|
+
*/
|
|
28
|
+
print(idx, text) {
|
|
29
|
+
addon.print(this.handle, idx, text)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* OnlineStream holds an active online stream handle.
|
|
35
|
+
*/
|
|
36
|
+
class OnlineStream {
|
|
37
|
+
/**
|
|
38
|
+
* @param {OnlineStreamObject|Object} handle - object with `handle` property
|
|
39
|
+
*/
|
|
40
|
+
constructor(handle) {
|
|
41
|
+
this.handle = handle;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Accept waveform data
|
|
46
|
+
* @param {Waveform} obj - { samples: Float32Array, sampleRate: number }
|
|
47
|
+
*/
|
|
48
|
+
acceptWaveform(obj) {
|
|
49
|
+
addon.acceptWaveformOnline(this.handle, obj)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Notify the stream input has finished. */
|
|
53
|
+
inputFinished() {
|
|
54
|
+
addon.inputFinished(this.handle)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Set a string option on the underlying online stream.
|
|
59
|
+
*
|
|
60
|
+
* For example, multilingual streaming Nemotron models read the option
|
|
61
|
+
* 'language' (e.g. 'en', 'de') from each stream on every decode call;
|
|
62
|
+
* leaving it unset selects automatic language detection.
|
|
63
|
+
* @param {string} key
|
|
64
|
+
* @param {string} value
|
|
65
|
+
*/
|
|
66
|
+
setOption(key, value) {
|
|
67
|
+
addon.onlineStreamSetOption(this.handle, key, value);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Get a string option of the underlying online stream.
|
|
72
|
+
*
|
|
73
|
+
* Returns an empty string if the option has not been set; use hasOption()
|
|
74
|
+
* to distinguish an unset option from an empty value.
|
|
75
|
+
* @param {string} key
|
|
76
|
+
* @returns {string}
|
|
77
|
+
*/
|
|
78
|
+
getOption(key) {
|
|
79
|
+
return addon.onlineStreamGetOption(this.handle, key);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Check whether an option has been set on the underlying online stream.
|
|
84
|
+
* @param {string} key
|
|
85
|
+
* @returns {boolean}
|
|
86
|
+
*/
|
|
87
|
+
hasOption(key) {
|
|
88
|
+
return addon.onlineStreamHasOption(this.handle, key);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* OnlineRecognizer wraps native online recognizer.
|
|
94
|
+
*/
|
|
95
|
+
class OnlineRecognizer {
|
|
96
|
+
/**
|
|
97
|
+
* @param {OnlineRecognizerConfig} config - online recognizer config (see C++ for fields)
|
|
98
|
+
*/
|
|
99
|
+
constructor(config) {
|
|
100
|
+
this.handle = addon.createOnlineRecognizer(config);
|
|
101
|
+
this.config = config
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Create a new OnlineStream.
|
|
106
|
+
* @returns {OnlineStream}
|
|
107
|
+
*/
|
|
108
|
+
createStream() {
|
|
109
|
+
const handle = addon.createOnlineStream(this.handle);
|
|
110
|
+
return new OnlineStream(handle);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Check whether a stream is ready.
|
|
115
|
+
* @param {OnlineStream} stream
|
|
116
|
+
* @returns {boolean}
|
|
117
|
+
*/
|
|
118
|
+
isReady(stream) {
|
|
119
|
+
return addon.isOnlineStreamReady(this.handle, stream.handle);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Trigger decoding on a stream.
|
|
124
|
+
* @param {OnlineStream} stream
|
|
125
|
+
*/
|
|
126
|
+
decode(stream) {
|
|
127
|
+
addon.decodeOnlineStream(this.handle, stream.handle);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Decode multiple streams of this recognizer in parallel.
|
|
132
|
+
*
|
|
133
|
+
* The caller must ensure every stream in the array is ready for decoding,
|
|
134
|
+
* i.e. isReady() returns true for each of them.
|
|
135
|
+
* @param {OnlineStream[]} streams
|
|
136
|
+
*/
|
|
137
|
+
decodeStreams(streams) {
|
|
138
|
+
const handles = streams.map((stream) => {
|
|
139
|
+
if (!(stream instanceof OnlineStream)) {
|
|
140
|
+
throw new TypeError('Every element should be an OnlineStream');
|
|
141
|
+
}
|
|
142
|
+
return stream.handle;
|
|
143
|
+
});
|
|
144
|
+
addon.decodeMultipleOnlineStreams(this.handle, handles);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Check endpoint condition for a stream.
|
|
149
|
+
* @param {OnlineStream} stream
|
|
150
|
+
* @returns {boolean}
|
|
151
|
+
*/
|
|
152
|
+
isEndpoint(stream) {
|
|
153
|
+
return addon.isEndpoint(this.handle, stream.handle);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Reset a stream.
|
|
158
|
+
* @param {OnlineStream} stream
|
|
159
|
+
*/
|
|
160
|
+
reset(stream) {
|
|
161
|
+
addon.reset(this.handle, stream.handle);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Get recognition result for a stream.
|
|
166
|
+
* @param {OnlineStream} stream
|
|
167
|
+
* @returns {OnlineRecognizerResult}
|
|
168
|
+
*/
|
|
169
|
+
getResult(stream) {
|
|
170
|
+
const jsonStr =
|
|
171
|
+
addon.getOnlineStreamResultAsJson(this.handle, stream.handle);
|
|
172
|
+
|
|
173
|
+
return JSON.parse(jsonStr);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
module.exports = {
|
|
178
|
+
OnlineRecognizer,
|
|
179
|
+
OnlineStream,
|
|
180
|
+
Display
|
|
181
|
+
}
|