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

Function startStream

speech/infiniteStreaming.js:98–115  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

96 let lastTranscriptWasFinal = false;
97
98 function startStream() {
99 // Clear current audioInput
100 audioInput = [];
101 // Initiate (Reinitiate) a recognize stream
102 recognizeStream = client
103 .streamingRecognize(request)
104 .on('error', err => {
105 if (err.code === 11) {
106 // restartStream();
107 } else {
108 console.error('API request error ' + err);
109 }
110 })
111 .on('data', speechCallback);
112
113 // Restart stream when streamingLimit expires
114 setTimeout(restartStream, streamingLimit);
115 }
116
117 const speechCallback = stream => {
118 // Convert API result end time from seconds + nanoseconds to milliseconds

Callers 2

restartStreamFunction · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected