Skip to content

Commit

Permalink
fix: Added check to see if stream has been destroyed before writing r…
Browse files Browse the repository at this point in the history
…esult… (#107)
  • Loading branch information
awoehler authored and kweinmeister committed Nov 8, 2022
1 parent 99227de commit 7f7405b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion media-translation/translate_from_mic.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ function main(encoding, sampleRateHertz, sourceLanguage, targetLanguage) {
streamingConfig: config,
audioContent: chunk.toString('base64'),
};
stream.write(request);
if (!stream.destroyed) {
stream.write(request);
}
})
.on('close', () => {
doTranslationLoop();
Expand Down

0 comments on commit 7f7405b

Please sign in to comment.