Add VAD and keyword spotting for the Node package with WebAssembly (#1286)

This commit is contained in:
Fangjun Kuang
2024-08-24 23:05:54 +08:00
committed by GitHub
parent 537e163dd0
commit 5ed8e31868
40 changed files with 456 additions and 524 deletions

View File

@@ -1,5 +1,5 @@
{
"dependencies": {
"sherpa-onnx-node": "^1.10.22"
"sherpa-onnx-node": "^1.10.23"
}
}

View File

@@ -42,11 +42,11 @@ stream.acceptWaveform({samples: tailPadding, sampleRate: wave.sampleRate});
const detectedKeywords = [];
while (kws.isReady(stream)) {
kws.decode(stream);
const keyword = kws.getResult(stream).keyword;
if (keyword != '') {
detectedKeywords.push(keyword);
}
kws.decode(stream);
}
let stop = Date.now();

View File

@@ -120,8 +120,8 @@ console.log('Done')
const elapsed_seconds = (stop - start) / 1000;
const duration = wave.samples.length / wave.sampleRate;
const real_time_factor = elapsed_seconds / duration;
console.log('Wave duration', duration.toFixed(3), 'secodns')
console.log('Elapsed', elapsed_seconds.toFixed(3), 'secodns')
console.log('Wave duration', duration.toFixed(3), 'seconds')
console.log('Elapsed', elapsed_seconds.toFixed(3), 'seconds')
console.log(
`RTF = ${elapsed_seconds.toFixed(3)}/${duration.toFixed(3)} =`,
real_time_factor.toFixed(3))