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 Feb 3, 2021
1 parent eee3583 commit cda9db5
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 cda9db5

Please sign in to comment.