Skip to content

Commit

Permalink
Fix WASM example for kws
Browse files Browse the repository at this point in the history
  • Loading branch information
csukuangfj committed Jan 20, 2025
1 parent ae281ac commit e68a906
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 8 additions & 6 deletions wasm/kws/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,17 @@ if (navigator.mediaDevices.getUserMedia) {
recognizer_stream.acceptWaveform(expectedSampleRate, samples);
while (recognizer.isReady(recognizer_stream)) {
recognizer.decode(recognizer_stream);
}

let result = recognizer.getResult(recognizer_stream);

let result = recognizer.getResult(recognizer_stream);
if (result.keyword.length > 0) {
console.log(result)
lastResult = result;
resultList.push(JSON.stringify(result));

if (result.keyword.length > 0) {
console.log(result)
lastResult = result;
resultList.push(JSON.stringify(result));
// remember to reset the stream right after detecting a keyword
recognizer.reset(recognizer_stream);
}
}


Expand Down
6 changes: 2 additions & 4 deletions wasm/kws/sherpa-onnx-kws.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,13 +296,11 @@ class Kws {
}

decode(stream) {
return this.Module._SherpaOnnxDecodeKeywordStream(
this.handle, stream.handle);
this.Module._SherpaOnnxDecodeKeywordStream(this.handle, stream.handle);
}

reset(stream) {
return this.Module._SherpaOnnxResetKeywordStream(
this.handle, stream.handle);
this.Module._SherpaOnnxResetKeywordStream(this.handle, stream.handle);
}

getResult(stream) {
Expand Down

0 comments on commit e68a906

Please sign in to comment.