Created
September 16, 2022 17:08
-
-
Save seatedro/86acddf28e4eade13f206490993f35a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
restartStream() { | |
if (this.recognizeStream) { | |
this.recognizeStream.end(); | |
this.recognizeStream.removeAllListeners(); | |
this.recognizeStream = null; | |
} | |
if (this.resultEndTime > 0) { | |
this.finalRequestEndTime = this.isFinalEndTime; | |
} | |
this.resultEndTime = 0; | |
this.lastAudioInput = []; | |
this.lastAudioInput = this.audioInput; | |
this.restartCounter++; | |
if (!this.lastTranscriptWasFinal) { | |
process.stdout.write("\n"); | |
} | |
process.stdout.write( | |
chalk.yellow( | |
`${this.streamingLimit * this.restartCounter}: RESTARTING REQUEST\n` | |
) | |
); | |
this.newStream = true; | |
this.startRecognitionStream(); | |
} | |
/** | |
* Closes the recognize stream and wipes it | |
*/ | |
stopRecognitionStream() { | |
if (this.recognizeStream) { | |
this.recognizeStream.end(); | |
this.recognizeStream.removeAllListeners(); | |
} | |
if (this.restartTimeout) { | |
clearTimeout(this.restartTimeout); | |
} | |
this.recognizeStream = null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment