diff --git a/media-translation/translate_from_mic.js b/media-translation/translate_from_mic.js index 73339c9290..1ea70744b4 100644 --- a/media-translation/translate_from_mic.js +++ b/media-translation/translate_from_mic.js @@ -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();