csukuangfj commited on
Commit
933cae2
1 Parent(s): bb28fe0

update model

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ *.data filter=lfs diff=lfs merge=lfs -text
app-vad-asr.js ADDED
@@ -0,0 +1,389 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This file copies and modifies code
2
+ // from https://mdn.github.io/web-dictaphone/scripts/app.js
3
+ // and https://gist.github.com/meziantou/edb7217fddfbb70e899e
4
+
5
+ const startBtn = document.getElementById('startBtn');
6
+ const stopBtn = document.getElementById('stopBtn');
7
+ const clearBtn = document.getElementById('clearBtn');
8
+ const hint = document.getElementById('hint');
9
+ const soundClips = document.getElementById('sound-clips');
10
+
11
+ let textArea = document.getElementById('results');
12
+
13
+ let lastResult = '';
14
+ let resultList = [];
15
+
16
+ clearBtn.onclick = function() {
17
+ resultList = [];
18
+ textArea.value = getDisplayResult();
19
+ textArea.scrollTop = textArea.scrollHeight; // auto scroll
20
+ };
21
+
22
+ function getDisplayResult() {
23
+ let i = 0;
24
+ let ans = '';
25
+ for (let s in resultList) {
26
+ if (resultList[s] == '') {
27
+ continue;
28
+ }
29
+
30
+ if (resultList[s] == 'Speech detected') {
31
+ ans += '' + i + ': ' + resultList[s];
32
+ i += 1;
33
+ } else {
34
+ ans += ', ' + resultList[s] + '\n';
35
+ }
36
+ }
37
+
38
+ if (lastResult.length > 0) {
39
+ ans += '' + i + ': ' + lastResult + '\n';
40
+ }
41
+ return ans;
42
+ }
43
+
44
+
45
+
46
+ Module = {};
47
+
48
+ let audioCtx;
49
+ let mediaStream;
50
+
51
+ let expectedSampleRate = 16000;
52
+ let recordSampleRate; // the sampleRate of the microphone
53
+ let recorder = null; // the microphone
54
+ let leftchannel = []; // TODO: Use a single channel
55
+
56
+ let recordingLength = 0; // number of samples so far
57
+
58
+ let vad = null;
59
+ let buffer = null;
60
+ let recognizer = null;
61
+ let printed = false;
62
+
63
+ function fileExists(filename) {
64
+ const filenameLen = Module.lengthBytesUTF8(filename) + 1;
65
+ const buffer = Module._malloc(filenameLen);
66
+ Module.stringToUTF8(filename, buffer, filenameLen);
67
+
68
+ let exists = Module._SherpaOnnxFileExists(buffer);
69
+
70
+ Module._free(buffer);
71
+
72
+ return exists;
73
+ }
74
+
75
+ function createOfflineRecognizerSenseVoice() {}
76
+
77
+ function initOfflineRecognizer() {
78
+ let config = {
79
+ modelConfig: {
80
+ debug: 1,
81
+ tokens: './tokens.txt',
82
+ },
83
+ };
84
+ if (fileExists('sense-voice.onnx') == 1) {
85
+ config.modelConfig.senseVoice = {
86
+ model: './sense-voice.onnx',
87
+ useInverseTextNormalization: 1,
88
+ };
89
+ } else if (fileExists('whisper-encoder.onnx')) {
90
+ config.modelConfig.whisper = {
91
+ encoder: './whisper-encoder.onnx',
92
+ decoder: './whisper-decoder.onnx',
93
+ };
94
+ } else if (fileExists('transducer-encoder.onnx')) {
95
+ config.modelConfig.transducer = {
96
+ encoder: './transducer-encoder.onnx',
97
+ decoder: './transducer-decoder.onnx',
98
+ joiner: './transducer-joiner.onnx',
99
+ };
100
+ config.modelConfig.modelType = 'transducer';
101
+ } else if (fileExists('nemo-transducer-encoder.onnx')) {
102
+ config.modelConfig.transducer = {
103
+ encoder: './nemo-transducer-encoder.onnx',
104
+ decoder: './nemo-transducer-decoder.onnx',
105
+ joiner: './nemo-transducer-joiner.onnx',
106
+ };
107
+ config.modelConfig.modelType = 'nemo_transducer';
108
+ } else if (fileExists('paraformer.onnx')) {
109
+ config.modelConfig.paraformer = {
110
+ model: './paraformer.onnx',
111
+ };
112
+ } else if (fileExists('telespeech.onnx')) {
113
+ config.modelConfig.telespeechCtc = './telespeech.onnx';
114
+ } else {
115
+ console.log('Please specify a model.');
116
+ alert('Please specify a model.');
117
+ }
118
+
119
+ recognizer = new OfflineRecognizer(config, Module);
120
+ }
121
+
122
+ Module.onRuntimeInitialized = function() {
123
+ console.log('inited!');
124
+ hint.innerText = 'Model loaded! Please click start';
125
+
126
+ startBtn.disabled = false;
127
+
128
+ vad = createVad(Module);
129
+ console.log('vad is created!', vad);
130
+
131
+ buffer = new CircularBuffer(30 * 16000, Module);
132
+ console.log('CircularBuffer is created!', buffer);
133
+
134
+ initOfflineRecognizer();
135
+ };
136
+
137
+
138
+
139
+ if (navigator.mediaDevices.getUserMedia) {
140
+ console.log('getUserMedia supported.');
141
+
142
+ // see https://w3c.github.io/mediacapture-main/#dom-mediadevices-getusermedia
143
+ const constraints = {audio: true};
144
+
145
+ let onSuccess = function(stream) {
146
+ if (!audioCtx) {
147
+ audioCtx = new AudioContext({sampleRate: expectedSampleRate});
148
+ }
149
+ console.log(audioCtx);
150
+ recordSampleRate = audioCtx.sampleRate;
151
+ console.log('sample rate ' + recordSampleRate);
152
+
153
+ // creates an audio node from the microphone incoming stream
154
+ mediaStream = audioCtx.createMediaStreamSource(stream);
155
+ console.log('media stream', mediaStream);
156
+
157
+ // https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createScriptProcessor
158
+ // bufferSize: the onaudioprocess event is called when the buffer is full
159
+ var bufferSize = 4096;
160
+ var numberOfInputChannels = 1;
161
+ var numberOfOutputChannels = 2;
162
+ if (audioCtx.createScriptProcessor) {
163
+ recorder = audioCtx.createScriptProcessor(
164
+ bufferSize, numberOfInputChannels, numberOfOutputChannels);
165
+ } else {
166
+ recorder = audioCtx.createJavaScriptNode(
167
+ bufferSize, numberOfInputChannels, numberOfOutputChannels);
168
+ }
169
+ console.log('recorder', recorder);
170
+
171
+ recorder.onaudioprocess = function(e) {
172
+ let samples = new Float32Array(e.inputBuffer.getChannelData(0))
173
+ samples = downsampleBuffer(samples, expectedSampleRate);
174
+ buffer.push(samples);
175
+ while (buffer.size() > vad.config.sileroVad.windowSize) {
176
+ const s = buffer.get(buffer.head(), vad.config.sileroVad.windowSize);
177
+ vad.acceptWaveform(s);
178
+ buffer.pop(vad.config.sileroVad.windowSize);
179
+
180
+ if (vad.isDetected() && !printed) {
181
+ printed = true;
182
+ lastResult = 'Speech detected';
183
+ }
184
+
185
+ if (!vad.isDetected()) {
186
+ printed = false;
187
+ if (lastResult != '') {
188
+ resultList.push(lastResult);
189
+ }
190
+ lastResult = '';
191
+ }
192
+
193
+ while (!vad.isEmpty()) {
194
+ const segment = vad.front();
195
+ const duration = segment.samples.length / expectedSampleRate;
196
+ let durationStr = `Duration: ${duration.toFixed(3)} seconds`;
197
+ vad.pop();
198
+
199
+ // non-streaming asr
200
+ const stream = recognizer.createStream();
201
+ stream.acceptWaveform(expectedSampleRate, segment.samples);
202
+ recognizer.decode(stream);
203
+ let recognitionResult = recognizer.getResult(stream);
204
+ console.log(recognitionResult);
205
+ let text = recognitionResult.text;
206
+ stream.free();
207
+ console.log(text);
208
+
209
+ if (text != '') {
210
+ durationStr += `. Result: ${text}`;
211
+ }
212
+
213
+ resultList.push(durationStr);
214
+
215
+
216
+ // now save the segment to a wav file
217
+ let buf = new Int16Array(segment.samples.length);
218
+ for (var i = 0; i < segment.samples.length; ++i) {
219
+ let s = segment.samples[i];
220
+ if (s >= 1)
221
+ s = 1;
222
+ else if (s <= -1)
223
+ s = -1;
224
+
225
+ buf[i] = s * 32767;
226
+ }
227
+
228
+ let clipName = new Date().toISOString() + '--' + durationStr;
229
+
230
+ const clipContainer = document.createElement('article');
231
+ const clipLabel = document.createElement('p');
232
+ const audio = document.createElement('audio');
233
+ const deleteButton = document.createElement('button');
234
+
235
+ clipContainer.classList.add('clip');
236
+ audio.setAttribute('controls', '');
237
+ deleteButton.textContent = 'Delete';
238
+ deleteButton.className = 'delete';
239
+
240
+ clipLabel.textContent = clipName;
241
+
242
+ clipContainer.appendChild(audio);
243
+
244
+ clipContainer.appendChild(clipLabel);
245
+ clipContainer.appendChild(deleteButton);
246
+ soundClips.appendChild(clipContainer);
247
+
248
+ audio.controls = true;
249
+ const blob = toWav(buf);
250
+
251
+ leftchannel = [];
252
+ const audioURL = window.URL.createObjectURL(blob);
253
+ audio.src = audioURL;
254
+
255
+ deleteButton.onclick = function(e) {
256
+ let evtTgt = e.target;
257
+ evtTgt.parentNode.parentNode.removeChild(evtTgt.parentNode);
258
+ };
259
+
260
+ clipLabel.onclick = function() {
261
+ const existingName = clipLabel.textContent;
262
+ const newClipName = prompt('Enter a new name for your sound clip?');
263
+ if (newClipName === null) {
264
+ clipLabel.textContent = existingName;
265
+ } else {
266
+ clipLabel.textContent = newClipName;
267
+ }
268
+ };
269
+ }
270
+ }
271
+
272
+ textArea.value = getDisplayResult();
273
+ textArea.scrollTop = textArea.scrollHeight; // auto scroll
274
+ };
275
+
276
+ startBtn.onclick = function() {
277
+ mediaStream.connect(recorder);
278
+ recorder.connect(audioCtx.destination);
279
+
280
+ console.log('recorder started');
281
+
282
+ stopBtn.disabled = false;
283
+ startBtn.disabled = true;
284
+ };
285
+
286
+ stopBtn.onclick = function() {
287
+ vad.reset();
288
+ buffer.reset();
289
+ console.log('recorder stopped');
290
+
291
+ // stopBtn recording
292
+ recorder.disconnect(audioCtx.destination);
293
+ mediaStream.disconnect(recorder);
294
+
295
+ startBtn.style.background = '';
296
+ startBtn.style.color = '';
297
+ // mediaRecorder.requestData();
298
+
299
+ stopBtn.disabled = true;
300
+ startBtn.disabled = false;
301
+ };
302
+ };
303
+
304
+ let onError = function(err) {
305
+ console.log('The following error occured: ' + err);
306
+ };
307
+
308
+ navigator.mediaDevices.getUserMedia(constraints).then(onSuccess, onError);
309
+ } else {
310
+ console.log('getUserMedia not supported on your browser!');
311
+ alert('getUserMedia not supported on your browser!');
312
+ }
313
+
314
+
315
+ // this function is copied/modified from
316
+ // https://gist.github.com/meziantou/edb7217fddfbb70e899e
317
+ function flatten(listOfSamples) {
318
+ let n = 0;
319
+ for (let i = 0; i < listOfSamples.length; ++i) {
320
+ n += listOfSamples[i].length;
321
+ }
322
+ let ans = new Int16Array(n);
323
+
324
+ let offset = 0;
325
+ for (let i = 0; i < listOfSamples.length; ++i) {
326
+ ans.set(listOfSamples[i], offset);
327
+ offset += listOfSamples[i].length;
328
+ }
329
+ return ans;
330
+ }
331
+
332
+ // this function is copied/modified from
333
+ // https://gist.github.com/meziantou/edb7217fddfbb70e899e
334
+ function toWav(samples) {
335
+ let buf = new ArrayBuffer(44 + samples.length * 2);
336
+ var view = new DataView(buf);
337
+
338
+ // http://soundfile.sapp.org/doc/WaveFormat/
339
+ // F F I R
340
+ view.setUint32(0, 0x46464952, true); // chunkID
341
+ view.setUint32(4, 36 + samples.length * 2, true); // chunkSize
342
+ // E V A W
343
+ view.setUint32(8, 0x45564157, true); // format
344
+ //
345
+ // t m f
346
+ view.setUint32(12, 0x20746d66, true); // subchunk1ID
347
+ view.setUint32(16, 16, true); // subchunk1Size, 16 for PCM
348
+ view.setUint32(20, 1, true); // audioFormat, 1 for PCM
349
+ view.setUint16(22, 1, true); // numChannels: 1 channel
350
+ view.setUint32(24, expectedSampleRate, true); // sampleRate
351
+ view.setUint32(28, expectedSampleRate * 2, true); // byteRate
352
+ view.setUint16(32, 2, true); // blockAlign
353
+ view.setUint16(34, 16, true); // bitsPerSample
354
+ view.setUint32(36, 0x61746164, true); // Subchunk2ID
355
+ view.setUint32(40, samples.length * 2, true); // subchunk2Size
356
+
357
+ let offset = 44;
358
+ for (let i = 0; i < samples.length; ++i) {
359
+ view.setInt16(offset, samples[i], true);
360
+ offset += 2;
361
+ }
362
+
363
+ return new Blob([view], {type: 'audio/wav'});
364
+ }
365
+
366
+ // this function is copied from
367
+ // https://github.com/awslabs/aws-lex-browser-audio-capture/blob/master/lib/worker.js#L46
368
+ function downsampleBuffer(buffer, exportSampleRate) {
369
+ if (exportSampleRate === recordSampleRate) {
370
+ return buffer;
371
+ }
372
+ var sampleRateRatio = recordSampleRate / exportSampleRate;
373
+ var newLength = Math.round(buffer.length / sampleRateRatio);
374
+ var result = new Float32Array(newLength);
375
+ var offsetResult = 0;
376
+ var offsetBuffer = 0;
377
+ while (offsetResult < result.length) {
378
+ var nextOffsetBuffer = Math.round((offsetResult + 1) * sampleRateRatio);
379
+ var accum = 0, count = 0;
380
+ for (var i = offsetBuffer; i < nextOffsetBuffer && i < buffer.length; i++) {
381
+ accum += buffer[i];
382
+ count++;
383
+ }
384
+ result[offsetResult] = accum / count;
385
+ offsetResult++;
386
+ offsetBuffer = nextOffsetBuffer;
387
+ }
388
+ return result;
389
+ };
index.html CHANGED
@@ -1,19 +1,43 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <html lang="en">
2
+
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width" />
6
+ <title>Next-gen Kaldi WebAssembly with sherpa-onnx for VAD + ASR</title>
7
+ <style>
8
+ h1,div {
9
+ text-align: center;
10
+ }
11
+ textarea {
12
+ width:100%;
13
+ }
14
+ </style>
15
+ </head>
16
+
17
+ <body>
18
+ <h1>
19
+ Next-gen Kaldi + WebAssembly<br/>
20
+ VAD+ASR Demo with <a href="https://github.com/k2-fsa/sherpa-onnx">sherpa-onnx</a><br/>
21
+ (with Zipformer supporting English 英语)
22
+ </h1>
23
+
24
+ <div>
25
+ <span id="hint">Loading model ... ...</span>
26
+ <br/>
27
+ <br/>
28
+ <button id="startBtn" disabled>Start</button>
29
+ <button id="stopBtn" disabled>Stop</button>
30
+ <button id="clearBtn">Clear</button>
31
+ <br/>
32
+ <br/>
33
+ <textarea id="results" rows="10" readonly></textarea>
34
+ </div>
35
+
36
+ <section flex="1" overflow="auto" id="sound-clips">
37
+ </section>
38
+
39
+ <script src="sherpa-onnx-asr.js"></script>
40
+ <script src="sherpa-onnx-vad.js"></script>
41
+ <script src="app-vad-asr.js"></script>
42
+ <script src="sherpa-onnx-wasm-main-vad-asr.js"></script>
43
+ </body>
sherpa-onnx-asr.js ADDED
@@ -0,0 +1,1030 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function freeConfig(config, Module) {
2
+ if ('buffer' in config) {
3
+ Module._free(config.buffer);
4
+ }
5
+
6
+ if ('config' in config) {
7
+ freeConfig(config.config, Module)
8
+ }
9
+
10
+ if ('transducer' in config) {
11
+ freeConfig(config.transducer, Module)
12
+ }
13
+
14
+ if ('paraformer' in config) {
15
+ freeConfig(config.paraformer, Module)
16
+ }
17
+
18
+ if ('ctc' in config) {
19
+ freeConfig(config.ctc, Module)
20
+ }
21
+
22
+ if ('feat' in config) {
23
+ freeConfig(config.feat, Module)
24
+ }
25
+
26
+ if ('model' in config) {
27
+ freeConfig(config.model, Module)
28
+ }
29
+
30
+ if ('nemoCtc' in config) {
31
+ freeConfig(config.nemoCtc, Module)
32
+ }
33
+
34
+ if ('whisper' in config) {
35
+ freeConfig(config.whisper, Module)
36
+ }
37
+
38
+ if ('tdnn' in config) {
39
+ freeConfig(config.tdnn, Module)
40
+ }
41
+
42
+ if ('senseVoice' in config) {
43
+ freeConfig(config.senseVoice, Module)
44
+ }
45
+
46
+ if ('lm' in config) {
47
+ freeConfig(config.lm, Module)
48
+ }
49
+
50
+ if ('ctcFstDecoder' in config) {
51
+ freeConfig(config.ctcFstDecoder, Module)
52
+ }
53
+
54
+ Module._free(config.ptr);
55
+ }
56
+
57
+ // The user should free the returned pointers
58
+ function initSherpaOnnxOnlineTransducerModelConfig(config, Module) {
59
+ const encoderLen = Module.lengthBytesUTF8(config.encoder || '') + 1;
60
+ const decoderLen = Module.lengthBytesUTF8(config.decoder || '') + 1;
61
+ const joinerLen = Module.lengthBytesUTF8(config.joiner || '') + 1;
62
+
63
+ const n = encoderLen + decoderLen + joinerLen;
64
+
65
+ const buffer = Module._malloc(n);
66
+
67
+ const len = 3 * 4; // 3 pointers
68
+ const ptr = Module._malloc(len);
69
+
70
+ let offset = 0;
71
+ Module.stringToUTF8(config.encoder || '', buffer + offset, encoderLen);
72
+ offset += encoderLen;
73
+
74
+ Module.stringToUTF8(config.decoder || '', buffer + offset, decoderLen);
75
+ offset += decoderLen;
76
+
77
+ Module.stringToUTF8(config.joiner || '', buffer + offset, joinerLen);
78
+
79
+ offset = 0;
80
+ Module.setValue(ptr, buffer + offset, 'i8*');
81
+ offset += encoderLen;
82
+
83
+ Module.setValue(ptr + 4, buffer + offset, 'i8*');
84
+ offset += decoderLen;
85
+
86
+ Module.setValue(ptr + 8, buffer + offset, 'i8*');
87
+
88
+ return {
89
+ buffer: buffer, ptr: ptr, len: len,
90
+ }
91
+ }
92
+
93
+ function initSherpaOnnxOnlineParaformerModelConfig(config, Module) {
94
+ const encoderLen = Module.lengthBytesUTF8(config.encoder || '') + 1;
95
+ const decoderLen = Module.lengthBytesUTF8(config.decoder || '') + 1;
96
+
97
+ const n = encoderLen + decoderLen;
98
+ const buffer = Module._malloc(n);
99
+
100
+ const len = 2 * 4; // 2 pointers
101
+ const ptr = Module._malloc(len);
102
+
103
+ let offset = 0;
104
+ Module.stringToUTF8(config.encoder || '', buffer + offset, encoderLen);
105
+ offset += encoderLen;
106
+
107
+ Module.stringToUTF8(config.decoder || '', buffer + offset, decoderLen);
108
+
109
+ offset = 0;
110
+ Module.setValue(ptr, buffer + offset, 'i8*');
111
+ offset += encoderLen;
112
+
113
+ Module.setValue(ptr + 4, buffer + offset, 'i8*');
114
+
115
+ return {
116
+ buffer: buffer, ptr: ptr, len: len,
117
+ }
118
+ }
119
+
120
+ function initSherpaOnnxOnlineZipformer2CtcModelConfig(config, Module) {
121
+ const n = Module.lengthBytesUTF8(config.model || '') + 1;
122
+ const buffer = Module._malloc(n);
123
+
124
+ const len = 1 * 4; // 1 pointer
125
+ const ptr = Module._malloc(len);
126
+
127
+ Module.stringToUTF8(config.model || '', buffer, n);
128
+
129
+ Module.setValue(ptr, buffer, 'i8*');
130
+
131
+ return {
132
+ buffer: buffer, ptr: ptr, len: len,
133
+ }
134
+ }
135
+
136
+ function initSherpaOnnxOnlineModelConfig(config, Module) {
137
+ if (!('transducer' in config)) {
138
+ config.transducer = {
139
+ encoder: '',
140
+ decoder: '',
141
+ joiner: '',
142
+ };
143
+ }
144
+
145
+ if (!('paraformer' in config)) {
146
+ config.paraformer = {
147
+ encoder: '',
148
+ decoder: '',
149
+ };
150
+ }
151
+
152
+ if (!('zipformer2Ctc' in config)) {
153
+ config.zipformer2Ctc = {
154
+ model: '',
155
+ };
156
+ }
157
+
158
+ const transducer =
159
+ initSherpaOnnxOnlineTransducerModelConfig(config.transducer, Module);
160
+
161
+ const paraformer =
162
+ initSherpaOnnxOnlineParaformerModelConfig(config.paraformer, Module);
163
+
164
+ const ctc = initSherpaOnnxOnlineZipformer2CtcModelConfig(
165
+ config.zipformer2Ctc, Module);
166
+
167
+ const len = transducer.len + paraformer.len + ctc.len + 7 * 4;
168
+ const ptr = Module._malloc(len);
169
+
170
+ let offset = 0;
171
+ Module._CopyHeap(transducer.ptr, transducer.len, ptr + offset);
172
+ offset += transducer.len;
173
+
174
+ Module._CopyHeap(paraformer.ptr, paraformer.len, ptr + offset);
175
+ offset += paraformer.len;
176
+
177
+ Module._CopyHeap(ctc.ptr, ctc.len, ptr + offset);
178
+ offset += ctc.len;
179
+
180
+ const tokensLen = Module.lengthBytesUTF8(config.tokens || '') + 1;
181
+ const providerLen = Module.lengthBytesUTF8(config.provider || 'cpu') + 1;
182
+ const modelTypeLen = Module.lengthBytesUTF8(config.modelType || '') + 1;
183
+ const modelingUnitLen = Module.lengthBytesUTF8(config.modelingUnit || '') + 1;
184
+ const bpeVocabLen = Module.lengthBytesUTF8(config.bpeVocab || '') + 1;
185
+
186
+ const bufferLen =
187
+ tokensLen + providerLen + modelTypeLen + modelingUnitLen + bpeVocabLen;
188
+ const buffer = Module._malloc(bufferLen);
189
+
190
+ offset = 0;
191
+ Module.stringToUTF8(config.tokens || '', buffer, tokensLen);
192
+ offset += tokensLen;
193
+
194
+ Module.stringToUTF8(config.provider || 'cpu', buffer + offset, providerLen);
195
+ offset += providerLen;
196
+
197
+ Module.stringToUTF8(config.modelType || '', buffer + offset, modelTypeLen);
198
+ offset += modelTypeLen;
199
+
200
+ Module.stringToUTF8(
201
+ config.modelingUnit || '', buffer + offset, modelingUnitLen);
202
+ offset += modelingUnitLen;
203
+
204
+ Module.stringToUTF8(config.bpeVocab || '', buffer + offset, bpeVocabLen);
205
+ offset += bpeVocabLen;
206
+
207
+ offset = transducer.len + paraformer.len + ctc.len;
208
+ Module.setValue(ptr + offset, buffer, 'i8*'); // tokens
209
+ offset += 4;
210
+
211
+ Module.setValue(ptr + offset, config.numThreads || 1, 'i32');
212
+ offset += 4;
213
+
214
+ Module.setValue(ptr + offset, buffer + tokensLen, 'i8*'); // provider
215
+ offset += 4;
216
+
217
+ Module.setValue(ptr + offset, config.debug || 0, 'i32');
218
+ offset += 4;
219
+
220
+ Module.setValue(
221
+ ptr + offset, buffer + tokensLen + providerLen, 'i8*'); // modelType
222
+ offset += 4;
223
+
224
+ Module.setValue(
225
+ ptr + offset, buffer + tokensLen + providerLen + modelTypeLen,
226
+ 'i8*'); // modelingUnit
227
+ offset += 4;
228
+
229
+ Module.setValue(
230
+ ptr + offset,
231
+ buffer + tokensLen + providerLen + modelTypeLen + modelingUnitLen,
232
+ 'i8*'); // bpeVocab
233
+ offset += 4;
234
+
235
+ return {
236
+ buffer: buffer, ptr: ptr, len: len, transducer: transducer,
237
+ paraformer: paraformer, ctc: ctc
238
+ }
239
+ }
240
+
241
+ function initSherpaOnnxFeatureConfig(config, Module) {
242
+ const len = 2 * 4; // 2 pointers
243
+ const ptr = Module._malloc(len);
244
+
245
+ Module.setValue(ptr, config.sampleRate || 16000, 'i32');
246
+ Module.setValue(ptr + 4, config.featureDim || 80, 'i32');
247
+ return {ptr: ptr, len: len};
248
+ }
249
+
250
+ function initSherpaOnnxOnlineCtcFstDecoderConfig(config, Module) {
251
+ const len = 2 * 4;
252
+ const ptr = Module._malloc(len);
253
+
254
+ const graphLen = Module.lengthBytesUTF8(config.graph || '') + 1;
255
+ const buffer = Module._malloc(graphLen);
256
+ Module.stringToUTF8(config.graph, buffer, graphLen);
257
+
258
+ Module.setValue(ptr, buffer, 'i8*');
259
+ Module.setValue(ptr + 4, config.maxActive || 3000, 'i32');
260
+ return {ptr: ptr, len: len, buffer: buffer};
261
+ }
262
+
263
+ function initSherpaOnnxOnlineRecognizerConfig(config, Module) {
264
+ if (!('featConfig' in config)) {
265
+ config.featConfig = {
266
+ sampleRate: 16000,
267
+ featureDim: 80,
268
+ };
269
+ }
270
+
271
+ if (!('ctcFstDecoderConfig' in config)) {
272
+ config.ctcFstDecoderConfig = {
273
+ graph: '',
274
+ maxActive: 3000,
275
+ };
276
+ }
277
+
278
+ const feat = initSherpaOnnxFeatureConfig(config.featConfig, Module);
279
+ const model = initSherpaOnnxOnlineModelConfig(config.modelConfig, Module);
280
+ const ctcFstDecoder = initSherpaOnnxOnlineCtcFstDecoderConfig(
281
+ config.ctcFstDecoderConfig, Module)
282
+
283
+ const len = feat.len + model.len + 8 * 4 + ctcFstDecoder.len + 3 * 4;
284
+ const ptr = Module._malloc(len);
285
+
286
+ let offset = 0;
287
+ Module._CopyHeap(feat.ptr, feat.len, ptr + offset);
288
+ offset += feat.len;
289
+
290
+ Module._CopyHeap(model.ptr, model.len, ptr + offset);
291
+ offset += model.len;
292
+
293
+ const decodingMethodLen =
294
+ Module.lengthBytesUTF8(config.decodingMethod || 'greedy_search') + 1;
295
+ const hotwordsFileLen = Module.lengthBytesUTF8(config.hotwordsFile || '') + 1;
296
+ const ruleFstsFileLen = Module.lengthBytesUTF8(config.ruleFsts || '') + 1;
297
+ const ruleFarsFileLen = Module.lengthBytesUTF8(config.ruleFars || '') + 1;
298
+ const bufferLen =
299
+ decodingMethodLen + hotwordsFileLen + ruleFstsFileLen + ruleFarsFileLen;
300
+ const buffer = Module._malloc(bufferLen);
301
+
302
+ offset = 0;
303
+ Module.stringToUTF8(
304
+ config.decodingMethod || 'greedy_search', buffer, decodingMethodLen);
305
+ offset += decodingMethodLen;
306
+
307
+ Module.stringToUTF8(
308
+ config.hotwordsFile || '', buffer + offset, hotwordsFileLen);
309
+ offset += hotwordsFileLen;
310
+
311
+ Module.stringToUTF8(config.ruleFsts || '', buffer + offset, ruleFstsFileLen);
312
+ offset += ruleFstsFileLen;
313
+
314
+ Module.stringToUTF8(config.ruleFars || '', buffer + offset, ruleFarsFileLen);
315
+ offset += ruleFarsFileLen;
316
+
317
+ offset = feat.len + model.len;
318
+ Module.setValue(ptr + offset, buffer, 'i8*'); // decoding method
319
+ offset += 4;
320
+
321
+ Module.setValue(ptr + offset, config.maxActivePaths || 4, 'i32');
322
+ offset += 4;
323
+
324
+ Module.setValue(ptr + offset, config.enableEndpoint || 0, 'i32');
325
+ offset += 4;
326
+
327
+ Module.setValue(ptr + offset, config.rule1MinTrailingSilence || 2.4, 'float');
328
+ offset += 4;
329
+
330
+ Module.setValue(ptr + offset, config.rule2MinTrailingSilence || 1.2, 'float');
331
+ offset += 4;
332
+
333
+ Module.setValue(ptr + offset, config.rule3MinUtteranceLength || 20, 'float');
334
+ offset += 4;
335
+
336
+ Module.setValue(ptr + offset, buffer + decodingMethodLen, 'i8*');
337
+ offset += 4;
338
+
339
+ Module.setValue(ptr + offset, config.hotwordsScore || 1.5, 'float');
340
+ offset += 4;
341
+
342
+ Module._CopyHeap(ctcFstDecoder.ptr, ctcFstDecoder.len, ptr + offset);
343
+ offset += ctcFstDecoder.len;
344
+
345
+ Module.setValue(
346
+ ptr + offset, buffer + decodingMethodLen + hotwordsFileLen, 'i8*');
347
+ offset += 4;
348
+
349
+ Module.setValue(
350
+ ptr + offset,
351
+ buffer + decodingMethodLen + hotwordsFileLen + ruleFstsFileLen, 'i8*');
352
+ offset += 4;
353
+
354
+ Module.setValue(ptr + offset, config.blankPenalty || 0, 'float');
355
+ offset += 4;
356
+
357
+ return {
358
+ buffer: buffer, ptr: ptr, len: len, feat: feat, model: model,
359
+ ctcFstDecoder: ctcFstDecoder
360
+ }
361
+ }
362
+
363
+ function createOnlineRecognizer(Module, myConfig) {
364
+ const onlineTransducerModelConfig = {
365
+ encoder: '',
366
+ decoder: '',
367
+ joiner: '',
368
+ };
369
+
370
+ const onlineParaformerModelConfig = {
371
+ encoder: '',
372
+ decoder: '',
373
+ };
374
+
375
+ const onlineZipformer2CtcModelConfig = {
376
+ model: '',
377
+ };
378
+
379
+ let type = 0;
380
+
381
+ switch (type) {
382
+ case 0:
383
+ // transducer
384
+ onlineTransducerModelConfig.encoder = './encoder.onnx';
385
+ onlineTransducerModelConfig.decoder = './decoder.onnx';
386
+ onlineTransducerModelConfig.joiner = './joiner.onnx';
387
+ break;
388
+ case 1:
389
+ // paraformer
390
+ onlineParaformerModelConfig.encoder = './encoder.onnx';
391
+ onlineParaformerModelConfig.decoder = './decoder.onnx';
392
+ break;
393
+ case 2:
394
+ // ctc
395
+ onlineZipformer2CtcModelConfig.model = './encoder.onnx';
396
+ break;
397
+ }
398
+
399
+
400
+ const onlineModelConfig = {
401
+ transducer: onlineTransducerModelConfig,
402
+ paraformer: onlineParaformerModelConfig,
403
+ zipformer2Ctc: onlineZipformer2CtcModelConfig,
404
+ tokens: './tokens.txt',
405
+ numThreads: 1,
406
+ provider: 'cpu',
407
+ debug: 1,
408
+ modelType: '',
409
+ modelingUnit: 'cjkchar',
410
+ bpeVocab: '',
411
+ };
412
+
413
+ const featureConfig = {
414
+ sampleRate: 16000,
415
+ featureDim: 80,
416
+ };
417
+
418
+ let recognizerConfig = {
419
+ featConfig: featureConfig,
420
+ modelConfig: onlineModelConfig,
421
+ decodingMethod: 'greedy_search',
422
+ maxActivePaths: 4,
423
+ enableEndpoint: 1,
424
+ rule1MinTrailingSilence: 2.4,
425
+ rule2MinTrailingSilence: 1.2,
426
+ rule3MinUtteranceLength: 20,
427
+ hotwordsFile: '',
428
+ hotwordsScore: 1.5,
429
+ ctcFstDecoderConfig: {
430
+ graph: '',
431
+ maxActive: 3000,
432
+ },
433
+ ruleFsts: '',
434
+ ruleFars: '',
435
+ };
436
+ if (myConfig) {
437
+ recognizerConfig = myConfig;
438
+ }
439
+
440
+ return new OnlineRecognizer(recognizerConfig, Module);
441
+ }
442
+
443
+ function initSherpaOnnxOfflineTransducerModelConfig(config, Module) {
444
+ const encoderLen = Module.lengthBytesUTF8(config.encoder || '') + 1;
445
+ const decoderLen = Module.lengthBytesUTF8(config.decoder || '') + 1;
446
+ const joinerLen = Module.lengthBytesUTF8(config.joiner || '') + 1;
447
+
448
+ const n = encoderLen + decoderLen + joinerLen;
449
+
450
+ const buffer = Module._malloc(n);
451
+
452
+ const len = 3 * 4; // 3 pointers
453
+ const ptr = Module._malloc(len);
454
+
455
+ let offset = 0;
456
+ Module.stringToUTF8(config.encoder || '', buffer + offset, encoderLen);
457
+ offset += encoderLen;
458
+
459
+ Module.stringToUTF8(config.decoder || '', buffer + offset, decoderLen);
460
+ offset += decoderLen;
461
+
462
+ Module.stringToUTF8(config.joiner || '', buffer + offset, joinerLen);
463
+
464
+ offset = 0;
465
+ Module.setValue(ptr, buffer + offset, 'i8*');
466
+ offset += encoderLen;
467
+
468
+ Module.setValue(ptr + 4, buffer + offset, 'i8*');
469
+ offset += decoderLen;
470
+
471
+ Module.setValue(ptr + 8, buffer + offset, 'i8*');
472
+
473
+ return {
474
+ buffer: buffer, ptr: ptr, len: len,
475
+ }
476
+ }
477
+
478
+ function initSherpaOnnxOfflineParaformerModelConfig(config, Module) {
479
+ const n = Module.lengthBytesUTF8(config.model || '') + 1;
480
+
481
+ const buffer = Module._malloc(n);
482
+
483
+ const len = 1 * 4; // 1 pointer
484
+ const ptr = Module._malloc(len);
485
+
486
+ Module.stringToUTF8(config.model || '', buffer, n);
487
+
488
+ Module.setValue(ptr, buffer, 'i8*');
489
+
490
+ return {
491
+ buffer: buffer, ptr: ptr, len: len,
492
+ }
493
+ }
494
+
495
+ function initSherpaOnnxOfflineNemoEncDecCtcModelConfig(config, Module) {
496
+ const n = Module.lengthBytesUTF8(config.model || '') + 1;
497
+
498
+ const buffer = Module._malloc(n);
499
+
500
+ const len = 1 * 4; // 1 pointer
501
+ const ptr = Module._malloc(len);
502
+
503
+ Module.stringToUTF8(config.model || '', buffer, n);
504
+
505
+ Module.setValue(ptr, buffer, 'i8*');
506
+
507
+ return {
508
+ buffer: buffer, ptr: ptr, len: len,
509
+ }
510
+ }
511
+
512
+ function initSherpaOnnxOfflineWhisperModelConfig(config, Module) {
513
+ const encoderLen = Module.lengthBytesUTF8(config.encoder || '') + 1;
514
+ const decoderLen = Module.lengthBytesUTF8(config.decoder || '') + 1;
515
+ const languageLen = Module.lengthBytesUTF8(config.language || '') + 1;
516
+ const taskLen = Module.lengthBytesUTF8(config.task || '') + 1;
517
+
518
+ const n = encoderLen + decoderLen + languageLen + taskLen;
519
+ const buffer = Module._malloc(n);
520
+
521
+ const len = 5 * 4; // 4 pointers
522
+ const ptr = Module._malloc(len);
523
+
524
+ let offset = 0;
525
+ Module.stringToUTF8(config.encoder || '', buffer + offset, encoderLen);
526
+ offset += encoderLen;
527
+
528
+ Module.stringToUTF8(config.decoder || '', buffer + offset, decoderLen);
529
+ offset += decoderLen;
530
+
531
+ Module.stringToUTF8(config.language || '', buffer + offset, languageLen);
532
+ offset += languageLen;
533
+
534
+ Module.stringToUTF8(config.task || '', buffer + offset, taskLen);
535
+
536
+ offset = 0;
537
+ Module.setValue(ptr, buffer + offset, 'i8*');
538
+ offset += encoderLen;
539
+
540
+ Module.setValue(ptr + 4, buffer + offset, 'i8*');
541
+ offset += decoderLen;
542
+
543
+ Module.setValue(ptr + 8, buffer + offset, 'i8*');
544
+ offset += languageLen;
545
+
546
+ Module.setValue(ptr + 12, buffer + offset, 'i8*');
547
+ offset += taskLen;
548
+
549
+ Module.setValue(ptr + 16, config.tailPaddings || -1, 'i32');
550
+
551
+ return {
552
+ buffer: buffer, ptr: ptr, len: len,
553
+ }
554
+ }
555
+
556
+ function initSherpaOnnxOfflineTdnnModelConfig(config, Module) {
557
+ const n = Module.lengthBytesUTF8(config.model || '') + 1;
558
+ const buffer = Module._malloc(n);
559
+
560
+ const len = 1 * 4; // 1 pointer
561
+ const ptr = Module._malloc(len);
562
+
563
+ Module.stringToUTF8(config.model || '', buffer, n);
564
+
565
+ Module.setValue(ptr, buffer, 'i8*');
566
+
567
+ return {
568
+ buffer: buffer, ptr: ptr, len: len,
569
+ }
570
+ }
571
+
572
+ function initSherpaOnnxOfflineSenseVoiceModelConfig(config, Module) {
573
+ const modelLen = Module.lengthBytesUTF8(config.model || '') + 1;
574
+ const languageLen = Module.lengthBytesUTF8(config.language || '') + 1;
575
+
576
+ // useItn is a integer with 4 bytes
577
+ const n = modelLen + languageLen;
578
+ const buffer = Module._malloc(n);
579
+
580
+ const len = 3 * 4; // 2 pointers + 1 int
581
+ const ptr = Module._malloc(len);
582
+
583
+ let offset = 0;
584
+ Module.stringToUTF8(config.model || '', buffer + offset, modelLen);
585
+ offset += modelLen;
586
+
587
+ Module.stringToUTF8(config.language || '', buffer + offset, languageLen);
588
+ offset += languageLen;
589
+
590
+ offset = 0;
591
+ Module.setValue(ptr, buffer + offset, 'i8*');
592
+ offset += modelLen;
593
+
594
+ Module.setValue(ptr + 4, buffer + offset, 'i8*');
595
+ offset += languageLen;
596
+
597
+ Module.setValue(ptr + 8, config.useInverseTextNormalization || 0, 'i32');
598
+
599
+ return {
600
+ buffer: buffer, ptr: ptr, len: len,
601
+ }
602
+ }
603
+
604
+ function initSherpaOnnxOfflineLMConfig(config, Module) {
605
+ const n = Module.lengthBytesUTF8(config.model || '') + 1;
606
+ const buffer = Module._malloc(n);
607
+
608
+ const len = 2 * 4;
609
+ const ptr = Module._malloc(len);
610
+
611
+ Module.stringToUTF8(config.model || '', buffer, n);
612
+ Module.setValue(ptr, buffer, 'i8*');
613
+ Module.setValue(ptr + 4, config.scale || 1, 'float');
614
+
615
+ return {
616
+ buffer: buffer, ptr: ptr, len: len,
617
+ }
618
+ }
619
+
620
+ function initSherpaOnnxOfflineModelConfig(config, Module) {
621
+ if (!('transducer' in config)) {
622
+ config.transducer = {
623
+ encoder: '',
624
+ decoder: '',
625
+ joiner: '',
626
+ };
627
+ }
628
+
629
+ if (!('paraformer' in config)) {
630
+ config.paraformer = {
631
+ model: '',
632
+ };
633
+ }
634
+
635
+ if (!('nemoCtc' in config)) {
636
+ config.nemoCtc = {
637
+ model: '',
638
+ };
639
+ }
640
+
641
+ if (!('whisper' in config)) {
642
+ config.whisper = {
643
+ encoder: '',
644
+ decoder: '',
645
+ language: '',
646
+ task: '',
647
+ tailPaddings: -1,
648
+ };
649
+ }
650
+
651
+ if (!('tdnn' in config)) {
652
+ config.tdnn = {
653
+ model: '',
654
+ };
655
+ }
656
+
657
+ if (!('senseVoice' in config)) {
658
+ config.senseVoice = {
659
+ model: '',
660
+ language: '',
661
+ useInverseTextNormalization: 0,
662
+ };
663
+ }
664
+
665
+ const transducer =
666
+ initSherpaOnnxOfflineTransducerModelConfig(config.transducer, Module);
667
+
668
+ const paraformer =
669
+ initSherpaOnnxOfflineParaformerModelConfig(config.paraformer, Module);
670
+
671
+ const nemoCtc =
672
+ initSherpaOnnxOfflineNemoEncDecCtcModelConfig(config.nemoCtc, Module);
673
+
674
+ const whisper =
675
+ initSherpaOnnxOfflineWhisperModelConfig(config.whisper, Module);
676
+
677
+ const tdnn = initSherpaOnnxOfflineTdnnModelConfig(config.tdnn, Module);
678
+
679
+ const senseVoice =
680
+ initSherpaOnnxOfflineSenseVoiceModelConfig(config.senseVoice, Module);
681
+
682
+ const len = transducer.len + paraformer.len + nemoCtc.len + whisper.len +
683
+ tdnn.len + 8 * 4 + senseVoice.len;
684
+
685
+ const ptr = Module._malloc(len);
686
+
687
+ let offset = 0;
688
+ Module._CopyHeap(transducer.ptr, transducer.len, ptr + offset);
689
+ offset += transducer.len;
690
+
691
+ Module._CopyHeap(paraformer.ptr, paraformer.len, ptr + offset);
692
+ offset += paraformer.len;
693
+
694
+ Module._CopyHeap(nemoCtc.ptr, nemoCtc.len, ptr + offset);
695
+ offset += nemoCtc.len;
696
+
697
+ Module._CopyHeap(whisper.ptr, whisper.len, ptr + offset);
698
+ offset += whisper.len;
699
+
700
+ Module._CopyHeap(tdnn.ptr, tdnn.len, ptr + offset);
701
+ offset += tdnn.len;
702
+
703
+
704
+ const tokensLen = Module.lengthBytesUTF8(config.tokens || '') + 1;
705
+ const providerLen = Module.lengthBytesUTF8(config.provider || 'cpu') + 1;
706
+ const modelTypeLen = Module.lengthBytesUTF8(config.modelType || '') + 1;
707
+ const modelingUnitLen = Module.lengthBytesUTF8(config.modelingUnit || '') + 1;
708
+ const bpeVocabLen = Module.lengthBytesUTF8(config.bpeVocab || '') + 1;
709
+ const teleSpeechCtcLen =
710
+ Module.lengthBytesUTF8(config.teleSpeechCtc || '') + 1;
711
+
712
+ const bufferLen = tokensLen + providerLen + modelTypeLen + modelingUnitLen +
713
+ bpeVocabLen + teleSpeechCtcLen;
714
+
715
+ const buffer = Module._malloc(bufferLen);
716
+
717
+ offset = 0;
718
+ Module.stringToUTF8(config.tokens, buffer, tokensLen);
719
+ offset += tokensLen;
720
+
721
+ Module.stringToUTF8(config.provider || 'cpu', buffer + offset, providerLen);
722
+ offset += providerLen;
723
+
724
+ Module.stringToUTF8(config.modelType || '', buffer + offset, modelTypeLen);
725
+ offset += modelTypeLen;
726
+
727
+ Module.stringToUTF8(
728
+ config.modelingUnit || '', buffer + offset, modelingUnitLen);
729
+ offset += modelingUnitLen;
730
+
731
+ Module.stringToUTF8(config.bpeVocab || '', buffer + offset, bpeVocabLen);
732
+ offset += bpeVocabLen;
733
+
734
+ Module.stringToUTF8(
735
+ config.teleSpeechCtc || '', buffer + offset, teleSpeechCtcLen);
736
+ offset += teleSpeechCtcLen;
737
+
738
+ offset =
739
+ transducer.len + paraformer.len + nemoCtc.len + whisper.len + tdnn.len;
740
+ Module.setValue(ptr + offset, buffer, 'i8*'); // tokens
741
+ offset += 4;
742
+
743
+ Module.setValue(ptr + offset, config.numThreads || 1, 'i32');
744
+ offset += 4;
745
+
746
+ Module.setValue(ptr + offset, config.debug || 0, 'i32');
747
+ offset += 4;
748
+
749
+ Module.setValue(ptr + offset, buffer + tokensLen, 'i8*'); // provider
750
+ offset += 4;
751
+
752
+ Module.setValue(
753
+ ptr + offset, buffer + tokensLen + providerLen, 'i8*'); // modelType
754
+ offset += 4;
755
+
756
+ Module.setValue(
757
+ ptr + offset, buffer + tokensLen + providerLen + modelTypeLen,
758
+ 'i8*'); // modelingUnit
759
+ offset += 4;
760
+
761
+ Module.setValue(
762
+ ptr + offset,
763
+ buffer + tokensLen + providerLen + modelTypeLen + modelingUnitLen,
764
+ 'i8*'); // bpeVocab
765
+ offset += 4;
766
+
767
+ Module.setValue(
768
+ ptr + offset,
769
+ buffer + tokensLen + providerLen + modelTypeLen + modelingUnitLen +
770
+ bpeVocabLen,
771
+ 'i8*'); // teleSpeechCtc
772
+ offset += 4;
773
+
774
+ Module._CopyHeap(senseVoice.ptr, senseVoice.len, ptr + offset);
775
+
776
+ return {
777
+ buffer: buffer, ptr: ptr, len: len, transducer: transducer,
778
+ paraformer: paraformer, nemoCtc: nemoCtc, whisper: whisper, tdnn: tdnn,
779
+ senseVoice: senseVoice,
780
+ }
781
+ }
782
+
783
+ function initSherpaOnnxOfflineRecognizerConfig(config, Module) {
784
+ if (!('featConfig' in config)) {
785
+ config.featConfig = {
786
+ sampleRate: 16000,
787
+ featureDim: 80,
788
+ };
789
+ }
790
+
791
+ if (!('lmConfig' in config)) {
792
+ config.lmConfig = {
793
+ model: '',
794
+ scale: 1.0,
795
+ };
796
+ }
797
+
798
+ const feat = initSherpaOnnxFeatureConfig(config.featConfig, Module);
799
+ const model = initSherpaOnnxOfflineModelConfig(config.modelConfig, Module);
800
+ const lm = initSherpaOnnxOfflineLMConfig(config.lmConfig, Module);
801
+
802
+ const len = feat.len + model.len + lm.len + 7 * 4;
803
+ const ptr = Module._malloc(len);
804
+
805
+ let offset = 0;
806
+ Module._CopyHeap(feat.ptr, feat.len, ptr + offset);
807
+ offset += feat.len;
808
+
809
+ Module._CopyHeap(model.ptr, model.len, ptr + offset);
810
+ offset += model.len;
811
+
812
+ Module._CopyHeap(lm.ptr, lm.len, ptr + offset);
813
+ offset += lm.len;
814
+
815
+ const decodingMethodLen =
816
+ Module.lengthBytesUTF8(config.decodingMethod || 'greedy_search') + 1;
817
+ const hotwordsFileLen = Module.lengthBytesUTF8(config.hotwordsFile || '') + 1;
818
+ const ruleFstsLen = Module.lengthBytesUTF8(config.ruleFsts || '') + 1;
819
+ const ruleFarsLen = Module.lengthBytesUTF8(config.ruleFars || '') + 1;
820
+ const bufferLen =
821
+ decodingMethodLen + hotwordsFileLen + ruleFstsLen + ruleFarsLen;
822
+ const buffer = Module._malloc(bufferLen);
823
+
824
+ offset = 0;
825
+ Module.stringToUTF8(
826
+ config.decodingMethod || 'greedy_search', buffer, decodingMethodLen);
827
+ offset += decodingMethodLen;
828
+
829
+ Module.stringToUTF8(
830
+ config.hotwordsFile || '', buffer + offset, hotwordsFileLen);
831
+ offset += hotwordsFileLen;
832
+
833
+ Module.stringToUTF8(config.ruleFsts || '', buffer + offset, ruleFstsLen);
834
+ offset += ruleFstsLen;
835
+
836
+ Module.stringToUTF8(config.ruleFars || '', buffer + offset, ruleFarsLen);
837
+ offset += ruleFarsLen;
838
+
839
+ offset = feat.len + model.len + lm.len;
840
+
841
+ Module.setValue(ptr + offset, buffer, 'i8*'); // decoding method
842
+ offset += 4;
843
+
844
+ Module.setValue(ptr + offset, config.maxActivePaths || 4, 'i32');
845
+ offset += 4;
846
+
847
+ Module.setValue(ptr + offset, buffer + decodingMethodLen, 'i8*');
848
+ offset += 4;
849
+
850
+ Module.setValue(ptr + offset, config.hotwordsScore || 1.5, 'float');
851
+ offset += 4;
852
+
853
+ Module.setValue(
854
+ ptr + offset, buffer + decodingMethodLen + hotwordsFileLen, 'i8*');
855
+ offset += 4;
856
+
857
+ Module.setValue(
858
+ ptr + offset, buffer + decodingMethodLen + hotwordsFileLen + ruleFstsLen,
859
+ 'i8*');
860
+ offset += 4;
861
+
862
+ Module.setValue(ptr + offset, config.blankPenalty || 0, 'float');
863
+ offset += 4;
864
+
865
+ return {
866
+ buffer: buffer, ptr: ptr, len: len, feat: feat, model: model, lm: lm
867
+ }
868
+ }
869
+
870
+ class OfflineStream {
871
+ constructor(handle, Module) {
872
+ this.handle = handle;
873
+ this.Module = Module;
874
+ }
875
+
876
+ free() {
877
+ if (this.handle) {
878
+ this.Module._SherpaOnnxDestroyOfflineStream(this.handle);
879
+ this.handle = null;
880
+ }
881
+ }
882
+
883
+ /**
884
+ * @param sampleRate {Number}
885
+ * @param samples {Float32Array} Containing samples in the range [-1, 1]
886
+ */
887
+ acceptWaveform(sampleRate, samples) {
888
+ const pointer =
889
+ this.Module._malloc(samples.length * samples.BYTES_PER_ELEMENT);
890
+ this.Module.HEAPF32.set(samples, pointer / samples.BYTES_PER_ELEMENT);
891
+ this.Module._SherpaOnnxAcceptWaveformOffline(
892
+ this.handle, sampleRate, pointer, samples.length);
893
+ this.Module._free(pointer);
894
+ }
895
+ };
896
+
897
+ class OfflineRecognizer {
898
+ constructor(configObj, Module) {
899
+ this.config = configObj;
900
+ const config = initSherpaOnnxOfflineRecognizerConfig(configObj, Module);
901
+ const handle = Module._SherpaOnnxCreateOfflineRecognizer(config.ptr);
902
+ freeConfig(config, Module);
903
+
904
+ this.handle = handle;
905
+ this.Module = Module;
906
+ }
907
+
908
+ free() {
909
+ this.Module._SherpaOnnxDestroyOfflineRecognizer(this.handle);
910
+ this.handle = 0
911
+ }
912
+
913
+ createStream() {
914
+ const handle = this.Module._SherpaOnnxCreateOfflineStream(this.handle);
915
+ return new OfflineStream(handle, this.Module);
916
+ }
917
+
918
+ decode(stream) {
919
+ this.Module._SherpaOnnxDecodeOfflineStream(this.handle, stream.handle);
920
+ }
921
+
922
+ getResult(stream) {
923
+ const r =
924
+ this.Module._SherpaOnnxGetOfflineStreamResultAsJson(stream.handle);
925
+ const jsonStr = this.Module.UTF8ToString(r);
926
+ const ans = JSON.parse(jsonStr);
927
+ this.Module._SherpaOnnxDestroyOfflineStreamResultJson(r);
928
+
929
+ return ans;
930
+ }
931
+ };
932
+
933
+ class OnlineStream {
934
+ constructor(handle, Module) {
935
+ this.handle = handle;
936
+ this.pointer = null; // buffer
937
+ this.n = 0; // buffer size
938
+ this.Module = Module;
939
+ }
940
+
941
+ free() {
942
+ if (this.handle) {
943
+ this.Module._SherpaOnnxDestroyOnlineStream(this.handle);
944
+ this.handle = null;
945
+ this.Module._free(this.pointer);
946
+ this.pointer = null;
947
+ this.n = 0;
948
+ }
949
+ }
950
+
951
+ /**
952
+ * @param sampleRate {Number}
953
+ * @param samples {Float32Array} Containing samples in the range [-1, 1]
954
+ */
955
+ acceptWaveform(sampleRate, samples) {
956
+ if (this.n < samples.length) {
957
+ this.Module._free(this.pointer);
958
+ this.pointer =
959
+ this.Module._malloc(samples.length * samples.BYTES_PER_ELEMENT);
960
+ this.n = samples.length
961
+ }
962
+
963
+ this.Module.HEAPF32.set(samples, this.pointer / samples.BYTES_PER_ELEMENT);
964
+ this.Module._SherpaOnnxOnlineStreamAcceptWaveform(
965
+ this.handle, sampleRate, this.pointer, samples.length);
966
+ }
967
+
968
+ inputFinished() {
969
+ this.Module._SherpaOnnxOnlineStreamInputFinished(this.handle);
970
+ }
971
+ };
972
+
973
+ class OnlineRecognizer {
974
+ constructor(configObj, Module) {
975
+ this.config = configObj;
976
+ const config = initSherpaOnnxOnlineRecognizerConfig(configObj, Module)
977
+ const handle = Module._SherpaOnnxCreateOnlineRecognizer(config.ptr);
978
+
979
+ freeConfig(config, Module);
980
+
981
+ this.handle = handle;
982
+ this.Module = Module;
983
+ }
984
+
985
+ free() {
986
+ this.Module._SherpaOnnxDestroyOnlineRecognizer(this.handle);
987
+ this.handle = 0
988
+ }
989
+
990
+ createStream() {
991
+ const handle = this.Module._SherpaOnnxCreateOnlineStream(this.handle);
992
+ return new OnlineStream(handle, this.Module);
993
+ }
994
+
995
+ isReady(stream) {
996
+ return this.Module._SherpaOnnxIsOnlineStreamReady(
997
+ this.handle, stream.handle) == 1;
998
+ }
999
+
1000
+ decode(stream) {
1001
+ this.Module._SherpaOnnxDecodeOnlineStream(this.handle, stream.handle);
1002
+ }
1003
+
1004
+ isEndpoint(stream) {
1005
+ return this.Module._SherpaOnnxOnlineStreamIsEndpoint(
1006
+ this.handle, stream.handle) == 1;
1007
+ }
1008
+
1009
+ reset(stream) {
1010
+ this.Module._SherpaOnnxOnlineStreamReset(this.handle, stream.handle);
1011
+ }
1012
+
1013
+ getResult(stream) {
1014
+ const r = this.Module._SherpaOnnxGetOnlineStreamResultAsJson(
1015
+ this.handle, stream.handle);
1016
+ const jsonStr = this.Module.UTF8ToString(r);
1017
+ const ans = JSON.parse(jsonStr);
1018
+ this.Module._SherpaOnnxDestroyOnlineStreamResultJson(r);
1019
+
1020
+ return ans;
1021
+ }
1022
+ }
1023
+
1024
+ if (typeof process == 'object' && typeof process.versions == 'object' &&
1025
+ typeof process.versions.node == 'string') {
1026
+ module.exports = {
1027
+ createOnlineRecognizer,
1028
+ OfflineRecognizer,
1029
+ };
1030
+ }
sherpa-onnx-vad.js ADDED
@@ -0,0 +1,252 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function freeConfig(config, Module) {
2
+ if ('buffer' in config) {
3
+ Module._free(config.buffer);
4
+ }
5
+
6
+ if ('sileroVad' in config) {
7
+ freeConfig(config.sileroVad, Module)
8
+ }
9
+
10
+
11
+ Module._free(config.ptr);
12
+ }
13
+
14
+ // The user should free the returned pointers
15
+ function initSherpaOnnxSileroVadModelConfig(config, Module) {
16
+ const modelLen = Module.lengthBytesUTF8(config.model || '') + 1;
17
+
18
+ const n = modelLen;
19
+
20
+ const buffer = Module._malloc(n);
21
+
22
+ const len = 5 * 4;
23
+ const ptr = Module._malloc(len);
24
+
25
+ Module.stringToUTF8(config.model || '', buffer, modelLen);
26
+
27
+ offset = 0;
28
+ Module.setValue(ptr, buffer, 'i8*');
29
+ offset += 4;
30
+
31
+ Module.setValue(ptr + offset, config.threshold || 0.5, 'float');
32
+ offset += 4;
33
+
34
+ Module.setValue(ptr + offset, config.minSilenceDuration || 0.5, 'float');
35
+ offset += 4;
36
+
37
+ Module.setValue(ptr + offset, config.minSpeechDuration || 0.25, 'float');
38
+ offset += 4;
39
+
40
+ Module.setValue(ptr + offset, config.windowSize || 512, 'i32');
41
+ offset += 4;
42
+
43
+ return {
44
+ buffer: buffer, ptr: ptr, len: len,
45
+ }
46
+ }
47
+
48
+ function initSherpaOnnxVadModelConfig(config, Module) {
49
+ if (!('sileroVad' in config)) {
50
+ config.sileroVad = {
51
+ model: '',
52
+ threshold: 0.50,
53
+ minSilenceDuration: 0.50,
54
+ minSpeechDuration: 0.25,
55
+ windowSize: 512,
56
+ };
57
+ }
58
+
59
+ const sileroVad =
60
+ initSherpaOnnxSileroVadModelConfig(config.sileroVad, Module);
61
+
62
+ const len = sileroVad.len + 4 * 4;
63
+ const ptr = Module._malloc(len);
64
+
65
+ const providerLen = Module.lengthBytesUTF8(config.provider || 'cpu') + 1;
66
+ const buffer = Module._malloc(providerLen);
67
+ Module.stringToUTF8(config.provider || 'cpu', buffer, providerLen);
68
+
69
+ let offset = 0;
70
+ Module._CopyHeap(sileroVad.ptr, sileroVad.len, ptr + offset);
71
+ offset += sileroVad.len;
72
+
73
+ Module.setValue(ptr + offset, config.sampleRate || 16000, 'i32');
74
+ offset += 4;
75
+
76
+ Module.setValue(ptr + offset, config.numThreads || 1, 'i32');
77
+ offset += 4;
78
+
79
+ Module.setValue(ptr + offset, buffer, 'i8*'); // provider
80
+ offset += 4;
81
+
82
+ Module.setValue(ptr + offset, config.debug || 0, 'i32');
83
+ offset += 4;
84
+
85
+ return {
86
+ buffer: buffer, ptr: ptr, len: len, sileroVad: sileroVad,
87
+ }
88
+ }
89
+
90
+ function createVad(Module, myConfig) {
91
+ const sileroVad = {
92
+ model: './silero_vad.onnx',
93
+ threshold: 0.50,
94
+ minSilenceDuration: 0.50,
95
+ minSpeechDuration: 0.25,
96
+ windowSize: 512,
97
+ };
98
+
99
+ let config = {
100
+ sileroVad: sileroVad,
101
+ sampleRate: 16000,
102
+ numThreads: 1,
103
+ provider: 'cpu',
104
+ debug: 1,
105
+ bufferSizeInSeconds: 30,
106
+ };
107
+
108
+ if (myConfig) {
109
+ config = myConfig;
110
+ }
111
+
112
+ return new Vad(config, Module);
113
+ }
114
+
115
+
116
+ class CircularBuffer {
117
+ constructor(capacity, Module) {
118
+ this.handle = Module._SherpaOnnxCreateCircularBuffer(capacity);
119
+ this.Module = Module;
120
+ }
121
+
122
+ free() {
123
+ this.Module._SherpaOnnxDestroyCircularBuffer(this.handle);
124
+ this.handle = 0
125
+ }
126
+
127
+ /**
128
+ * @param samples {Float32Array}
129
+ */
130
+ push(samples) {
131
+ const pointer =
132
+ this.Module._malloc(samples.length * samples.BYTES_PER_ELEMENT);
133
+ this.Module.HEAPF32.set(samples, pointer / samples.BYTES_PER_ELEMENT);
134
+ this.Module._SherpaOnnxCircularBufferPush(
135
+ this.handle, pointer, samples.length);
136
+ this.Module._free(pointer);
137
+ }
138
+
139
+ get(startIndex, n) {
140
+ const p =
141
+ this.Module._SherpaOnnxCircularBufferGet(this.handle, startIndex, n);
142
+
143
+ const samplesPtr = p / 4;
144
+ const samples = new Float32Array(n);
145
+ for (let i = 0; i < n; i++) {
146
+ samples[i] = this.Module.HEAPF32[samplesPtr + i];
147
+ }
148
+
149
+ this.Module._SherpaOnnxCircularBufferFree(p);
150
+
151
+ return samples;
152
+ }
153
+
154
+ pop(n) {
155
+ this.Module._SherpaOnnxCircularBufferPop(this.handle, n);
156
+ }
157
+
158
+ size() {
159
+ return this.Module._SherpaOnnxCircularBufferSize(this.handle);
160
+ }
161
+
162
+ head() {
163
+ return this.Module._SherpaOnnxCircularBufferHead(this.handle);
164
+ }
165
+
166
+ reset() {
167
+ this.Module._SherpaOnnxCircularBufferReset(this.handle);
168
+ }
169
+ }
170
+
171
+ class Vad {
172
+ constructor(configObj, Module) {
173
+ this.config = configObj;
174
+ const config = initSherpaOnnxVadModelConfig(configObj, Module);
175
+ const handle = Module._SherpaOnnxCreateVoiceActivityDetector(
176
+ config.ptr, configObj.bufferSizeInSeconds || 30);
177
+ freeConfig(config, Module);
178
+
179
+ this.handle = handle;
180
+ this.Module = Module;
181
+ }
182
+
183
+ free() {
184
+ this.Module._SherpaOnnxDestroyVoiceActivityDetector(this.handle);
185
+ this.handle = 0
186
+ }
187
+
188
+ // samples is a float32 array
189
+ acceptWaveform(samples) {
190
+ const pointer =
191
+ this.Module._malloc(samples.length * samples.BYTES_PER_ELEMENT);
192
+ this.Module.HEAPF32.set(samples, pointer / samples.BYTES_PER_ELEMENT);
193
+ this.Module._SherpaOnnxVoiceActivityDetectorAcceptWaveform(
194
+ this.handle, pointer, samples.length);
195
+ this.Module._free(pointer);
196
+ }
197
+
198
+ isEmpty() {
199
+ return this.Module._SherpaOnnxVoiceActivityDetectorEmpty(this.handle) == 1;
200
+ }
201
+
202
+ isDetected() {
203
+ return this.Module._SherpaOnnxVoiceActivityDetectorDetected(this.handle) ==
204
+ 1;
205
+ }
206
+
207
+ pop() {
208
+ this.Module._SherpaOnnxVoiceActivityDetectorPop(this.handle);
209
+ }
210
+
211
+ clear() {
212
+ this.Module._SherpaOnnxVoiceActivityDetectorClear(this.handle);
213
+ }
214
+
215
+ /*
216
+ {
217
+ samples: a 1-d float32 array,
218
+ start: an int32
219
+ }
220
+ */
221
+ front() {
222
+ const h = this.Module._SherpaOnnxVoiceActivityDetectorFront(this.handle);
223
+
224
+ const start = this.Module.HEAP32[h / 4];
225
+ const samplesPtr = this.Module.HEAP32[h / 4 + 1] / 4;
226
+ const numSamples = this.Module.HEAP32[h / 4 + 2];
227
+
228
+ const samples = new Float32Array(numSamples);
229
+ for (let i = 0; i < numSamples; i++) {
230
+ samples[i] = this.Module.HEAPF32[samplesPtr + i];
231
+ }
232
+
233
+ this.Module._SherpaOnnxDestroySpeechSegment(h);
234
+ return {samples: samples, start: start};
235
+ }
236
+
237
+ reset() {
238
+ this.Module._SherpaOnnxVoiceActivityDetectorReset(this.handle);
239
+ }
240
+
241
+ flush() {
242
+ this.Module._SherpaOnnxVoiceActivityDetectorFlush(this.handle);
243
+ }
244
+ };
245
+
246
+ if (typeof process == 'object' && typeof process.versions == 'object' &&
247
+ typeof process.versions.node == 'string') {
248
+ module.exports = {
249
+ createVad,
250
+ CircularBuffer,
251
+ };
252
+ }
sherpa-onnx-wasm-main-vad-asr.data ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ede0cafeb3e6144a373d63df3126365c155d702a8742933b88c6dd5b545fbdbd
3
+ size 74949766
sherpa-onnx-wasm-main-vad-asr.js ADDED
@@ -0,0 +1 @@
 
 
1
+ var Module=typeof Module!="undefined"?Module:{};if(!Module.expectedDataFileDownloads){Module.expectedDataFileDownloads=0}Module.expectedDataFileDownloads++;(function(){if(Module["ENVIRONMENT_IS_PTHREAD"]||Module["$ww"])return;var loadPackage=function(metadata){var PACKAGE_PATH="";if(typeof window==="object"){PACKAGE_PATH=window["encodeURIComponent"](window.location.pathname.toString().substring(0,window.location.pathname.toString().lastIndexOf("/"))+"/")}else if(typeof process==="undefined"&&typeof location!=="undefined"){PACKAGE_PATH=encodeURIComponent(location.pathname.toString().substring(0,location.pathname.toString().lastIndexOf("/"))+"/")}var PACKAGE_NAME="../../bin/sherpa-onnx-wasm-main-vad-asr.data";var REMOTE_PACKAGE_BASE="sherpa-onnx-wasm-main-vad-asr.data";if(typeof Module["locateFilePackage"]==="function"&&!Module["locateFile"]){Module["locateFile"]=Module["locateFilePackage"];err("warning: you defined Module.locateFilePackage, that has been renamed to Module.locateFile (using your locateFilePackage for now)")}var REMOTE_PACKAGE_NAME=Module["locateFile"]?Module["locateFile"](REMOTE_PACKAGE_BASE,""):REMOTE_PACKAGE_BASE;var REMOTE_PACKAGE_SIZE=metadata["remote_package_size"];function fetchRemotePackage(packageName,packageSize,callback,errback){if(typeof process==="object"&&typeof process.versions==="object"&&typeof process.versions.node==="string"){require("fs").readFile(packageName,function(err,contents){if(err){errback(err)}else{callback(contents.buffer)}});return}var xhr=new XMLHttpRequest;xhr.open("GET",packageName,true);xhr.responseType="arraybuffer";xhr.onprogress=function(event){var url=packageName;var size=packageSize;if(event.total)size=event.total;if(event.loaded){if(!xhr.addedTotal){xhr.addedTotal=true;if(!Module.dataFileDownloads)Module.dataFileDownloads={};Module.dataFileDownloads[url]={loaded:event.loaded,total:size}}else{Module.dataFileDownloads[url].loaded=event.loaded}var total=0;var loaded=0;var num=0;for(var download in Module.dataFileDownloads){var data=Module.dataFileDownloads[download];total+=data.total;loaded+=data.loaded;num++}total=Math.ceil(total*Module.expectedDataFileDownloads/num);if(Module["setStatus"])Module["setStatus"](`Downloading data... (${loaded}/${total})`)}else if(!Module.dataFileDownloads){if(Module["setStatus"])Module["setStatus"]("Downloading data...")}};xhr.onerror=function(event){throw new Error("NetworkError for: "+packageName)};xhr.onload=function(event){if(xhr.status==200||xhr.status==304||xhr.status==206||xhr.status==0&&xhr.response){var packageData=xhr.response;callback(packageData)}else{throw new Error(xhr.statusText+" : "+xhr.responseURL)}};xhr.send(null)}function handleError(error){console.error("package error:",error)}var fetchedCallback=null;var fetched=Module["getPreloadedPackage"]?Module["getPreloadedPackage"](REMOTE_PACKAGE_NAME,REMOTE_PACKAGE_SIZE):null;if(!fetched)fetchRemotePackage(REMOTE_PACKAGE_NAME,REMOTE_PACKAGE_SIZE,function(data){if(fetchedCallback){fetchedCallback(data);fetchedCallback=null}else{fetched=data}},handleError);function runWithFS(){function assert(check,msg){if(!check)throw msg+(new Error).stack}function DataRequest(start,end,audio){this.start=start;this.end=end;this.audio=audio}DataRequest.prototype={requests:{},open:function(mode,name){this.name=name;this.requests[name]=this;Module["addRunDependency"](`fp ${this.name}`)},send:function(){},onload:function(){var byteArray=this.byteArray.subarray(this.start,this.end);this.finish(byteArray)},finish:function(byteArray){var that=this;Module["FS_createDataFile"](this.name,null,byteArray,true,true,true);Module["removeRunDependency"](`fp ${that.name}`);this.requests[this.name]=null}};var files=metadata["files"];for(var i=0;i<files.length;++i){new DataRequest(files[i]["start"],files[i]["end"],files[i]["audio"]||0).open("GET",files[i]["filename"])}function processPackageData(arrayBuffer){assert(arrayBuffer,"Loading data file failed.");assert(arrayBuffer.constructor.name===ArrayBuffer.name,"bad input to processPackageData");var byteArray=new Uint8Array(arrayBuffer);DataRequest.prototype.byteArray=byteArray;var files=metadata["files"];for(var i=0;i<files.length;++i){DataRequest.prototype.requests[files[i].filename].onload()}Module["removeRunDependency"]("datafile_../../bin/sherpa-onnx-wasm-main-vad-asr.data")}Module["addRunDependency"]("datafile_../../bin/sherpa-onnx-wasm-main-vad-asr.data");if(!Module.preloadResults)Module.preloadResults={};Module.preloadResults[PACKAGE_NAME]={fromCache:false};if(fetched){processPackageData(fetched);fetched=null}else{fetchedCallback=processPackageData}}if(Module["calledRun"]){runWithFS()}else{if(!Module["preRun"])Module["preRun"]=[];Module["preRun"].push(runWithFS)}};loadPackage({"files":[{"filename":"/silero_vad.onnx","start":0,"end":1807522},{"filename":"/tokens.txt","start":1807522,"end":1812542},{"filename":"/transducer-decoder.onnx","start":1812542,"end":3905622},{"filename":"/transducer-encoder.onnx","start":3905622,"end":74690350},{"filename":"/transducer-joiner.onnx","start":74690350,"end":74949766}],"remote_package_size":74949766})})();var moduleOverrides=Object.assign({},Module);var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};var ENVIRONMENT_IS_WEB=typeof window=="object";var ENVIRONMENT_IS_WORKER=typeof importScripts=="function";var ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string";var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var read_,readAsync,readBinary;if(ENVIRONMENT_IS_NODE){var fs=require("fs");var nodePath=require("path");if(ENVIRONMENT_IS_WORKER){scriptDirectory=nodePath.dirname(scriptDirectory)+"/"}else{scriptDirectory=__dirname+"/"}read_=(filename,binary)=>{filename=isFileURI(filename)?new URL(filename):nodePath.normalize(filename);return fs.readFileSync(filename,binary?undefined:"utf8")};readBinary=filename=>{var ret=read_(filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}return ret};readAsync=(filename,onload,onerror,binary=true)=>{filename=isFileURI(filename)?new URL(filename):nodePath.normalize(filename);fs.readFile(filename,binary?undefined:"utf8",(err,data)=>{if(err)onerror(err);else onload(binary?data.buffer:data)})};if(!Module["thisProgram"]&&process.argv.length>1){thisProgram=process.argv[1].replace(/\\/g,"/")}arguments_=process.argv.slice(2);if(typeof module!="undefined"){module["exports"]=Module}process.on("uncaughtException",ex=>{if(ex!=="unwind"&&!(ex instanceof ExitStatus)&&!(ex.context instanceof ExitStatus)){throw ex}});quit_=(status,toThrow)=>{process.exitCode=status;throw toThrow};Module["inspect"]=()=>"[Emscripten Module object]"}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(typeof document!="undefined"&&document.currentScript){scriptDirectory=document.currentScript.src}if(scriptDirectory.indexOf("blob:")!==0){scriptDirectory=scriptDirectory.substr(0,scriptDirectory.replace(/[?#].*/,"").lastIndexOf("/")+1)}else{scriptDirectory=""}{read_=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=(url,onload,onerror)=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=()=>{if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}onerror()};xhr.onerror=onerror;xhr.send(null)}}}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.error.bind(console);Object.assign(Module,moduleOverrides);moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["quit"])quit_=Module["quit"];var wasmBinary;if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];if(typeof WebAssembly!="object"){abort("no native wasm support detected")}var wasmMemory;var ABORT=false;var EXITSTATUS;function assert(condition,text){if(!condition){abort(text)}}var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateMemoryViews(){var b=wasmMemory.buffer;Module["HEAP8"]=HEAP8=new Int8Array(b);Module["HEAP16"]=HEAP16=new Int16Array(b);Module["HEAPU8"]=HEAPU8=new Uint8Array(b);Module["HEAPU16"]=HEAPU16=new Uint16Array(b);Module["HEAP32"]=HEAP32=new Int32Array(b);Module["HEAPU32"]=HEAPU32=new Uint32Array(b);Module["HEAPF32"]=HEAPF32=new Float32Array(b);Module["HEAPF64"]=HEAPF64=new Float64Array(b)}var __ATPRERUN__=[];var __ATINIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=true;if(!Module["noFSInit"]&&!FS.init.initialized)FS.init();FS.ignorePermissions=false;TTY.init();callRuntimeCallbacks(__ATINIT__)}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnInit(cb){__ATINIT__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function getUniqueRunDependency(id){return id}function addRunDependency(id){runDependencies++;Module["monitorRunDependencies"]?.(runDependencies)}function removeRunDependency(id){runDependencies--;Module["monitorRunDependencies"]?.(runDependencies);if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}function abort(what){Module["onAbort"]?.(what);what="Aborted("+what+")";err(what);ABORT=true;EXITSTATUS=1;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);throw e}var dataURIPrefix="data:application/octet-stream;base64,";var isDataURI=filename=>filename.startsWith(dataURIPrefix);var isFileURI=filename=>filename.startsWith("file://");var wasmBinaryFile;wasmBinaryFile="sherpa-onnx-wasm-main-vad-asr.wasm";if(!isDataURI(wasmBinaryFile)){wasmBinaryFile=locateFile(wasmBinaryFile)}function getBinarySync(file){if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}function getBinaryPromise(binaryFile){if(!wasmBinary&&(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)){if(typeof fetch=="function"&&!isFileURI(binaryFile)){return fetch(binaryFile,{credentials:"same-origin"}).then(response=>{if(!response["ok"]){throw"failed to load wasm binary file at '"+binaryFile+"'"}return response["arrayBuffer"]()}).catch(()=>getBinarySync(binaryFile))}else if(readAsync){return new Promise((resolve,reject)=>{readAsync(binaryFile,response=>resolve(new Uint8Array(response)),reject)})}}return Promise.resolve().then(()=>getBinarySync(binaryFile))}function instantiateArrayBuffer(binaryFile,imports,receiver){return getBinaryPromise(binaryFile).then(binary=>WebAssembly.instantiate(binary,imports)).then(instance=>instance).then(receiver,reason=>{err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)})}function instantiateAsync(binary,binaryFile,imports,callback){if(!binary&&typeof WebAssembly.instantiateStreaming=="function"&&!isDataURI(binaryFile)&&!isFileURI(binaryFile)&&!ENVIRONMENT_IS_NODE&&typeof fetch=="function"){return fetch(binaryFile,{credentials:"same-origin"}).then(response=>{var result=WebAssembly.instantiateStreaming(response,imports);return result.then(callback,function(reason){err(`wasm streaming compile failed: ${reason}`);err("falling back to ArrayBuffer instantiation");return instantiateArrayBuffer(binaryFile,imports,callback)})})}return instantiateArrayBuffer(binaryFile,imports,callback)}function createWasm(){var info={"a":wasmImports};function receiveInstance(instance,module){wasmExports=instance.exports;wasmMemory=wasmExports["L"];updateMemoryViews();addOnInit(wasmExports["M"]);removeRunDependency("wasm-instantiate");return wasmExports}addRunDependency("wasm-instantiate");function receiveInstantiationResult(result){receiveInstance(result["instance"])}if(Module["instantiateWasm"]){try{return Module["instantiateWasm"](info,receiveInstance)}catch(e){err(`Module.instantiateWasm callback failed with error: ${e}`);return false}}instantiateAsync(wasmBinary,wasmBinaryFile,info,receiveInstantiationResult);return{}}var tempDouble;var tempI64;var ASM_CONSTS={1006448:($0,$1,$2,$3)=>{if(typeof Module=="undefined"||!Module.MountedFiles){return 1}let fileName=UTF8ToString($0>>>0);if(fileName.startsWith("./")){fileName=fileName.substring(2)}const fileData=Module.MountedFiles.get(fileName);if(!fileData){return 2}const offset=$1>>>0;const length=$2>>>0;const buffer=$3>>>0;if(offset+length>fileData.byteLength){return 3}try{HEAPU8.set(fileData.subarray(offset,offset+length),buffer);return 0}catch{return 4}}};function ExitStatus(status){this.name="ExitStatus";this.message=`Program terminated with exit(${status})`;this.status=status}var callRuntimeCallbacks=callbacks=>{while(callbacks.length>0){callbacks.shift()(Module)}};function getValue(ptr,type="i8"){if(type.endsWith("*"))type="*";switch(type){case"i1":return HEAP8[ptr>>0];case"i8":return HEAP8[ptr>>0];case"i16":return HEAP16[ptr>>1];case"i32":return HEAP32[ptr>>2];case"i64":abort("to do getValue(i64) use WASM_BIGINT");case"float":return HEAPF32[ptr>>2];case"double":return HEAPF64[ptr>>3];case"*":return HEAPU32[ptr>>2];default:abort(`invalid type for getValue: ${type}`)}}var noExitRuntime=Module["noExitRuntime"]||true;function setValue(ptr,value,type="i8"){if(type.endsWith("*"))type="*";switch(type){case"i1":HEAP8[ptr>>0]=value;break;case"i8":HEAP8[ptr>>0]=value;break;case"i16":HEAP16[ptr>>1]=value;break;case"i32":HEAP32[ptr>>2]=value;break;case"i64":abort("to do setValue(i64) use WASM_BIGINT");case"float":HEAPF32[ptr>>2]=value;break;case"double":HEAPF64[ptr>>3]=value;break;case"*":HEAPU32[ptr>>2]=value;break;default:abort(`invalid type for setValue: ${type}`)}}function ExceptionInfo(excPtr){this.excPtr=excPtr;this.ptr=excPtr-24;this.set_type=function(type){HEAPU32[this.ptr+4>>2]=type};this.get_type=function(){return HEAPU32[this.ptr+4>>2]};this.set_destructor=function(destructor){HEAPU32[this.ptr+8>>2]=destructor};this.get_destructor=function(){return HEAPU32[this.ptr+8>>2]};this.set_caught=function(caught){caught=caught?1:0;HEAP8[this.ptr+12>>0]=caught};this.get_caught=function(){return HEAP8[this.ptr+12>>0]!=0};this.set_rethrown=function(rethrown){rethrown=rethrown?1:0;HEAP8[this.ptr+13>>0]=rethrown};this.get_rethrown=function(){return HEAP8[this.ptr+13>>0]!=0};this.init=function(type,destructor){this.set_adjusted_ptr(0);this.set_type(type);this.set_destructor(destructor)};this.set_adjusted_ptr=function(adjustedPtr){HEAPU32[this.ptr+16>>2]=adjustedPtr};this.get_adjusted_ptr=function(){return HEAPU32[this.ptr+16>>2]};this.get_exception_ptr=function(){var isPointer=___cxa_is_pointer_type(this.get_type());if(isPointer){return HEAPU32[this.excPtr>>2]}var adjusted=this.get_adjusted_ptr();if(adjusted!==0)return adjusted;return this.excPtr}}var exceptionLast=0;var uncaughtExceptionCount=0;var ___cxa_throw=(ptr,type,destructor)=>{var info=new ExceptionInfo(ptr);info.init(type,destructor);exceptionLast=ptr;uncaughtExceptionCount++;throw exceptionLast};var setErrNo=value=>{HEAP32[___errno_location()>>2]=value;return value};var PATH={isAbs:path=>path.charAt(0)==="/",splitPath:filename=>{var splitPathRe=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return splitPathRe.exec(filename).slice(1)},normalizeArray:(parts,allowAboveRoot)=>{var up=0;for(var i=parts.length-1;i>=0;i--){var last=parts[i];if(last==="."){parts.splice(i,1)}else if(last===".."){parts.splice(i,1);up++}else if(up){parts.splice(i,1);up--}}if(allowAboveRoot){for(;up;up--){parts.unshift("..")}}return parts},normalize:path=>{var isAbsolute=PATH.isAbs(path),trailingSlash=path.substr(-1)==="/";path=PATH.normalizeArray(path.split("/").filter(p=>!!p),!isAbsolute).join("/");if(!path&&!isAbsolute){path="."}if(path&&trailingSlash){path+="/"}return(isAbsolute?"/":"")+path},dirname:path=>{var result=PATH.splitPath(path),root=result[0],dir=result[1];if(!root&&!dir){return"."}if(dir){dir=dir.substr(0,dir.length-1)}return root+dir},basename:path=>{if(path==="/")return"/";path=PATH.normalize(path);path=path.replace(/\/$/,"");var lastSlash=path.lastIndexOf("/");if(lastSlash===-1)return path;return path.substr(lastSlash+1)},join:function(){var paths=Array.prototype.slice.call(arguments);return PATH.normalize(paths.join("/"))},join2:(l,r)=>PATH.normalize(l+"/"+r)};var initRandomFill=()=>{if(typeof crypto=="object"&&typeof crypto["getRandomValues"]=="function"){return view=>crypto.getRandomValues(view)}else if(ENVIRONMENT_IS_NODE){try{var crypto_module=require("crypto");var randomFillSync=crypto_module["randomFillSync"];if(randomFillSync){return view=>crypto_module["randomFillSync"](view)}var randomBytes=crypto_module["randomBytes"];return view=>(view.set(randomBytes(view.byteLength)),view)}catch(e){}}abort("initRandomDevice")};var randomFill=view=>(randomFill=initRandomFill())(view);var PATH_FS={resolve:function(){var resolvedPath="",resolvedAbsolute=false;for(var i=arguments.length-1;i>=-1&&!resolvedAbsolute;i--){var path=i>=0?arguments[i]:FS.cwd();if(typeof path!="string"){throw new TypeError("Arguments to path.resolve must be strings")}else if(!path){return""}resolvedPath=path+"/"+resolvedPath;resolvedAbsolute=PATH.isAbs(path)}resolvedPath=PATH.normalizeArray(resolvedPath.split("/").filter(p=>!!p),!resolvedAbsolute).join("/");return(resolvedAbsolute?"/":"")+resolvedPath||"."},relative:(from,to)=>{from=PATH_FS.resolve(from).substr(1);to=PATH_FS.resolve(to).substr(1);function trim(arr){var start=0;for(;start<arr.length;start++){if(arr[start]!=="")break}var end=arr.length-1;for(;end>=0;end--){if(arr[end]!=="")break}if(start>end)return[];return arr.slice(start,end-start+1)}var fromParts=trim(from.split("/"));var toParts=trim(to.split("/"));var length=Math.min(fromParts.length,toParts.length);var samePartsLength=length;for(var i=0;i<length;i++){if(fromParts[i]!==toParts[i]){samePartsLength=i;break}}var outputParts=[];for(var i=samePartsLength;i<fromParts.length;i++){outputParts.push("..")}outputParts=outputParts.concat(toParts.slice(samePartsLength));return outputParts.join("/")}};var UTF8Decoder=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):undefined;var UTF8ArrayToString=(heapOrArray,idx,maxBytesToRead)=>{var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heapOrArray[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr))}var str="";while(idx<endPtr){var u0=heapOrArray[idx++];if(!(u0&128)){str+=String.fromCharCode(u0);continue}var u1=heapOrArray[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}var u2=heapOrArray[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u0=(u0&7)<<18|u1<<12|u2<<6|heapOrArray[idx++]&63}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}return str};var FS_stdin_getChar_buffer=[];var lengthBytesUTF8=str=>{var len=0;for(var i=0;i<str.length;++i){var c=str.charCodeAt(i);if(c<=127){len++}else if(c<=2047){len+=2}else if(c>=55296&&c<=57343){len+=4;++i}else{len+=3}}return len};var stringToUTF8Array=(str,heap,outIdx,maxBytesToWrite)=>{if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i<str.length;++i){var u=str.charCodeAt(i);if(u>=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}}heap[outIdx]=0;return outIdx-startIdx};function intArrayFromString(stringy,dontAddNull,length){var len=length>0?length:lengthBytesUTF8(stringy)+1;var u8array=new Array(len);var numBytesWritten=stringToUTF8Array(stringy,u8array,0,u8array.length);if(dontAddNull)u8array.length=numBytesWritten;return u8array}var FS_stdin_getChar=()=>{if(!FS_stdin_getChar_buffer.length){var result=null;if(ENVIRONMENT_IS_NODE){var BUFSIZE=256;var buf=Buffer.alloc(BUFSIZE);var bytesRead=0;var fd=process.stdin.fd;try{bytesRead=fs.readSync(fd,buf)}catch(e){if(e.toString().includes("EOF"))bytesRead=0;else throw e}if(bytesRead>0){result=buf.slice(0,bytesRead).toString("utf-8")}else{result=null}}else if(typeof window!="undefined"&&typeof window.prompt=="function"){result=window.prompt("Input: ");if(result!==null){result+="\n"}}else if(typeof readline=="function"){result=readline();if(result!==null){result+="\n"}}if(!result){return null}FS_stdin_getChar_buffer=intArrayFromString(result,true)}return FS_stdin_getChar_buffer.shift()};var TTY={ttys:[],init(){},shutdown(){},register(dev,ops){TTY.ttys[dev]={input:[],output:[],ops:ops};FS.registerDevice(dev,TTY.stream_ops)},stream_ops:{open(stream){var tty=TTY.ttys[stream.node.rdev];if(!tty){throw new FS.ErrnoError(43)}stream.tty=tty;stream.seekable=false},close(stream){stream.tty.ops.fsync(stream.tty)},fsync(stream){stream.tty.ops.fsync(stream.tty)},read(stream,buffer,offset,length,pos){if(!stream.tty||!stream.tty.ops.get_char){throw new FS.ErrnoError(60)}var bytesRead=0;for(var i=0;i<length;i++){var result;try{result=stream.tty.ops.get_char(stream.tty)}catch(e){throw new FS.ErrnoError(29)}if(result===undefined&&bytesRead===0){throw new FS.ErrnoError(6)}if(result===null||result===undefined)break;bytesRead++;buffer[offset+i]=result}if(bytesRead){stream.node.timestamp=Date.now()}return bytesRead},write(stream,buffer,offset,length,pos){if(!stream.tty||!stream.tty.ops.put_char){throw new FS.ErrnoError(60)}try{for(var i=0;i<length;i++){stream.tty.ops.put_char(stream.tty,buffer[offset+i])}}catch(e){throw new FS.ErrnoError(29)}if(length){stream.node.timestamp=Date.now()}return i}},default_tty_ops:{get_char(tty){return FS_stdin_getChar()},put_char(tty,val){if(val===null||val===10){out(UTF8ArrayToString(tty.output,0));tty.output=[]}else{if(val!=0)tty.output.push(val)}},fsync(tty){if(tty.output&&tty.output.length>0){out(UTF8ArrayToString(tty.output,0));tty.output=[]}},ioctl_tcgets(tty){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets(tty,optional_actions,data){return 0},ioctl_tiocgwinsz(tty){return[24,80]}},default_tty1_ops:{put_char(tty,val){if(val===null||val===10){err(UTF8ArrayToString(tty.output,0));tty.output=[]}else{if(val!=0)tty.output.push(val)}},fsync(tty){if(tty.output&&tty.output.length>0){err(UTF8ArrayToString(tty.output,0));tty.output=[]}}}};var zeroMemory=(address,size)=>{HEAPU8.fill(0,address,address+size);return address};var alignMemory=(size,alignment)=>Math.ceil(size/alignment)*alignment;var mmapAlloc=size=>{size=alignMemory(size,65536);var ptr=_emscripten_builtin_memalign(65536,size);if(!ptr)return 0;return zeroMemory(ptr,size)};var MEMFS={ops_table:null,mount(mount){return MEMFS.createNode(null,"/",16384|511,0)},createNode(parent,name,mode,dev){if(FS.isBlkdev(mode)||FS.isFIFO(mode)){throw new FS.ErrnoError(63)}MEMFS.ops_table||={dir:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,lookup:MEMFS.node_ops.lookup,mknod:MEMFS.node_ops.mknod,rename:MEMFS.node_ops.rename,unlink:MEMFS.node_ops.unlink,rmdir:MEMFS.node_ops.rmdir,readdir:MEMFS.node_ops.readdir,symlink:MEMFS.node_ops.symlink},stream:{llseek:MEMFS.stream_ops.llseek}},file:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:{llseek:MEMFS.stream_ops.llseek,read:MEMFS.stream_ops.read,write:MEMFS.stream_ops.write,allocate:MEMFS.stream_ops.allocate,mmap:MEMFS.stream_ops.mmap,msync:MEMFS.stream_ops.msync}},link:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,readlink:MEMFS.node_ops.readlink},stream:{}},chrdev:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:FS.chrdev_stream_ops}};var node=FS.createNode(parent,name,mode,dev);if(FS.isDir(node.mode)){node.node_ops=MEMFS.ops_table.dir.node;node.stream_ops=MEMFS.ops_table.dir.stream;node.contents={}}else if(FS.isFile(node.mode)){node.node_ops=MEMFS.ops_table.file.node;node.stream_ops=MEMFS.ops_table.file.stream;node.usedBytes=0;node.contents=null}else if(FS.isLink(node.mode)){node.node_ops=MEMFS.ops_table.link.node;node.stream_ops=MEMFS.ops_table.link.stream}else if(FS.isChrdev(node.mode)){node.node_ops=MEMFS.ops_table.chrdev.node;node.stream_ops=MEMFS.ops_table.chrdev.stream}node.timestamp=Date.now();if(parent){parent.contents[name]=node;parent.timestamp=node.timestamp}return node},getFileDataAsTypedArray(node){if(!node.contents)return new Uint8Array(0);if(node.contents.subarray)return node.contents.subarray(0,node.usedBytes);return new Uint8Array(node.contents)},expandFileStorage(node,newCapacity){var prevCapacity=node.contents?node.contents.length:0;if(prevCapacity>=newCapacity)return;var CAPACITY_DOUBLING_MAX=1024*1024;newCapacity=Math.max(newCapacity,prevCapacity*(prevCapacity<CAPACITY_DOUBLING_MAX?2:1.125)>>>0);if(prevCapacity!=0)newCapacity=Math.max(newCapacity,256);var oldContents=node.contents;node.contents=new Uint8Array(newCapacity);if(node.usedBytes>0)node.contents.set(oldContents.subarray(0,node.usedBytes),0)},resizeFileStorage(node,newSize){if(node.usedBytes==newSize)return;if(newSize==0){node.contents=null;node.usedBytes=0}else{var oldContents=node.contents;node.contents=new Uint8Array(newSize);if(oldContents){node.contents.set(oldContents.subarray(0,Math.min(newSize,node.usedBytes)))}node.usedBytes=newSize}},node_ops:{getattr(node){var attr={};attr.dev=FS.isChrdev(node.mode)?node.id:1;attr.ino=node.id;attr.mode=node.mode;attr.nlink=1;attr.uid=0;attr.gid=0;attr.rdev=node.rdev;if(FS.isDir(node.mode)){attr.size=4096}else if(FS.isFile(node.mode)){attr.size=node.usedBytes}else if(FS.isLink(node.mode)){attr.size=node.link.length}else{attr.size=0}attr.atime=new Date(node.timestamp);attr.mtime=new Date(node.timestamp);attr.ctime=new Date(node.timestamp);attr.blksize=4096;attr.blocks=Math.ceil(attr.size/attr.blksize);return attr},setattr(node,attr){if(attr.mode!==undefined){node.mode=attr.mode}if(attr.timestamp!==undefined){node.timestamp=attr.timestamp}if(attr.size!==undefined){MEMFS.resizeFileStorage(node,attr.size)}},lookup(parent,name){throw FS.genericErrors[44]},mknod(parent,name,mode,dev){return MEMFS.createNode(parent,name,mode,dev)},rename(old_node,new_dir,new_name){if(FS.isDir(old_node.mode)){var new_node;try{new_node=FS.lookupNode(new_dir,new_name)}catch(e){}if(new_node){for(var i in new_node.contents){throw new FS.ErrnoError(55)}}}delete old_node.parent.contents[old_node.name];old_node.parent.timestamp=Date.now();old_node.name=new_name;new_dir.contents[new_name]=old_node;new_dir.timestamp=old_node.parent.timestamp;old_node.parent=new_dir},unlink(parent,name){delete parent.contents[name];parent.timestamp=Date.now()},rmdir(parent,name){var node=FS.lookupNode(parent,name);for(var i in node.contents){throw new FS.ErrnoError(55)}delete parent.contents[name];parent.timestamp=Date.now()},readdir(node){var entries=[".",".."];for(var key of Object.keys(node.contents)){entries.push(key)}return entries},symlink(parent,newname,oldpath){var node=MEMFS.createNode(parent,newname,511|40960,0);node.link=oldpath;return node},readlink(node){if(!FS.isLink(node.mode)){throw new FS.ErrnoError(28)}return node.link}},stream_ops:{read(stream,buffer,offset,length,position){var contents=stream.node.contents;if(position>=stream.node.usedBytes)return 0;var size=Math.min(stream.node.usedBytes-position,length);if(size>8&&contents.subarray){buffer.set(contents.subarray(position,position+size),offset)}else{for(var i=0;i<size;i++)buffer[offset+i]=contents[position+i]}return size},write(stream,buffer,offset,length,position,canOwn){if(buffer.buffer===HEAP8.buffer){canOwn=false}if(!length)return 0;var node=stream.node;node.timestamp=Date.now();if(buffer.subarray&&(!node.contents||node.contents.subarray)){if(canOwn){node.contents=buffer.subarray(offset,offset+length);node.usedBytes=length;return length}else if(node.usedBytes===0&&position===0){node.contents=buffer.slice(offset,offset+length);node.usedBytes=length;return length}else if(position+length<=node.usedBytes){node.contents.set(buffer.subarray(offset,offset+length),position);return length}}MEMFS.expandFileStorage(node,position+length);if(node.contents.subarray&&buffer.subarray){node.contents.set(buffer.subarray(offset,offset+length),position)}else{for(var i=0;i<length;i++){node.contents[position+i]=buffer[offset+i]}}node.usedBytes=Math.max(node.usedBytes,position+length);return length},llseek(stream,offset,whence){var position=offset;if(whence===1){position+=stream.position}else if(whence===2){if(FS.isFile(stream.node.mode)){position+=stream.node.usedBytes}}if(position<0){throw new FS.ErrnoError(28)}return position},allocate(stream,offset,length){MEMFS.expandFileStorage(stream.node,offset+length);stream.node.usedBytes=Math.max(stream.node.usedBytes,offset+length)},mmap(stream,length,position,prot,flags){if(!FS.isFile(stream.node.mode)){throw new FS.ErrnoError(43)}var ptr;var allocated;var contents=stream.node.contents;if(!(flags&2)&&contents.buffer===HEAP8.buffer){allocated=false;ptr=contents.byteOffset}else{if(position>0||position+length<contents.length){if(contents.subarray){contents=contents.subarray(position,position+length)}else{contents=Array.prototype.slice.call(contents,position,position+length)}}allocated=true;ptr=mmapAlloc(length);if(!ptr){throw new FS.ErrnoError(48)}HEAP8.set(contents,ptr)}return{ptr:ptr,allocated:allocated}},msync(stream,buffer,offset,length,mmapFlags){MEMFS.stream_ops.write(stream,buffer,0,length,offset,false);return 0}}};var asyncLoad=(url,onload,onerror,noRunDep)=>{var dep=!noRunDep?getUniqueRunDependency(`al ${url}`):"";readAsync(url,arrayBuffer=>{assert(arrayBuffer,`Loading data file "${url}" failed (no arrayBuffer).`);onload(new Uint8Array(arrayBuffer));if(dep)removeRunDependency(dep)},event=>{if(onerror){onerror()}else{throw`Loading data file "${url}" failed.`}});if(dep)addRunDependency(dep)};var FS_createDataFile=(parent,name,fileData,canRead,canWrite,canOwn)=>{FS.createDataFile(parent,name,fileData,canRead,canWrite,canOwn)};var preloadPlugins=Module["preloadPlugins"]||[];var FS_handledByPreloadPlugin=(byteArray,fullname,finish,onerror)=>{if(typeof Browser!="undefined")Browser.init();var handled=false;preloadPlugins.forEach(plugin=>{if(handled)return;if(plugin["canHandle"](fullname)){plugin["handle"](byteArray,fullname,finish,onerror);handled=true}});return handled};var FS_createPreloadedFile=(parent,name,url,canRead,canWrite,onload,onerror,dontCreateFile,canOwn,preFinish)=>{var fullname=name?PATH_FS.resolve(PATH.join2(parent,name)):parent;var dep=getUniqueRunDependency(`cp ${fullname}`);function processData(byteArray){function finish(byteArray){preFinish?.();if(!dontCreateFile){FS_createDataFile(parent,name,byteArray,canRead,canWrite,canOwn)}onload?.();removeRunDependency(dep)}if(FS_handledByPreloadPlugin(byteArray,fullname,finish,()=>{onerror?.();removeRunDependency(dep)})){return}finish(byteArray)}addRunDependency(dep);if(typeof url=="string"){asyncLoad(url,byteArray=>processData(byteArray),onerror)}else{processData(url)}};var FS_modeStringToFlags=str=>{var flagModes={"r":0,"r+":2,"w":512|64|1,"w+":512|64|2,"a":1024|64|1,"a+":1024|64|2};var flags=flagModes[str];if(typeof flags=="undefined"){throw new Error(`Unknown file open mode: ${str}`)}return flags};var FS_getMode=(canRead,canWrite)=>{var mode=0;if(canRead)mode|=292|73;if(canWrite)mode|=146;return mode};var FS={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:false,ignorePermissions:true,ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,lookupPath(path,opts={}){path=PATH_FS.resolve(path);if(!path)return{path:"",node:null};var defaults={follow_mount:true,recurse_count:0};opts=Object.assign(defaults,opts);if(opts.recurse_count>8){throw new FS.ErrnoError(32)}var parts=path.split("/").filter(p=>!!p);var current=FS.root;var current_path="/";for(var i=0;i<parts.length;i++){var islast=i===parts.length-1;if(islast&&opts.parent){break}current=FS.lookupNode(current,parts[i]);current_path=PATH.join2(current_path,parts[i]);if(FS.isMountpoint(current)){if(!islast||islast&&opts.follow_mount){current=current.mounted.root}}if(!islast||opts.follow){var count=0;while(FS.isLink(current.mode)){var link=FS.readlink(current_path);current_path=PATH_FS.resolve(PATH.dirname(current_path),link);var lookup=FS.lookupPath(current_path,{recurse_count:opts.recurse_count+1});current=lookup.node;if(count++>40){throw new FS.ErrnoError(32)}}}}return{path:current_path,node:current}},getPath(node){var path;while(true){if(FS.isRoot(node)){var mount=node.mount.mountpoint;if(!path)return mount;return mount[mount.length-1]!=="/"?`${mount}/${path}`:mount+path}path=path?`${node.name}/${path}`:node.name;node=node.parent}},hashName(parentid,name){var hash=0;for(var i=0;i<name.length;i++){hash=(hash<<5)-hash+name.charCodeAt(i)|0}return(parentid+hash>>>0)%FS.nameTable.length},hashAddNode(node){var hash=FS.hashName(node.parent.id,node.name);node.name_next=FS.nameTable[hash];FS.nameTable[hash]=node},hashRemoveNode(node){var hash=FS.hashName(node.parent.id,node.name);if(FS.nameTable[hash]===node){FS.nameTable[hash]=node.name_next}else{var current=FS.nameTable[hash];while(current){if(current.name_next===node){current.name_next=node.name_next;break}current=current.name_next}}},lookupNode(parent,name){var errCode=FS.mayLookup(parent);if(errCode){throw new FS.ErrnoError(errCode,parent)}var hash=FS.hashName(parent.id,name);for(var node=FS.nameTable[hash];node;node=node.name_next){var nodeName=node.name;if(node.parent.id===parent.id&&nodeName===name){return node}}return FS.lookup(parent,name)},createNode(parent,name,mode,rdev){var node=new FS.FSNode(parent,name,mode,rdev);FS.hashAddNode(node);return node},destroyNode(node){FS.hashRemoveNode(node)},isRoot(node){return node===node.parent},isMountpoint(node){return!!node.mounted},isFile(mode){return(mode&61440)===32768},isDir(mode){return(mode&61440)===16384},isLink(mode){return(mode&61440)===40960},isChrdev(mode){return(mode&61440)===8192},isBlkdev(mode){return(mode&61440)===24576},isFIFO(mode){return(mode&61440)===4096},isSocket(mode){return(mode&49152)===49152},flagsToPermissionString(flag){var perms=["r","w","rw"][flag&3];if(flag&512){perms+="w"}return perms},nodePermissions(node,perms){if(FS.ignorePermissions){return 0}if(perms.includes("r")&&!(node.mode&292)){return 2}else if(perms.includes("w")&&!(node.mode&146)){return 2}else if(perms.includes("x")&&!(node.mode&73)){return 2}return 0},mayLookup(dir){var errCode=FS.nodePermissions(dir,"x");if(errCode)return errCode;if(!dir.node_ops.lookup)return 2;return 0},mayCreate(dir,name){try{var node=FS.lookupNode(dir,name);return 20}catch(e){}return FS.nodePermissions(dir,"wx")},mayDelete(dir,name,isdir){var node;try{node=FS.lookupNode(dir,name)}catch(e){return e.errno}var errCode=FS.nodePermissions(dir,"wx");if(errCode){return errCode}if(isdir){if(!FS.isDir(node.mode)){return 54}if(FS.isRoot(node)||FS.getPath(node)===FS.cwd()){return 10}}else{if(FS.isDir(node.mode)){return 31}}return 0},mayOpen(node,flags){if(!node){return 44}if(FS.isLink(node.mode)){return 32}else if(FS.isDir(node.mode)){if(FS.flagsToPermissionString(flags)!=="r"||flags&512){return 31}}return FS.nodePermissions(node,FS.flagsToPermissionString(flags))},MAX_OPEN_FDS:4096,nextfd(){for(var fd=0;fd<=FS.MAX_OPEN_FDS;fd++){if(!FS.streams[fd]){return fd}}throw new FS.ErrnoError(33)},getStreamChecked(fd){var stream=FS.getStream(fd);if(!stream){throw new FS.ErrnoError(8)}return stream},getStream:fd=>FS.streams[fd],createStream(stream,fd=-1){if(!FS.FSStream){FS.FSStream=function(){this.shared={}};FS.FSStream.prototype={};Object.defineProperties(FS.FSStream.prototype,{object:{get(){return this.node},set(val){this.node=val}},isRead:{get(){return(this.flags&2097155)!==1}},isWrite:{get(){return(this.flags&2097155)!==0}},isAppend:{get(){return this.flags&1024}},flags:{get(){return this.shared.flags},set(val){this.shared.flags=val}},position:{get(){return this.shared.position},set(val){this.shared.position=val}}})}stream=Object.assign(new FS.FSStream,stream);if(fd==-1){fd=FS.nextfd()}stream.fd=fd;FS.streams[fd]=stream;return stream},closeStream(fd){FS.streams[fd]=null},chrdev_stream_ops:{open(stream){var device=FS.getDevice(stream.node.rdev);stream.stream_ops=device.stream_ops;stream.stream_ops.open?.(stream)},llseek(){throw new FS.ErrnoError(70)}},major:dev=>dev>>8,minor:dev=>dev&255,makedev:(ma,mi)=>ma<<8|mi,registerDevice(dev,ops){FS.devices[dev]={stream_ops:ops}},getDevice:dev=>FS.devices[dev],getMounts(mount){var mounts=[];var check=[mount];while(check.length){var m=check.pop();mounts.push(m);check.push.apply(check,m.mounts)}return mounts},syncfs(populate,callback){if(typeof populate=="function"){callback=populate;populate=false}FS.syncFSRequests++;if(FS.syncFSRequests>1){err(`warning: ${FS.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`)}var mounts=FS.getMounts(FS.root.mount);var completed=0;function doCallback(errCode){FS.syncFSRequests--;return callback(errCode)}function done(errCode){if(errCode){if(!done.errored){done.errored=true;return doCallback(errCode)}return}if(++completed>=mounts.length){doCallback(null)}}mounts.forEach(mount=>{if(!mount.type.syncfs){return done(null)}mount.type.syncfs(mount,populate,done)})},mount(type,opts,mountpoint){var root=mountpoint==="/";var pseudo=!mountpoint;var node;if(root&&FS.root){throw new FS.ErrnoError(10)}else if(!root&&!pseudo){var lookup=FS.lookupPath(mountpoint,{follow_mount:false});mountpoint=lookup.path;node=lookup.node;if(FS.isMountpoint(node)){throw new FS.ErrnoError(10)}if(!FS.isDir(node.mode)){throw new FS.ErrnoError(54)}}var mount={type:type,opts:opts,mountpoint:mountpoint,mounts:[]};var mountRoot=type.mount(mount);mountRoot.mount=mount;mount.root=mountRoot;if(root){FS.root=mountRoot}else if(node){node.mounted=mount;if(node.mount){node.mount.mounts.push(mount)}}return mountRoot},unmount(mountpoint){var lookup=FS.lookupPath(mountpoint,{follow_mount:false});if(!FS.isMountpoint(lookup.node)){throw new FS.ErrnoError(28)}var node=lookup.node;var mount=node.mounted;var mounts=FS.getMounts(mount);Object.keys(FS.nameTable).forEach(hash=>{var current=FS.nameTable[hash];while(current){var next=current.name_next;if(mounts.includes(current.mount)){FS.destroyNode(current)}current=next}});node.mounted=null;var idx=node.mount.mounts.indexOf(mount);node.mount.mounts.splice(idx,1)},lookup(parent,name){return parent.node_ops.lookup(parent,name)},mknod(path,mode,dev){var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;var name=PATH.basename(path);if(!name||name==="."||name===".."){throw new FS.ErrnoError(28)}var errCode=FS.mayCreate(parent,name);if(errCode){throw new FS.ErrnoError(errCode)}if(!parent.node_ops.mknod){throw new FS.ErrnoError(63)}return parent.node_ops.mknod(parent,name,mode,dev)},create(path,mode){mode=mode!==undefined?mode:438;mode&=4095;mode|=32768;return FS.mknod(path,mode,0)},mkdir(path,mode){mode=mode!==undefined?mode:511;mode&=511|512;mode|=16384;return FS.mknod(path,mode,0)},mkdirTree(path,mode){var dirs=path.split("/");var d="";for(var i=0;i<dirs.length;++i){if(!dirs[i])continue;d+="/"+dirs[i];try{FS.mkdir(d,mode)}catch(e){if(e.errno!=20)throw e}}},mkdev(path,mode,dev){if(typeof dev=="undefined"){dev=mode;mode=438}mode|=8192;return FS.mknod(path,mode,dev)},symlink(oldpath,newpath){if(!PATH_FS.resolve(oldpath)){throw new FS.ErrnoError(44)}var lookup=FS.lookupPath(newpath,{parent:true});var parent=lookup.node;if(!parent){throw new FS.ErrnoError(44)}var newname=PATH.basename(newpath);var errCode=FS.mayCreate(parent,newname);if(errCode){throw new FS.ErrnoError(errCode)}if(!parent.node_ops.symlink){throw new FS.ErrnoError(63)}return parent.node_ops.symlink(parent,newname,oldpath)},rename(old_path,new_path){var old_dirname=PATH.dirname(old_path);var new_dirname=PATH.dirname(new_path);var old_name=PATH.basename(old_path);var new_name=PATH.basename(new_path);var lookup,old_dir,new_dir;lookup=FS.lookupPath(old_path,{parent:true});old_dir=lookup.node;lookup=FS.lookupPath(new_path,{parent:true});new_dir=lookup.node;if(!old_dir||!new_dir)throw new FS.ErrnoError(44);if(old_dir.mount!==new_dir.mount){throw new FS.ErrnoError(75)}var old_node=FS.lookupNode(old_dir,old_name);var relative=PATH_FS.relative(old_path,new_dirname);if(relative.charAt(0)!=="."){throw new FS.ErrnoError(28)}relative=PATH_FS.relative(new_path,old_dirname);if(relative.charAt(0)!=="."){throw new FS.ErrnoError(55)}var new_node;try{new_node=FS.lookupNode(new_dir,new_name)}catch(e){}if(old_node===new_node){return}var isdir=FS.isDir(old_node.mode);var errCode=FS.mayDelete(old_dir,old_name,isdir);if(errCode){throw new FS.ErrnoError(errCode)}errCode=new_node?FS.mayDelete(new_dir,new_name,isdir):FS.mayCreate(new_dir,new_name);if(errCode){throw new FS.ErrnoError(errCode)}if(!old_dir.node_ops.rename){throw new FS.ErrnoError(63)}if(FS.isMountpoint(old_node)||new_node&&FS.isMountpoint(new_node)){throw new FS.ErrnoError(10)}if(new_dir!==old_dir){errCode=FS.nodePermissions(old_dir,"w");if(errCode){throw new FS.ErrnoError(errCode)}}FS.hashRemoveNode(old_node);try{old_dir.node_ops.rename(old_node,new_dir,new_name)}catch(e){throw e}finally{FS.hashAddNode(old_node)}},rmdir(path){var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;var name=PATH.basename(path);var node=FS.lookupNode(parent,name);var errCode=FS.mayDelete(parent,name,true);if(errCode){throw new FS.ErrnoError(errCode)}if(!parent.node_ops.rmdir){throw new FS.ErrnoError(63)}if(FS.isMountpoint(node)){throw new FS.ErrnoError(10)}parent.node_ops.rmdir(parent,name);FS.destroyNode(node)},readdir(path){var lookup=FS.lookupPath(path,{follow:true});var node=lookup.node;if(!node.node_ops.readdir){throw new FS.ErrnoError(54)}return node.node_ops.readdir(node)},unlink(path){var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;if(!parent){throw new FS.ErrnoError(44)}var name=PATH.basename(path);var node=FS.lookupNode(parent,name);var errCode=FS.mayDelete(parent,name,false);if(errCode){throw new FS.ErrnoError(errCode)}if(!parent.node_ops.unlink){throw new FS.ErrnoError(63)}if(FS.isMountpoint(node)){throw new FS.ErrnoError(10)}parent.node_ops.unlink(parent,name);FS.destroyNode(node)},readlink(path){var lookup=FS.lookupPath(path);var link=lookup.node;if(!link){throw new FS.ErrnoError(44)}if(!link.node_ops.readlink){throw new FS.ErrnoError(28)}return PATH_FS.resolve(FS.getPath(link.parent),link.node_ops.readlink(link))},stat(path,dontFollow){var lookup=FS.lookupPath(path,{follow:!dontFollow});var node=lookup.node;if(!node){throw new FS.ErrnoError(44)}if(!node.node_ops.getattr){throw new FS.ErrnoError(63)}return node.node_ops.getattr(node)},lstat(path){return FS.stat(path,true)},chmod(path,mode,dontFollow){var node;if(typeof path=="string"){var lookup=FS.lookupPath(path,{follow:!dontFollow});node=lookup.node}else{node=path}if(!node.node_ops.setattr){throw new FS.ErrnoError(63)}node.node_ops.setattr(node,{mode:mode&4095|node.mode&~4095,timestamp:Date.now()})},lchmod(path,mode){FS.chmod(path,mode,true)},fchmod(fd,mode){var stream=FS.getStreamChecked(fd);FS.chmod(stream.node,mode)},chown(path,uid,gid,dontFollow){var node;if(typeof path=="string"){var lookup=FS.lookupPath(path,{follow:!dontFollow});node=lookup.node}else{node=path}if(!node.node_ops.setattr){throw new FS.ErrnoError(63)}node.node_ops.setattr(node,{timestamp:Date.now()})},lchown(path,uid,gid){FS.chown(path,uid,gid,true)},fchown(fd,uid,gid){var stream=FS.getStreamChecked(fd);FS.chown(stream.node,uid,gid)},truncate(path,len){if(len<0){throw new FS.ErrnoError(28)}var node;if(typeof path=="string"){var lookup=FS.lookupPath(path,{follow:true});node=lookup.node}else{node=path}if(!node.node_ops.setattr){throw new FS.ErrnoError(63)}if(FS.isDir(node.mode)){throw new FS.ErrnoError(31)}if(!FS.isFile(node.mode)){throw new FS.ErrnoError(28)}var errCode=FS.nodePermissions(node,"w");if(errCode){throw new FS.ErrnoError(errCode)}node.node_ops.setattr(node,{size:len,timestamp:Date.now()})},ftruncate(fd,len){var stream=FS.getStreamChecked(fd);if((stream.flags&2097155)===0){throw new FS.ErrnoError(28)}FS.truncate(stream.node,len)},utime(path,atime,mtime){var lookup=FS.lookupPath(path,{follow:true});var node=lookup.node;node.node_ops.setattr(node,{timestamp:Math.max(atime,mtime)})},open(path,flags,mode){if(path===""){throw new FS.ErrnoError(44)}flags=typeof flags=="string"?FS_modeStringToFlags(flags):flags;mode=typeof mode=="undefined"?438:mode;if(flags&64){mode=mode&4095|32768}else{mode=0}var node;if(typeof path=="object"){node=path}else{path=PATH.normalize(path);try{var lookup=FS.lookupPath(path,{follow:!(flags&131072)});node=lookup.node}catch(e){}}var created=false;if(flags&64){if(node){if(flags&128){throw new FS.ErrnoError(20)}}else{node=FS.mknod(path,mode,0);created=true}}if(!node){throw new FS.ErrnoError(44)}if(FS.isChrdev(node.mode)){flags&=~512}if(flags&65536&&!FS.isDir(node.mode)){throw new FS.ErrnoError(54)}if(!created){var errCode=FS.mayOpen(node,flags);if(errCode){throw new FS.ErrnoError(errCode)}}if(flags&512&&!created){FS.truncate(node,0)}flags&=~(128|512|131072);var stream=FS.createStream({node:node,path:FS.getPath(node),flags:flags,seekable:true,position:0,stream_ops:node.stream_ops,ungotten:[],error:false});if(stream.stream_ops.open){stream.stream_ops.open(stream)}if(Module["logReadFiles"]&&!(flags&1)){if(!FS.readFiles)FS.readFiles={};if(!(path in FS.readFiles)){FS.readFiles[path]=1}}return stream},close(stream){if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if(stream.getdents)stream.getdents=null;try{if(stream.stream_ops.close){stream.stream_ops.close(stream)}}catch(e){throw e}finally{FS.closeStream(stream.fd)}stream.fd=null},isClosed(stream){return stream.fd===null},llseek(stream,offset,whence){if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if(!stream.seekable||!stream.stream_ops.llseek){throw new FS.ErrnoError(70)}if(whence!=0&&whence!=1&&whence!=2){throw new FS.ErrnoError(28)}stream.position=stream.stream_ops.llseek(stream,offset,whence);stream.ungotten=[];return stream.position},read(stream,buffer,offset,length,position){if(length<0||position<0){throw new FS.ErrnoError(28)}if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if((stream.flags&2097155)===1){throw new FS.ErrnoError(8)}if(FS.isDir(stream.node.mode)){throw new FS.ErrnoError(31)}if(!stream.stream_ops.read){throw new FS.ErrnoError(28)}var seeking=typeof position!="undefined";if(!seeking){position=stream.position}else if(!stream.seekable){throw new FS.ErrnoError(70)}var bytesRead=stream.stream_ops.read(stream,buffer,offset,length,position);if(!seeking)stream.position+=bytesRead;return bytesRead},write(stream,buffer,offset,length,position,canOwn){if(length<0||position<0){throw new FS.ErrnoError(28)}if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if((stream.flags&2097155)===0){throw new FS.ErrnoError(8)}if(FS.isDir(stream.node.mode)){throw new FS.ErrnoError(31)}if(!stream.stream_ops.write){throw new FS.ErrnoError(28)}if(stream.seekable&&stream.flags&1024){FS.llseek(stream,0,2)}var seeking=typeof position!="undefined";if(!seeking){position=stream.position}else if(!stream.seekable){throw new FS.ErrnoError(70)}var bytesWritten=stream.stream_ops.write(stream,buffer,offset,length,position,canOwn);if(!seeking)stream.position+=bytesWritten;return bytesWritten},allocate(stream,offset,length){if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if(offset<0||length<=0){throw new FS.ErrnoError(28)}if((stream.flags&2097155)===0){throw new FS.ErrnoError(8)}if(!FS.isFile(stream.node.mode)&&!FS.isDir(stream.node.mode)){throw new FS.ErrnoError(43)}if(!stream.stream_ops.allocate){throw new FS.ErrnoError(138)}stream.stream_ops.allocate(stream,offset,length)},mmap(stream,length,position,prot,flags){if((prot&2)!==0&&(flags&2)===0&&(stream.flags&2097155)!==2){throw new FS.ErrnoError(2)}if((stream.flags&2097155)===1){throw new FS.ErrnoError(2)}if(!stream.stream_ops.mmap){throw new FS.ErrnoError(43)}return stream.stream_ops.mmap(stream,length,position,prot,flags)},msync(stream,buffer,offset,length,mmapFlags){if(!stream.stream_ops.msync){return 0}return stream.stream_ops.msync(stream,buffer,offset,length,mmapFlags)},munmap:stream=>0,ioctl(stream,cmd,arg){if(!stream.stream_ops.ioctl){throw new FS.ErrnoError(59)}return stream.stream_ops.ioctl(stream,cmd,arg)},readFile(path,opts={}){opts.flags=opts.flags||0;opts.encoding=opts.encoding||"binary";if(opts.encoding!=="utf8"&&opts.encoding!=="binary"){throw new Error(`Invalid encoding type "${opts.encoding}"`)}var ret;var stream=FS.open(path,opts.flags);var stat=FS.stat(path);var length=stat.size;var buf=new Uint8Array(length);FS.read(stream,buf,0,length,0);if(opts.encoding==="utf8"){ret=UTF8ArrayToString(buf,0)}else if(opts.encoding==="binary"){ret=buf}FS.close(stream);return ret},writeFile(path,data,opts={}){opts.flags=opts.flags||577;var stream=FS.open(path,opts.flags,opts.mode);if(typeof data=="string"){var buf=new Uint8Array(lengthBytesUTF8(data)+1);var actualNumBytes=stringToUTF8Array(data,buf,0,buf.length);FS.write(stream,buf,0,actualNumBytes,undefined,opts.canOwn)}else if(ArrayBuffer.isView(data)){FS.write(stream,data,0,data.byteLength,undefined,opts.canOwn)}else{throw new Error("Unsupported data type")}FS.close(stream)},cwd:()=>FS.currentPath,chdir(path){var lookup=FS.lookupPath(path,{follow:true});if(lookup.node===null){throw new FS.ErrnoError(44)}if(!FS.isDir(lookup.node.mode)){throw new FS.ErrnoError(54)}var errCode=FS.nodePermissions(lookup.node,"x");if(errCode){throw new FS.ErrnoError(errCode)}FS.currentPath=lookup.path},createDefaultDirectories(){FS.mkdir("/tmp");FS.mkdir("/home");FS.mkdir("/home/web_user")},createDefaultDevices(){FS.mkdir("/dev");FS.registerDevice(FS.makedev(1,3),{read:()=>0,write:(stream,buffer,offset,length,pos)=>length});FS.mkdev("/dev/null",FS.makedev(1,3));TTY.register(FS.makedev(5,0),TTY.default_tty_ops);TTY.register(FS.makedev(6,0),TTY.default_tty1_ops);FS.mkdev("/dev/tty",FS.makedev(5,0));FS.mkdev("/dev/tty1",FS.makedev(6,0));var randomBuffer=new Uint8Array(1024),randomLeft=0;var randomByte=()=>{if(randomLeft===0){randomLeft=randomFill(randomBuffer).byteLength}return randomBuffer[--randomLeft]};FS.createDevice("/dev","random",randomByte);FS.createDevice("/dev","urandom",randomByte);FS.mkdir("/dev/shm");FS.mkdir("/dev/shm/tmp")},createSpecialDirectories(){FS.mkdir("/proc");var proc_self=FS.mkdir("/proc/self");FS.mkdir("/proc/self/fd");FS.mount({mount(){var node=FS.createNode(proc_self,"fd",16384|511,73);node.node_ops={lookup(parent,name){var fd=+name;var stream=FS.getStreamChecked(fd);var ret={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>stream.path}};ret.parent=ret;return ret}};return node}},{},"/proc/self/fd")},createStandardStreams(){if(Module["stdin"]){FS.createDevice("/dev","stdin",Module["stdin"])}else{FS.symlink("/dev/tty","/dev/stdin")}if(Module["stdout"]){FS.createDevice("/dev","stdout",null,Module["stdout"])}else{FS.symlink("/dev/tty","/dev/stdout")}if(Module["stderr"]){FS.createDevice("/dev","stderr",null,Module["stderr"])}else{FS.symlink("/dev/tty1","/dev/stderr")}var stdin=FS.open("/dev/stdin",0);var stdout=FS.open("/dev/stdout",1);var stderr=FS.open("/dev/stderr",1)},ensureErrnoError(){if(FS.ErrnoError)return;FS.ErrnoError=function ErrnoError(errno,node){this.name="ErrnoError";this.node=node;this.setErrno=function(errno){this.errno=errno};this.setErrno(errno);this.message="FS error"};FS.ErrnoError.prototype=new Error;FS.ErrnoError.prototype.constructor=FS.ErrnoError;[44].forEach(code=>{FS.genericErrors[code]=new FS.ErrnoError(code);FS.genericErrors[code].stack="<generic error, no stack>"})},staticInit(){FS.ensureErrnoError();FS.nameTable=new Array(4096);FS.mount(MEMFS,{},"/");FS.createDefaultDirectories();FS.createDefaultDevices();FS.createSpecialDirectories();FS.filesystems={"MEMFS":MEMFS}},init(input,output,error){FS.init.initialized=true;FS.ensureErrnoError();Module["stdin"]=input||Module["stdin"];Module["stdout"]=output||Module["stdout"];Module["stderr"]=error||Module["stderr"];FS.createStandardStreams()},quit(){FS.init.initialized=false;for(var i=0;i<FS.streams.length;i++){var stream=FS.streams[i];if(!stream){continue}FS.close(stream)}},findObject(path,dontResolveLastLink){var ret=FS.analyzePath(path,dontResolveLastLink);if(!ret.exists){return null}return ret.object},analyzePath(path,dontResolveLastLink){try{var lookup=FS.lookupPath(path,{follow:!dontResolveLastLink});path=lookup.path}catch(e){}var ret={isRoot:false,exists:false,error:0,name:null,path:null,object:null,parentExists:false,parentPath:null,parentObject:null};try{var lookup=FS.lookupPath(path,{parent:true});ret.parentExists=true;ret.parentPath=lookup.path;ret.parentObject=lookup.node;ret.name=PATH.basename(path);lookup=FS.lookupPath(path,{follow:!dontResolveLastLink});ret.exists=true;ret.path=lookup.path;ret.object=lookup.node;ret.name=lookup.node.name;ret.isRoot=lookup.path==="/"}catch(e){ret.error=e.errno}return ret},createPath(parent,path,canRead,canWrite){parent=typeof parent=="string"?parent:FS.getPath(parent);var parts=path.split("/").reverse();while(parts.length){var part=parts.pop();if(!part)continue;var current=PATH.join2(parent,part);try{FS.mkdir(current)}catch(e){}parent=current}return current},createFile(parent,name,properties,canRead,canWrite){var path=PATH.join2(typeof parent=="string"?parent:FS.getPath(parent),name);var mode=FS_getMode(canRead,canWrite);return FS.create(path,mode)},createDataFile(parent,name,data,canRead,canWrite,canOwn){var path=name;if(parent){parent=typeof parent=="string"?parent:FS.getPath(parent);path=name?PATH.join2(parent,name):parent}var mode=FS_getMode(canRead,canWrite);var node=FS.create(path,mode);if(data){if(typeof data=="string"){var arr=new Array(data.length);for(var i=0,len=data.length;i<len;++i)arr[i]=data.charCodeAt(i);data=arr}FS.chmod(node,mode|146);var stream=FS.open(node,577);FS.write(stream,data,0,data.length,0,canOwn);FS.close(stream);FS.chmod(node,mode)}},createDevice(parent,name,input,output){var path=PATH.join2(typeof parent=="string"?parent:FS.getPath(parent),name);var mode=FS_getMode(!!input,!!output);if(!FS.createDevice.major)FS.createDevice.major=64;var dev=FS.makedev(FS.createDevice.major++,0);FS.registerDevice(dev,{open(stream){stream.seekable=false},close(stream){if(output?.buffer?.length){output(10)}},read(stream,buffer,offset,length,pos){var bytesRead=0;for(var i=0;i<length;i++){var result;try{result=input()}catch(e){throw new FS.ErrnoError(29)}if(result===undefined&&bytesRead===0){throw new FS.ErrnoError(6)}if(result===null||result===undefined)break;bytesRead++;buffer[offset+i]=result}if(bytesRead){stream.node.timestamp=Date.now()}return bytesRead},write(stream,buffer,offset,length,pos){for(var i=0;i<length;i++){try{output(buffer[offset+i])}catch(e){throw new FS.ErrnoError(29)}}if(length){stream.node.timestamp=Date.now()}return i}});return FS.mkdev(path,mode,dev)},forceLoadFile(obj){if(obj.isDevice||obj.isFolder||obj.link||obj.contents)return true;if(typeof XMLHttpRequest!="undefined"){throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.")}else if(read_){try{obj.contents=intArrayFromString(read_(obj.url),true);obj.usedBytes=obj.contents.length}catch(e){throw new FS.ErrnoError(29)}}else{throw new Error("Cannot load without read() or XMLHttpRequest.")}},createLazyFile(parent,name,url,canRead,canWrite){function LazyUint8Array(){this.lengthKnown=false;this.chunks=[]}LazyUint8Array.prototype.get=function LazyUint8Array_get(idx){if(idx>this.length-1||idx<0){return undefined}var chunkOffset=idx%this.chunkSize;var chunkNum=idx/this.chunkSize|0;return this.getter(chunkNum)[chunkOffset]};LazyUint8Array.prototype.setDataGetter=function LazyUint8Array_setDataGetter(getter){this.getter=getter};LazyUint8Array.prototype.cacheLength=function LazyUint8Array_cacheLength(){var xhr=new XMLHttpRequest;xhr.open("HEAD",url,false);xhr.send(null);if(!(xhr.status>=200&&xhr.status<300||xhr.status===304))throw new Error("Couldn't load "+url+". Status: "+xhr.status);var datalength=Number(xhr.getResponseHeader("Content-length"));var header;var hasByteServing=(header=xhr.getResponseHeader("Accept-Ranges"))&&header==="bytes";var usesGzip=(header=xhr.getResponseHeader("Content-Encoding"))&&header==="gzip";var chunkSize=1024*1024;if(!hasByteServing)chunkSize=datalength;var doXHR=(from,to)=>{if(from>to)throw new Error("invalid range ("+from+", "+to+") or no bytes requested!");if(to>datalength-1)throw new Error("only "+datalength+" bytes available! programmer error!");var xhr=new XMLHttpRequest;xhr.open("GET",url,false);if(datalength!==chunkSize)xhr.setRequestHeader("Range","bytes="+from+"-"+to);xhr.responseType="arraybuffer";if(xhr.overrideMimeType){xhr.overrideMimeType("text/plain; charset=x-user-defined")}xhr.send(null);if(!(xhr.status>=200&&xhr.status<300||xhr.status===304))throw new Error("Couldn't load "+url+". Status: "+xhr.status);if(xhr.response!==undefined){return new Uint8Array(xhr.response||[])}return intArrayFromString(xhr.responseText||"",true)};var lazyArray=this;lazyArray.setDataGetter(chunkNum=>{var start=chunkNum*chunkSize;var end=(chunkNum+1)*chunkSize-1;end=Math.min(end,datalength-1);if(typeof lazyArray.chunks[chunkNum]=="undefined"){lazyArray.chunks[chunkNum]=doXHR(start,end)}if(typeof lazyArray.chunks[chunkNum]=="undefined")throw new Error("doXHR failed!");return lazyArray.chunks[chunkNum]});if(usesGzip||!datalength){chunkSize=datalength=1;datalength=this.getter(0).length;chunkSize=datalength;out("LazyFiles on gzip forces download of the whole file when length is accessed")}this._length=datalength;this._chunkSize=chunkSize;this.lengthKnown=true};if(typeof XMLHttpRequest!="undefined"){if(!ENVIRONMENT_IS_WORKER)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var lazyArray=new LazyUint8Array;Object.defineProperties(lazyArray,{length:{get:function(){if(!this.lengthKnown){this.cacheLength()}return this._length}},chunkSize:{get:function(){if(!this.lengthKnown){this.cacheLength()}return this._chunkSize}}});var properties={isDevice:false,contents:lazyArray}}else{var properties={isDevice:false,url:url}}var node=FS.createFile(parent,name,properties,canRead,canWrite);if(properties.contents){node.contents=properties.contents}else if(properties.url){node.contents=null;node.url=properties.url}Object.defineProperties(node,{usedBytes:{get:function(){return this.contents.length}}});var stream_ops={};var keys=Object.keys(node.stream_ops);keys.forEach(key=>{var fn=node.stream_ops[key];stream_ops[key]=function forceLoadLazyFile(){FS.forceLoadFile(node);return fn.apply(null,arguments)}});function writeChunks(stream,buffer,offset,length,position){var contents=stream.node.contents;if(position>=contents.length)return 0;var size=Math.min(contents.length-position,length);if(contents.slice){for(var i=0;i<size;i++){buffer[offset+i]=contents[position+i]}}else{for(var i=0;i<size;i++){buffer[offset+i]=contents.get(position+i)}}return size}stream_ops.read=(stream,buffer,offset,length,position)=>{FS.forceLoadFile(node);return writeChunks(stream,buffer,offset,length,position)};stream_ops.mmap=(stream,length,position,prot,flags)=>{FS.forceLoadFile(node);var ptr=mmapAlloc(length);if(!ptr){throw new FS.ErrnoError(48)}writeChunks(stream,HEAP8,ptr,length,position);return{ptr:ptr,allocated:true}};node.stream_ops=stream_ops;return node}};var UTF8ToString=(ptr,maxBytesToRead)=>ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):"";var SYSCALLS={DEFAULT_POLLMASK:5,calculateAt(dirfd,path,allowEmpty){if(PATH.isAbs(path)){return path}var dir;if(dirfd===-100){dir=FS.cwd()}else{var dirstream=SYSCALLS.getStreamFromFD(dirfd);dir=dirstream.path}if(path.length==0){if(!allowEmpty){throw new FS.ErrnoError(44)}return dir}return PATH.join2(dir,path)},doStat(func,path,buf){try{var stat=func(path)}catch(e){if(e&&e.node&&PATH.normalize(path)!==PATH.normalize(FS.getPath(e.node))){return-54}throw e}HEAP32[buf>>2]=stat.dev;HEAP32[buf+4>>2]=stat.mode;HEAPU32[buf+8>>2]=stat.nlink;HEAP32[buf+12>>2]=stat.uid;HEAP32[buf+16>>2]=stat.gid;HEAP32[buf+20>>2]=stat.rdev;tempI64=[stat.size>>>0,(tempDouble=stat.size,+Math.abs(tempDouble)>=1?tempDouble>0?+Math.floor(tempDouble/4294967296)>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[buf+24>>2]=tempI64[0],HEAP32[buf+28>>2]=tempI64[1];HEAP32[buf+32>>2]=4096;HEAP32[buf+36>>2]=stat.blocks;var atime=stat.atime.getTime();var mtime=stat.mtime.getTime();var ctime=stat.ctime.getTime();tempI64=[Math.floor(atime/1e3)>>>0,(tempDouble=Math.floor(atime/1e3),+Math.abs(tempDouble)>=1?tempDouble>0?+Math.floor(tempDouble/4294967296)>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[buf+40>>2]=tempI64[0],HEAP32[buf+44>>2]=tempI64[1];HEAPU32[buf+48>>2]=atime%1e3*1e3;tempI64=[Math.floor(mtime/1e3)>>>0,(tempDouble=Math.floor(mtime/1e3),+Math.abs(tempDouble)>=1?tempDouble>0?+Math.floor(tempDouble/4294967296)>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[buf+56>>2]=tempI64[0],HEAP32[buf+60>>2]=tempI64[1];HEAPU32[buf+64>>2]=mtime%1e3*1e3;tempI64=[Math.floor(ctime/1e3)>>>0,(tempDouble=Math.floor(ctime/1e3),+Math.abs(tempDouble)>=1?tempDouble>0?+Math.floor(tempDouble/4294967296)>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[buf+72>>2]=tempI64[0],HEAP32[buf+76>>2]=tempI64[1];HEAPU32[buf+80>>2]=ctime%1e3*1e3;tempI64=[stat.ino>>>0,(tempDouble=stat.ino,+Math.abs(tempDouble)>=1?tempDouble>0?+Math.floor(tempDouble/4294967296)>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[buf+88>>2]=tempI64[0],HEAP32[buf+92>>2]=tempI64[1];return 0},doMsync(addr,stream,len,flags,offset){if(!FS.isFile(stream.node.mode)){throw new FS.ErrnoError(43)}if(flags&2){return 0}var buffer=HEAPU8.slice(addr,addr+len);FS.msync(stream,buffer,offset,len,flags)},varargs:undefined,get(){var ret=HEAP32[+SYSCALLS.varargs>>2];SYSCALLS.varargs+=4;return ret},getp(){return SYSCALLS.get()},getStr(ptr){var ret=UTF8ToString(ptr);return ret},getStreamFromFD(fd){var stream=FS.getStreamChecked(fd);return stream}};function ___syscall_fcntl64(fd,cmd,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.getStreamFromFD(fd);switch(cmd){case 0:{var arg=SYSCALLS.get();if(arg<0){return-28}while(FS.streams[arg]){arg++}var newStream;newStream=FS.createStream(stream,arg);return newStream.fd}case 1:case 2:return 0;case 3:return stream.flags;case 4:{var arg=SYSCALLS.get();stream.flags|=arg;return 0}case 5:{var arg=SYSCALLS.getp();var offset=0;HEAP16[arg+offset>>1]=2;return 0}case 6:case 7:return 0;case 16:case 8:return-28;case 9:setErrNo(28);return-1;default:{return-28}}}catch(e){if(typeof FS=="undefined"||!(e.name==="ErrnoError"))throw e;return-e.errno}}function ___syscall_fstat64(fd,buf){try{var stream=SYSCALLS.getStreamFromFD(fd);return SYSCALLS.doStat(FS.stat,stream.path,buf)}catch(e){if(typeof FS=="undefined"||!(e.name==="ErrnoError"))throw e;return-e.errno}}var stringToUTF8=(str,outPtr,maxBytesToWrite)=>stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite);function ___syscall_getcwd(buf,size){try{if(size===0)return-28;var cwd=FS.cwd();var cwdLengthInBytes=lengthBytesUTF8(cwd)+1;if(size<cwdLengthInBytes)return-68;stringToUTF8(cwd,buf,size);return cwdLengthInBytes}catch(e){if(typeof FS=="undefined"||!(e.name==="ErrnoError"))throw e;return-e.errno}}function ___syscall_getdents64(fd,dirp,count){try{var stream=SYSCALLS.getStreamFromFD(fd);stream.getdents||=FS.readdir(stream.path);var struct_size=280;var pos=0;var off=FS.llseek(stream,0,1);var idx=Math.floor(off/struct_size);while(idx<stream.getdents.length&&pos+struct_size<=count){var id;var type;var name=stream.getdents[idx];if(name==="."){id=stream.node.id;type=4}else if(name===".."){var lookup=FS.lookupPath(stream.path,{parent:true});id=lookup.node.id;type=4}else{var child=FS.lookupNode(stream.node,name);id=child.id;type=FS.isChrdev(child.mode)?2:FS.isDir(child.mode)?4:FS.isLink(child.mode)?10:8}tempI64=[id>>>0,(tempDouble=id,+Math.abs(tempDouble)>=1?tempDouble>0?+Math.floor(tempDouble/4294967296)>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[dirp+pos>>2]=tempI64[0],HEAP32[dirp+pos+4>>2]=tempI64[1];tempI64=[(idx+1)*struct_size>>>0,(tempDouble=(idx+1)*struct_size,+Math.abs(tempDouble)>=1?tempDouble>0?+Math.floor(tempDouble/4294967296)>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[dirp+pos+8>>2]=tempI64[0],HEAP32[dirp+pos+12>>2]=tempI64[1];HEAP16[dirp+pos+16>>1]=280;HEAP8[dirp+pos+18>>0]=type;stringToUTF8(name,dirp+pos+19,256);pos+=struct_size;idx+=1}FS.llseek(stream,idx*struct_size,0);return pos}catch(e){if(typeof FS=="undefined"||!(e.name==="ErrnoError"))throw e;return-e.errno}}function ___syscall_ioctl(fd,op,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.getStreamFromFD(fd);switch(op){case 21509:{if(!stream.tty)return-59;return 0}case 21505:{if(!stream.tty)return-59;if(stream.tty.ops.ioctl_tcgets){var termios=stream.tty.ops.ioctl_tcgets(stream);var argp=SYSCALLS.getp();HEAP32[argp>>2]=termios.c_iflag||0;HEAP32[argp+4>>2]=termios.c_oflag||0;HEAP32[argp+8>>2]=termios.c_cflag||0;HEAP32[argp+12>>2]=termios.c_lflag||0;for(var i=0;i<32;i++){HEAP8[argp+i+17>>0]=termios.c_cc[i]||0}return 0}return 0}case 21510:case 21511:case 21512:{if(!stream.tty)return-59;return 0}case 21506:case 21507:case 21508:{if(!stream.tty)return-59;if(stream.tty.ops.ioctl_tcsets){var argp=SYSCALLS.getp();var c_iflag=HEAP32[argp>>2];var c_oflag=HEAP32[argp+4>>2];var c_cflag=HEAP32[argp+8>>2];var c_lflag=HEAP32[argp+12>>2];var c_cc=[];for(var i=0;i<32;i++){c_cc.push(HEAP8[argp+i+17>>0])}return stream.tty.ops.ioctl_tcsets(stream.tty,op,{c_iflag:c_iflag,c_oflag:c_oflag,c_cflag:c_cflag,c_lflag:c_lflag,c_cc:c_cc})}return 0}case 21519:{if(!stream.tty)return-59;var argp=SYSCALLS.getp();HEAP32[argp>>2]=0;return 0}case 21520:{if(!stream.tty)return-59;return-28}case 21531:{var argp=SYSCALLS.getp();return FS.ioctl(stream,op,argp)}case 21523:{if(!stream.tty)return-59;if(stream.tty.ops.ioctl_tiocgwinsz){var winsize=stream.tty.ops.ioctl_tiocgwinsz(stream.tty);var argp=SYSCALLS.getp();HEAP16[argp>>1]=winsize[0];HEAP16[argp+2>>1]=winsize[1]}return 0}case 21524:{if(!stream.tty)return-59;return 0}case 21515:{if(!stream.tty)return-59;return 0}default:return-28}}catch(e){if(typeof FS=="undefined"||!(e.name==="ErrnoError"))throw e;return-e.errno}}function ___syscall_lstat64(path,buf){try{path=SYSCALLS.getStr(path);return SYSCALLS.doStat(FS.lstat,path,buf)}catch(e){if(typeof FS=="undefined"||!(e.name==="ErrnoError"))throw e;return-e.errno}}function ___syscall_mkdirat(dirfd,path,mode){try{path=SYSCALLS.getStr(path);path=SYSCALLS.calculateAt(dirfd,path);path=PATH.normalize(path);if(path[path.length-1]==="/")path=path.substr(0,path.length-1);FS.mkdir(path,mode,0);return 0}catch(e){if(typeof FS=="undefined"||!(e.name==="ErrnoError"))throw e;return-e.errno}}function ___syscall_newfstatat(dirfd,path,buf,flags){try{path=SYSCALLS.getStr(path);var nofollow=flags&256;var allowEmpty=flags&4096;flags=flags&~6400;path=SYSCALLS.calculateAt(dirfd,path,allowEmpty);return SYSCALLS.doStat(nofollow?FS.lstat:FS.stat,path,buf)}catch(e){if(typeof FS=="undefined"||!(e.name==="ErrnoError"))throw e;return-e.errno}}function ___syscall_openat(dirfd,path,flags,varargs){SYSCALLS.varargs=varargs;try{path=SYSCALLS.getStr(path);path=SYSCALLS.calculateAt(dirfd,path);var mode=varargs?SYSCALLS.get():0;return FS.open(path,flags,mode).fd}catch(e){if(typeof FS=="undefined"||!(e.name==="ErrnoError"))throw e;return-e.errno}}function ___syscall_readlinkat(dirfd,path,buf,bufsize){try{path=SYSCALLS.getStr(path);path=SYSCALLS.calculateAt(dirfd,path);if(bufsize<=0)return-28;var ret=FS.readlink(path);var len=Math.min(bufsize,lengthBytesUTF8(ret));var endChar=HEAP8[buf+len];stringToUTF8(ret,buf,bufsize+1);HEAP8[buf+len]=endChar;return len}catch(e){if(typeof FS=="undefined"||!(e.name==="ErrnoError"))throw e;return-e.errno}}function ___syscall_rmdir(path){try{path=SYSCALLS.getStr(path);FS.rmdir(path);return 0}catch(e){if(typeof FS=="undefined"||!(e.name==="ErrnoError"))throw e;return-e.errno}}function ___syscall_stat64(path,buf){try{path=SYSCALLS.getStr(path);return SYSCALLS.doStat(FS.stat,path,buf)}catch(e){if(typeof FS=="undefined"||!(e.name==="ErrnoError"))throw e;return-e.errno}}function ___syscall_unlinkat(dirfd,path,flags){try{path=SYSCALLS.getStr(path);path=SYSCALLS.calculateAt(dirfd,path);if(flags===0){FS.unlink(path)}else if(flags===512){FS.rmdir(path)}else{abort("Invalid flags passed to unlinkat")}return 0}catch(e){if(typeof FS=="undefined"||!(e.name==="ErrnoError"))throw e;return-e.errno}}var nowIsMonotonic=1;var __emscripten_get_now_is_monotonic=()=>nowIsMonotonic;var convertI32PairToI53Checked=(lo,hi)=>hi+2097152>>>0<4194305-!!lo?(lo>>>0)+hi*4294967296:NaN;function __gmtime_js(time_low,time_high,tmPtr){var time=convertI32PairToI53Checked(time_low,time_high);var date=new Date(time*1e3);HEAP32[tmPtr>>2]=date.getUTCSeconds();HEAP32[tmPtr+4>>2]=date.getUTCMinutes();HEAP32[tmPtr+8>>2]=date.getUTCHours();HEAP32[tmPtr+12>>2]=date.getUTCDate();HEAP32[tmPtr+16>>2]=date.getUTCMonth();HEAP32[tmPtr+20>>2]=date.getUTCFullYear()-1900;HEAP32[tmPtr+24>>2]=date.getUTCDay();var start=Date.UTC(date.getUTCFullYear(),0,1,0,0,0,0);var yday=(date.getTime()-start)/(1e3*60*60*24)|0;HEAP32[tmPtr+28>>2]=yday}var isLeapYear=year=>year%4===0&&(year%100!==0||year%400===0);var MONTH_DAYS_LEAP_CUMULATIVE=[0,31,60,91,121,152,182,213,244,274,305,335];var MONTH_DAYS_REGULAR_CUMULATIVE=[0,31,59,90,120,151,181,212,243,273,304,334];var ydayFromDate=date=>{var leap=isLeapYear(date.getFullYear());var monthDaysCumulative=leap?MONTH_DAYS_LEAP_CUMULATIVE:MONTH_DAYS_REGULAR_CUMULATIVE;var yday=monthDaysCumulative[date.getMonth()]+date.getDate()-1;return yday};function __localtime_js(time_low,time_high,tmPtr){var time=convertI32PairToI53Checked(time_low,time_high);var date=new Date(time*1e3);HEAP32[tmPtr>>2]=date.getSeconds();HEAP32[tmPtr+4>>2]=date.getMinutes();HEAP32[tmPtr+8>>2]=date.getHours();HEAP32[tmPtr+12>>2]=date.getDate();HEAP32[tmPtr+16>>2]=date.getMonth();HEAP32[tmPtr+20>>2]=date.getFullYear()-1900;HEAP32[tmPtr+24>>2]=date.getDay();var yday=ydayFromDate(date)|0;HEAP32[tmPtr+28>>2]=yday;HEAP32[tmPtr+36>>2]=-(date.getTimezoneOffset()*60);var start=new Date(date.getFullYear(),0,1);var summerOffset=new Date(date.getFullYear(),6,1).getTimezoneOffset();var winterOffset=start.getTimezoneOffset();var dst=(summerOffset!=winterOffset&&date.getTimezoneOffset()==Math.min(winterOffset,summerOffset))|0;HEAP32[tmPtr+32>>2]=dst}var __mktime_js=function(tmPtr){var ret=(()=>{var date=new Date(HEAP32[tmPtr+20>>2]+1900,HEAP32[tmPtr+16>>2],HEAP32[tmPtr+12>>2],HEAP32[tmPtr+8>>2],HEAP32[tmPtr+4>>2],HEAP32[tmPtr>>2],0);var dst=HEAP32[tmPtr+32>>2];var guessedOffset=date.getTimezoneOffset();var start=new Date(date.getFullYear(),0,1);var summerOffset=new Date(date.getFullYear(),6,1).getTimezoneOffset();var winterOffset=start.getTimezoneOffset();var dstOffset=Math.min(winterOffset,summerOffset);if(dst<0){HEAP32[tmPtr+32>>2]=Number(summerOffset!=winterOffset&&dstOffset==guessedOffset)}else if(dst>0!=(dstOffset==guessedOffset)){var nonDstOffset=Math.max(winterOffset,summerOffset);var trueOffset=dst>0?dstOffset:nonDstOffset;date.setTime(date.getTime()+(trueOffset-guessedOffset)*6e4)}HEAP32[tmPtr+24>>2]=date.getDay();var yday=ydayFromDate(date)|0;HEAP32[tmPtr+28>>2]=yday;HEAP32[tmPtr>>2]=date.getSeconds();HEAP32[tmPtr+4>>2]=date.getMinutes();HEAP32[tmPtr+8>>2]=date.getHours();HEAP32[tmPtr+12>>2]=date.getDate();HEAP32[tmPtr+16>>2]=date.getMonth();HEAP32[tmPtr+20>>2]=date.getYear();var timeMs=date.getTime();if(isNaN(timeMs)){setErrNo(61);return-1}return timeMs/1e3})();return setTempRet0((tempDouble=ret,+Math.abs(tempDouble)>=1?tempDouble>0?+Math.floor(tempDouble/4294967296)>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)),ret>>>0};function __mmap_js(len,prot,flags,fd,offset_low,offset_high,allocated,addr){var offset=convertI32PairToI53Checked(offset_low,offset_high);try{if(isNaN(offset))return 61;var stream=SYSCALLS.getStreamFromFD(fd);var res=FS.mmap(stream,len,offset,prot,flags);var ptr=res.ptr;HEAP32[allocated>>2]=res.allocated;HEAPU32[addr>>2]=ptr;return 0}catch(e){if(typeof FS=="undefined"||!(e.name==="ErrnoError"))throw e;return-e.errno}}function __munmap_js(addr,len,prot,flags,fd,offset_low,offset_high){var offset=convertI32PairToI53Checked(offset_low,offset_high);try{if(isNaN(offset))return 61;var stream=SYSCALLS.getStreamFromFD(fd);if(prot&2){SYSCALLS.doMsync(addr,stream,len,flags,offset)}FS.munmap(stream)}catch(e){if(typeof FS=="undefined"||!(e.name==="ErrnoError"))throw e;return-e.errno}}var stringToNewUTF8=str=>{var size=lengthBytesUTF8(str)+1;var ret=_malloc(size);if(ret)stringToUTF8(str,ret,size);return ret};var __tzset_js=(timezone,daylight,tzname)=>{var currentYear=(new Date).getFullYear();var winter=new Date(currentYear,0,1);var summer=new Date(currentYear,6,1);var winterOffset=winter.getTimezoneOffset();var summerOffset=summer.getTimezoneOffset();var stdTimezoneOffset=Math.max(winterOffset,summerOffset);HEAPU32[timezone>>2]=stdTimezoneOffset*60;HEAP32[daylight>>2]=Number(winterOffset!=summerOffset);function extractZone(date){var match=date.toTimeString().match(/\(([A-Za-z ]+)\)$/);return match?match[1]:"GMT"}var winterName=extractZone(winter);var summerName=extractZone(summer);var winterNamePtr=stringToNewUTF8(winterName);var summerNamePtr=stringToNewUTF8(summerName);if(summerOffset<winterOffset){HEAPU32[tzname>>2]=winterNamePtr;HEAPU32[tzname+4>>2]=summerNamePtr}else{HEAPU32[tzname>>2]=summerNamePtr;HEAPU32[tzname+4>>2]=winterNamePtr}};var _abort=()=>{abort("")};var readEmAsmArgsArray=[];var readEmAsmArgs=(sigPtr,buf)=>{readEmAsmArgsArray.length=0;var ch;while(ch=HEAPU8[sigPtr++]){var wide=ch!=105;wide&=ch!=112;buf+=wide&&buf%8?4:0;readEmAsmArgsArray.push(ch==112?HEAPU32[buf>>2]:ch==105?HEAP32[buf>>2]:HEAPF64[buf>>3]);buf+=wide?8:4}return readEmAsmArgsArray};var runEmAsmFunction=(code,sigPtr,argbuf)=>{var args=readEmAsmArgs(sigPtr,argbuf);return ASM_CONSTS[code].apply(null,args)};var _emscripten_asm_const_int=(code,sigPtr,argbuf)=>runEmAsmFunction(code,sigPtr,argbuf);var _emscripten_date_now=()=>Date.now();var getHeapMax=()=>2147483648;var _emscripten_get_heap_max=()=>getHeapMax();var _emscripten_get_now;_emscripten_get_now=()=>performance.now();var _emscripten_memcpy_js=(dest,src,num)=>HEAPU8.copyWithin(dest,src,src+num);var growMemory=size=>{var b=wasmMemory.buffer;var pages=(size-b.byteLength+65535)/65536;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};var _emscripten_resize_heap=requestedSize=>{var oldSize=HEAPU8.length;requestedSize>>>=0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}var alignUp=(x,multiple)=>x+(multiple-x%multiple)%multiple;for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignUp(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement){return true}}return false};var ENV={};var getExecutableName=()=>thisProgram||"./this.program";var getEnvStrings=()=>{if(!getEnvStrings.strings){var lang=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8";var env={"USER":"web_user","LOGNAME":"web_user","PATH":"/","PWD":"/","HOME":"/home/web_user","LANG":lang,"_":getExecutableName()};for(var x in ENV){if(ENV[x]===undefined)delete env[x];else env[x]=ENV[x]}var strings=[];for(var x in env){strings.push(`${x}=${env[x]}`)}getEnvStrings.strings=strings}return getEnvStrings.strings};var stringToAscii=(str,buffer)=>{for(var i=0;i<str.length;++i){HEAP8[buffer++>>0]=str.charCodeAt(i)}HEAP8[buffer>>0]=0};var _environ_get=(__environ,environ_buf)=>{var bufSize=0;getEnvStrings().forEach((string,i)=>{var ptr=environ_buf+bufSize;HEAPU32[__environ+i*4>>2]=ptr;stringToAscii(string,ptr);bufSize+=string.length+1});return 0};var _environ_sizes_get=(penviron_count,penviron_buf_size)=>{var strings=getEnvStrings();HEAPU32[penviron_count>>2]=strings.length;var bufSize=0;strings.forEach(string=>bufSize+=string.length+1);HEAPU32[penviron_buf_size>>2]=bufSize;return 0};var runtimeKeepaliveCounter=0;var keepRuntimeAlive=()=>noExitRuntime||runtimeKeepaliveCounter>0;var _proc_exit=code=>{EXITSTATUS=code;if(!keepRuntimeAlive()){Module["onExit"]?.(code);ABORT=true}quit_(code,new ExitStatus(code))};var exitJS=(status,implicit)=>{EXITSTATUS=status;_proc_exit(status)};var _exit=exitJS;function _fd_close(fd){try{var stream=SYSCALLS.getStreamFromFD(fd);FS.close(stream);return 0}catch(e){if(typeof FS=="undefined"||!(e.name==="ErrnoError"))throw e;return e.errno}}var doReadv=(stream,iov,iovcnt,offset)=>{var ret=0;for(var i=0;i<iovcnt;i++){var ptr=HEAPU32[iov>>2];var len=HEAPU32[iov+4>>2];iov+=8;var curr=FS.read(stream,HEAP8,ptr,len,offset);if(curr<0)return-1;ret+=curr;if(curr<len)break;if(typeof offset!=="undefined"){offset+=curr}}return ret};function _fd_read(fd,iov,iovcnt,pnum){try{var stream=SYSCALLS.getStreamFromFD(fd);var num=doReadv(stream,iov,iovcnt);HEAPU32[pnum>>2]=num;return 0}catch(e){if(typeof FS=="undefined"||!(e.name==="ErrnoError"))throw e;return e.errno}}function _fd_seek(fd,offset_low,offset_high,whence,newOffset){var offset=convertI32PairToI53Checked(offset_low,offset_high);try{if(isNaN(offset))return 61;var stream=SYSCALLS.getStreamFromFD(fd);FS.llseek(stream,offset,whence);tempI64=[stream.position>>>0,(tempDouble=stream.position,+Math.abs(tempDouble)>=1?tempDouble>0?+Math.floor(tempDouble/4294967296)>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[newOffset>>2]=tempI64[0],HEAP32[newOffset+4>>2]=tempI64[1];if(stream.getdents&&offset===0&&whence===0)stream.getdents=null;return 0}catch(e){if(typeof FS=="undefined"||!(e.name==="ErrnoError"))throw e;return e.errno}}var doWritev=(stream,iov,iovcnt,offset)=>{var ret=0;for(var i=0;i<iovcnt;i++){var ptr=HEAPU32[iov>>2];var len=HEAPU32[iov+4>>2];iov+=8;var curr=FS.write(stream,HEAP8,ptr,len,offset);if(curr<0)return-1;ret+=curr;if(typeof offset!=="undefined"){offset+=curr}}return ret};function _fd_write(fd,iov,iovcnt,pnum){try{var stream=SYSCALLS.getStreamFromFD(fd);var num=doWritev(stream,iov,iovcnt);HEAPU32[pnum>>2]=num;return 0}catch(e){if(typeof FS=="undefined"||!(e.name==="ErrnoError"))throw e;return e.errno}}var arraySum=(array,index)=>{var sum=0;for(var i=0;i<=index;sum+=array[i++]){}return sum};var MONTH_DAYS_LEAP=[31,29,31,30,31,30,31,31,30,31,30,31];var MONTH_DAYS_REGULAR=[31,28,31,30,31,30,31,31,30,31,30,31];var addDays=(date,days)=>{var newDate=new Date(date.getTime());while(days>0){var leap=isLeapYear(newDate.getFullYear());var currentMonth=newDate.getMonth();var daysInCurrentMonth=(leap?MONTH_DAYS_LEAP:MONTH_DAYS_REGULAR)[currentMonth];if(days>daysInCurrentMonth-newDate.getDate()){days-=daysInCurrentMonth-newDate.getDate()+1;newDate.setDate(1);if(currentMonth<11){newDate.setMonth(currentMonth+1)}else{newDate.setMonth(0);newDate.setFullYear(newDate.getFullYear()+1)}}else{newDate.setDate(newDate.getDate()+days);return newDate}}return newDate};var writeArrayToMemory=(array,buffer)=>{HEAP8.set(array,buffer)};var _strftime=(s,maxsize,format,tm)=>{var tm_zone=HEAPU32[tm+40>>2];var date={tm_sec:HEAP32[tm>>2],tm_min:HEAP32[tm+4>>2],tm_hour:HEAP32[tm+8>>2],tm_mday:HEAP32[tm+12>>2],tm_mon:HEAP32[tm+16>>2],tm_year:HEAP32[tm+20>>2],tm_wday:HEAP32[tm+24>>2],tm_yday:HEAP32[tm+28>>2],tm_isdst:HEAP32[tm+32>>2],tm_gmtoff:HEAP32[tm+36>>2],tm_zone:tm_zone?UTF8ToString(tm_zone):""};var pattern=UTF8ToString(format);var EXPANSION_RULES_1={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var rule in EXPANSION_RULES_1){pattern=pattern.replace(new RegExp(rule,"g"),EXPANSION_RULES_1[rule])}var WEEKDAYS=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];var MONTHS=["January","February","March","April","May","June","July","August","September","October","November","December"];function leadingSomething(value,digits,character){var str=typeof value=="number"?value.toString():value||"";while(str.length<digits){str=character[0]+str}return str}function leadingNulls(value,digits){return leadingSomething(value,digits,"0")}function compareByDay(date1,date2){function sgn(value){return value<0?-1:value>0?1:0}var compare;if((compare=sgn(date1.getFullYear()-date2.getFullYear()))===0){if((compare=sgn(date1.getMonth()-date2.getMonth()))===0){compare=sgn(date1.getDate()-date2.getDate())}}return compare}function getFirstWeekStartDate(janFourth){switch(janFourth.getDay()){case 0:return new Date(janFourth.getFullYear()-1,11,29);case 1:return janFourth;case 2:return new Date(janFourth.getFullYear(),0,3);case 3:return new Date(janFourth.getFullYear(),0,2);case 4:return new Date(janFourth.getFullYear(),0,1);case 5:return new Date(janFourth.getFullYear()-1,11,31);case 6:return new Date(janFourth.getFullYear()-1,11,30)}}function getWeekBasedYear(date){var thisDate=addDays(new Date(date.tm_year+1900,0,1),date.tm_yday);var janFourthThisYear=new Date(thisDate.getFullYear(),0,4);var janFourthNextYear=new Date(thisDate.getFullYear()+1,0,4);var firstWeekStartThisYear=getFirstWeekStartDate(janFourthThisYear);var firstWeekStartNextYear=getFirstWeekStartDate(janFourthNextYear);if(compareByDay(firstWeekStartThisYear,thisDate)<=0){if(compareByDay(firstWeekStartNextYear,thisDate)<=0){return thisDate.getFullYear()+1}return thisDate.getFullYear()}return thisDate.getFullYear()-1}var EXPANSION_RULES_2={"%a":date=>WEEKDAYS[date.tm_wday].substring(0,3),"%A":date=>WEEKDAYS[date.tm_wday],"%b":date=>MONTHS[date.tm_mon].substring(0,3),"%B":date=>MONTHS[date.tm_mon],"%C":date=>{var year=date.tm_year+1900;return leadingNulls(year/100|0,2)},"%d":date=>leadingNulls(date.tm_mday,2),"%e":date=>leadingSomething(date.tm_mday,2," "),"%g":date=>getWeekBasedYear(date).toString().substring(2),"%G":date=>getWeekBasedYear(date),"%H":date=>leadingNulls(date.tm_hour,2),"%I":date=>{var twelveHour=date.tm_hour;if(twelveHour==0)twelveHour=12;else if(twelveHour>12)twelveHour-=12;return leadingNulls(twelveHour,2)},"%j":date=>leadingNulls(date.tm_mday+arraySum(isLeapYear(date.tm_year+1900)?MONTH_DAYS_LEAP:MONTH_DAYS_REGULAR,date.tm_mon-1),3),"%m":date=>leadingNulls(date.tm_mon+1,2),"%M":date=>leadingNulls(date.tm_min,2),"%n":()=>"\n","%p":date=>{if(date.tm_hour>=0&&date.tm_hour<12){return"AM"}return"PM"},"%S":date=>leadingNulls(date.tm_sec,2),"%t":()=>"\t","%u":date=>date.tm_wday||7,"%U":date=>{var days=date.tm_yday+7-date.tm_wday;return leadingNulls(Math.floor(days/7),2)},"%V":date=>{var val=Math.floor((date.tm_yday+7-(date.tm_wday+6)%7)/7);if((date.tm_wday+371-date.tm_yday-2)%7<=2){val++}if(!val){val=52;var dec31=(date.tm_wday+7-date.tm_yday-1)%7;if(dec31==4||dec31==5&&isLeapYear(date.tm_year%400-1)){val++}}else if(val==53){var jan1=(date.tm_wday+371-date.tm_yday)%7;if(jan1!=4&&(jan1!=3||!isLeapYear(date.tm_year)))val=1}return leadingNulls(val,2)},"%w":date=>date.tm_wday,"%W":date=>{var days=date.tm_yday+7-(date.tm_wday+6)%7;return leadingNulls(Math.floor(days/7),2)},"%y":date=>(date.tm_year+1900).toString().substring(2),"%Y":date=>date.tm_year+1900,"%z":date=>{var off=date.tm_gmtoff;var ahead=off>=0;off=Math.abs(off)/60;off=off/60*100+off%60;return(ahead?"+":"-")+String("0000"+off).slice(-4)},"%Z":date=>date.tm_zone,"%%":()=>"%"};pattern=pattern.replace(/%%/g,"\0\0");for(var rule in EXPANSION_RULES_2){if(pattern.includes(rule)){pattern=pattern.replace(new RegExp(rule,"g"),EXPANSION_RULES_2[rule](date))}}pattern=pattern.replace(/\0\0/g,"%");var bytes=intArrayFromString(pattern,false);if(bytes.length>maxsize){return 0}writeArrayToMemory(bytes,s);return bytes.length-1};var _strftime_l=(s,maxsize,format,tm,loc)=>_strftime(s,maxsize,format,tm);var getCFunc=ident=>{var func=Module["_"+ident];return func};var stringToUTF8OnStack=str=>{var size=lengthBytesUTF8(str)+1;var ret=stackAlloc(size);stringToUTF8(str,ret,size);return ret};var ccall=(ident,returnType,argTypes,args,opts)=>{var toC={"string":str=>{var ret=0;if(str!==null&&str!==undefined&&str!==0){ret=stringToUTF8OnStack(str)}return ret},"array":arr=>{var ret=stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}};function convertReturnValue(ret){if(returnType==="string"){return UTF8ToString(ret)}if(returnType==="boolean")return Boolean(ret);return ret}var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i<args.length;i++){var converter=toC[argTypes[i]];if(converter){if(stack===0)stack=stackSave();cArgs[i]=converter(args[i])}else{cArgs[i]=args[i]}}}var ret=func.apply(null,cArgs);function onDone(ret){if(stack!==0)stackRestore(stack);return convertReturnValue(ret)}ret=onDone(ret);return ret};var FSNode=function(parent,name,mode,rdev){if(!parent){parent=this}this.parent=parent;this.mount=parent.mount;this.mounted=null;this.id=FS.nextInode++;this.name=name;this.mode=mode;this.node_ops={};this.stream_ops={};this.rdev=rdev};var readMode=292|73;var writeMode=146;Object.defineProperties(FSNode.prototype,{read:{get:function(){return(this.mode&readMode)===readMode},set:function(val){val?this.mode|=readMode:this.mode&=~readMode}},write:{get:function(){return(this.mode&writeMode)===writeMode},set:function(val){val?this.mode|=writeMode:this.mode&=~writeMode}},isFolder:{get:function(){return FS.isDir(this.mode)}},isDevice:{get:function(){return FS.isChrdev(this.mode)}}});FS.FSNode=FSNode;FS.createPreloadedFile=FS_createPreloadedFile;FS.staticInit();Module["FS_createPath"]=FS.createPath;Module["FS_createDataFile"]=FS.createDataFile;Module["FS_createPreloadedFile"]=FS.createPreloadedFile;Module["FS_unlink"]=FS.unlink;Module["FS_createLazyFile"]=FS.createLazyFile;Module["FS_createDevice"]=FS.createDevice;var wasmImports={a:___cxa_throw,e:___syscall_fcntl64,F:___syscall_fstat64,x:___syscall_getcwd,A:___syscall_getdents64,H:___syscall_ioctl,C:___syscall_lstat64,B:___syscall_mkdirat,D:___syscall_newfstatat,j:___syscall_openat,w:___syscall_readlinkat,y:___syscall_rmdir,E:___syscall_stat64,z:___syscall_unlinkat,I:__emscripten_get_now_is_monotonic,q:__gmtime_js,r:__localtime_js,s:__mktime_js,o:__mmap_js,p:__munmap_js,G:__tzset_js,f:_abort,v:_emscripten_asm_const_int,k:_emscripten_date_now,l:_emscripten_get_heap_max,c:_emscripten_get_now,K:_emscripten_memcpy_js,J:_emscripten_resize_heap,m:_environ_get,n:_environ_sizes_get,b:_exit,g:_fd_close,i:_fd_read,t:_fd_seek,h:_fd_write,u:_strftime,d:_strftime_l};var wasmExports=createWasm();var ___wasm_call_ctors=()=>(___wasm_call_ctors=wasmExports["M"])();var _CopyHeap=Module["_CopyHeap"]=(a0,a1,a2)=>(_CopyHeap=Module["_CopyHeap"]=wasmExports["N"])(a0,a1,a2);var _SherpaOnnxCreateOfflineRecognizer=Module["_SherpaOnnxCreateOfflineRecognizer"]=a0=>(_SherpaOnnxCreateOfflineRecognizer=Module["_SherpaOnnxCreateOfflineRecognizer"]=wasmExports["O"])(a0);var _SherpaOnnxDestroyOfflineRecognizer=Module["_SherpaOnnxDestroyOfflineRecognizer"]=a0=>(_SherpaOnnxDestroyOfflineRecognizer=Module["_SherpaOnnxDestroyOfflineRecognizer"]=wasmExports["P"])(a0);var _SherpaOnnxCreateOfflineStream=Module["_SherpaOnnxCreateOfflineStream"]=a0=>(_SherpaOnnxCreateOfflineStream=Module["_SherpaOnnxCreateOfflineStream"]=wasmExports["Q"])(a0);var _SherpaOnnxDestroyOfflineStream=Module["_SherpaOnnxDestroyOfflineStream"]=a0=>(_SherpaOnnxDestroyOfflineStream=Module["_SherpaOnnxDestroyOfflineStream"]=wasmExports["R"])(a0);var _SherpaOnnxAcceptWaveformOffline=Module["_SherpaOnnxAcceptWaveformOffline"]=(a0,a1,a2,a3)=>(_SherpaOnnxAcceptWaveformOffline=Module["_SherpaOnnxAcceptWaveformOffline"]=wasmExports["S"])(a0,a1,a2,a3);var _SherpaOnnxDecodeOfflineStream=Module["_SherpaOnnxDecodeOfflineStream"]=(a0,a1)=>(_SherpaOnnxDecodeOfflineStream=Module["_SherpaOnnxDecodeOfflineStream"]=wasmExports["T"])(a0,a1);var _SherpaOnnxDecodeMultipleOfflineStreams=Module["_SherpaOnnxDecodeMultipleOfflineStreams"]=(a0,a1,a2)=>(_SherpaOnnxDecodeMultipleOfflineStreams=Module["_SherpaOnnxDecodeMultipleOfflineStreams"]=wasmExports["U"])(a0,a1,a2);var _SherpaOnnxGetOfflineStreamResult=Module["_SherpaOnnxGetOfflineStreamResult"]=a0=>(_SherpaOnnxGetOfflineStreamResult=Module["_SherpaOnnxGetOfflineStreamResult"]=wasmExports["V"])(a0);var _SherpaOnnxDestroyOfflineRecognizerResult=Module["_SherpaOnnxDestroyOfflineRecognizerResult"]=a0=>(_SherpaOnnxDestroyOfflineRecognizerResult=Module["_SherpaOnnxDestroyOfflineRecognizerResult"]=wasmExports["W"])(a0);var _SherpaOnnxGetOfflineStreamResultAsJson=Module["_SherpaOnnxGetOfflineStreamResultAsJson"]=a0=>(_SherpaOnnxGetOfflineStreamResultAsJson=Module["_SherpaOnnxGetOfflineStreamResultAsJson"]=wasmExports["X"])(a0);var _SherpaOnnxDestroyOfflineStreamResultJson=Module["_SherpaOnnxDestroyOfflineStreamResultJson"]=a0=>(_SherpaOnnxDestroyOfflineStreamResultJson=Module["_SherpaOnnxDestroyOfflineStreamResultJson"]=wasmExports["Y"])(a0);var _SherpaOnnxCreateCircularBuffer=Module["_SherpaOnnxCreateCircularBuffer"]=a0=>(_SherpaOnnxCreateCircularBuffer=Module["_SherpaOnnxCreateCircularBuffer"]=wasmExports["Z"])(a0);var _SherpaOnnxDestroyCircularBuffer=Module["_SherpaOnnxDestroyCircularBuffer"]=a0=>(_SherpaOnnxDestroyCircularBuffer=Module["_SherpaOnnxDestroyCircularBuffer"]=wasmExports["_"])(a0);var _SherpaOnnxCircularBufferPush=Module["_SherpaOnnxCircularBufferPush"]=(a0,a1,a2)=>(_SherpaOnnxCircularBufferPush=Module["_SherpaOnnxCircularBufferPush"]=wasmExports["$"])(a0,a1,a2);var _SherpaOnnxCircularBufferGet=Module["_SherpaOnnxCircularBufferGet"]=(a0,a1,a2)=>(_SherpaOnnxCircularBufferGet=Module["_SherpaOnnxCircularBufferGet"]=wasmExports["aa"])(a0,a1,a2);var _SherpaOnnxCircularBufferFree=Module["_SherpaOnnxCircularBufferFree"]=a0=>(_SherpaOnnxCircularBufferFree=Module["_SherpaOnnxCircularBufferFree"]=wasmExports["ba"])(a0);var _SherpaOnnxCircularBufferPop=Module["_SherpaOnnxCircularBufferPop"]=(a0,a1)=>(_SherpaOnnxCircularBufferPop=Module["_SherpaOnnxCircularBufferPop"]=wasmExports["ca"])(a0,a1);var _SherpaOnnxCircularBufferSize=Module["_SherpaOnnxCircularBufferSize"]=a0=>(_SherpaOnnxCircularBufferSize=Module["_SherpaOnnxCircularBufferSize"]=wasmExports["da"])(a0);var _SherpaOnnxCircularBufferHead=Module["_SherpaOnnxCircularBufferHead"]=a0=>(_SherpaOnnxCircularBufferHead=Module["_SherpaOnnxCircularBufferHead"]=wasmExports["ea"])(a0);var _SherpaOnnxCircularBufferReset=Module["_SherpaOnnxCircularBufferReset"]=a0=>(_SherpaOnnxCircularBufferReset=Module["_SherpaOnnxCircularBufferReset"]=wasmExports["fa"])(a0);var _SherpaOnnxCreateVoiceActivityDetector=Module["_SherpaOnnxCreateVoiceActivityDetector"]=(a0,a1)=>(_SherpaOnnxCreateVoiceActivityDetector=Module["_SherpaOnnxCreateVoiceActivityDetector"]=wasmExports["ga"])(a0,a1);var _SherpaOnnxDestroyVoiceActivityDetector=Module["_SherpaOnnxDestroyVoiceActivityDetector"]=a0=>(_SherpaOnnxDestroyVoiceActivityDetector=Module["_SherpaOnnxDestroyVoiceActivityDetector"]=wasmExports["ha"])(a0);var _SherpaOnnxVoiceActivityDetectorAcceptWaveform=Module["_SherpaOnnxVoiceActivityDetectorAcceptWaveform"]=(a0,a1,a2)=>(_SherpaOnnxVoiceActivityDetectorAcceptWaveform=Module["_SherpaOnnxVoiceActivityDetectorAcceptWaveform"]=wasmExports["ia"])(a0,a1,a2);var _SherpaOnnxVoiceActivityDetectorEmpty=Module["_SherpaOnnxVoiceActivityDetectorEmpty"]=a0=>(_SherpaOnnxVoiceActivityDetectorEmpty=Module["_SherpaOnnxVoiceActivityDetectorEmpty"]=wasmExports["ja"])(a0);var _SherpaOnnxVoiceActivityDetectorDetected=Module["_SherpaOnnxVoiceActivityDetectorDetected"]=a0=>(_SherpaOnnxVoiceActivityDetectorDetected=Module["_SherpaOnnxVoiceActivityDetectorDetected"]=wasmExports["ka"])(a0);var _SherpaOnnxVoiceActivityDetectorPop=Module["_SherpaOnnxVoiceActivityDetectorPop"]=a0=>(_SherpaOnnxVoiceActivityDetectorPop=Module["_SherpaOnnxVoiceActivityDetectorPop"]=wasmExports["la"])(a0);var _SherpaOnnxVoiceActivityDetectorClear=Module["_SherpaOnnxVoiceActivityDetectorClear"]=a0=>(_SherpaOnnxVoiceActivityDetectorClear=Module["_SherpaOnnxVoiceActivityDetectorClear"]=wasmExports["ma"])(a0);var _SherpaOnnxVoiceActivityDetectorFront=Module["_SherpaOnnxVoiceActivityDetectorFront"]=a0=>(_SherpaOnnxVoiceActivityDetectorFront=Module["_SherpaOnnxVoiceActivityDetectorFront"]=wasmExports["na"])(a0);var _SherpaOnnxDestroySpeechSegment=Module["_SherpaOnnxDestroySpeechSegment"]=a0=>(_SherpaOnnxDestroySpeechSegment=Module["_SherpaOnnxDestroySpeechSegment"]=wasmExports["oa"])(a0);var _SherpaOnnxVoiceActivityDetectorReset=Module["_SherpaOnnxVoiceActivityDetectorReset"]=a0=>(_SherpaOnnxVoiceActivityDetectorReset=Module["_SherpaOnnxVoiceActivityDetectorReset"]=wasmExports["pa"])(a0);var _SherpaOnnxVoiceActivityDetectorFlush=Module["_SherpaOnnxVoiceActivityDetectorFlush"]=a0=>(_SherpaOnnxVoiceActivityDetectorFlush=Module["_SherpaOnnxVoiceActivityDetectorFlush"]=wasmExports["qa"])(a0);var _SherpaOnnxFileExists=Module["_SherpaOnnxFileExists"]=a0=>(_SherpaOnnxFileExists=Module["_SherpaOnnxFileExists"]=wasmExports["ra"])(a0);var ___errno_location=()=>(___errno_location=wasmExports["sa"])();var _malloc=Module["_malloc"]=a0=>(_malloc=Module["_malloc"]=wasmExports["ua"])(a0);var _free=Module["_free"]=a0=>(_free=Module["_free"]=wasmExports["va"])(a0);var _emscripten_builtin_memalign=(a0,a1)=>(_emscripten_builtin_memalign=wasmExports["wa"])(a0,a1);var setTempRet0=a0=>(setTempRet0=wasmExports["xa"])(a0);var stackSave=()=>(stackSave=wasmExports["ya"])();var stackRestore=a0=>(stackRestore=wasmExports["za"])(a0);var stackAlloc=a0=>(stackAlloc=wasmExports["Aa"])(a0);var ___cxa_is_pointer_type=a0=>(___cxa_is_pointer_type=wasmExports["Ba"])(a0);Module["addRunDependency"]=addRunDependency;Module["removeRunDependency"]=removeRunDependency;Module["FS_createPath"]=FS.createPath;Module["FS_createLazyFile"]=FS.createLazyFile;Module["FS_createDevice"]=FS.createDevice;Module["ccall"]=ccall;Module["setValue"]=setValue;Module["getValue"]=getValue;Module["UTF8ToString"]=UTF8ToString;Module["stringToUTF8"]=stringToUTF8;Module["lengthBytesUTF8"]=lengthBytesUTF8;Module["FS_createPreloadedFile"]=FS.createPreloadedFile;Module["FS_createDataFile"]=FS.createDataFile;Module["FS_unlink"]=FS.unlink;var calledRun;dependenciesFulfilled=function runCaller(){if(!calledRun)run();if(!calledRun)dependenciesFulfilled=runCaller};function run(){if(runDependencies>0){return}preRun();if(runDependencies>0){return}function doRun(){if(calledRun)return;calledRun=true;Module["calledRun"]=true;if(ABORT)return;initRuntime();if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(function(){setTimeout(function(){Module["setStatus"]("")},1);doRun()},1)}else{doRun()}}if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}run();
sherpa-onnx-wasm-main-vad-asr.wasm ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:056ca836de68792da4fa64280c69f0071bab72d5d07bae785d23372585256261
3
+ size 11384694