fix cartesia channel vars for streaming (#1012)

This commit is contained in:
Dave Horton
2024-12-20 16:48:20 -05:00
committed by GitHub
parent 13ef89d605
commit 02f25f8343
2 changed files with 8 additions and 6 deletions

View File

@@ -110,7 +110,6 @@ class TtsStreamingBuffer extends Emitter {
return {status: 'failed', reason: `connection to ${this.vendor} failed`};
}
const starting = this.tokens === '';
const displayedTokens = tokens.length <= 40 ? tokens : tokens.substring(0, 40);
const totalLength = tokens.length;
@@ -127,14 +126,14 @@ class TtsStreamingBuffer extends Emitter {
}
this.logger.debug(
`TtsStreamingBuffer:bufferTokens "${displayedTokens}" (length: ${totalLength}), starting? ${starting}`
`TtsStreamingBuffer:bufferTokens "${displayedTokens}" (length: ${totalLength}), starting? ${this.isEmpty}`
);
this.tokens += (tokens || '');
const leftoverTokens = await this._feedTokens();
/* do we need to start a timer to periodically feed tokens to the endpoint? */
if (starting && leftoverTokens > 0) {
if (this.isEmpty && leftoverTokens > 0) {
assert(!this.timer);
this.timer = setInterval(async() => {
const remaining = await this._feedTokens();