()
| 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({ |
nothing calls this directly
no test coverage detected