MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / restartStream

Function restartStream

speech/infiniteStreaming.js:194–220  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

192 });
193
194 function restartStream() {
195 if (recognizeStream) {
196 recognizeStream.end();
197 recognizeStream.removeListener('data', speechCallback);
198 recognizeStream = null;
199 }
200 if (resultEndTime > 0) {
201 finalRequestEndTime = isFinalEndTime;
202 }
203 resultEndTime = 0;
204
205 lastAudioInput = [];
206 lastAudioInput = audioInput;
207
208 restartCounter++;
209
210 if (!lastTranscriptWasFinal) {
211 process.stdout.write('\n');
212 }
213 process.stdout.write(
214 chalk.yellow(`${streamingLimit * restartCounter}: RESTARTING REQUEST\n`)
215 );
216
217 newStream = true;
218
219 startStream();
220 }
221 // Start recording and send the microphone input to the Speech API
222 recorder
223 .record({

Callers

nothing calls this directly

Calls 1

startStreamFunction · 0.85

Tested by

no test coverage detected