Skip to content

Commit

Permalink
Wait for microphone to finalize. Fixes crash in issue #1034
Browse files Browse the repository at this point in the history
  • Loading branch information
nshmyrev committed Jun 27, 2022
1 parent a7bc5a2 commit 58fa98c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions nodejs/demo/test_microphone.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ var micInstance = mic({
});

var micInputStream = micInstance.getAudioStream();
micInstance.start();

micInputStream.on('data', data => {
if (rec.acceptWaveform(data))
Expand All @@ -32,9 +31,16 @@ micInputStream.on('data', data => {
console.log(rec.partialResult());
});

process.on('SIGINT', function() {
micInputStream.on('audioProcessExitComplete', function() {
console.log("Cleaning up");
console.log(rec.finalResult());
console.log("\nDone");
rec.free();
model.free();
});

process.on('SIGINT', function() {
console.log("\nStopping");
micInstance.stop();
});

micInstance.start();

0 comments on commit 58fa98c

Please sign in to comment.