fixed tts streaming buffer cannot reset timeoutwhen lastUpdateTime is short (#1184)

* fixed tts streaming buffer cannot reset timeoutwhen lastUpdateTime is short

* wip
This commit is contained in:
Hoan Luu Huu
2025-05-07 21:26:11 +07:00
committed by GitHub
parent e4bb00b382
commit 8b18532f31

View File

@@ -8,7 +8,7 @@ const {
const MAX_CHUNK_SIZE = 1800;
const HIGH_WATER_BUFFER_SIZE = 1000;
const LOW_WATER_BUFFER_SIZE = 200;
const TIMEOUT_RETRY_MSECS = 3000;
const TIMEOUT_RETRY_MSECS = 1000; // 1 second
const isWhitespace = (str) => /^\s*$/.test(str);
@@ -377,6 +377,7 @@ class TtsStreamingBuffer extends Emitter {
_onTimeout() {
this.logger.debug('TtsStreamingBuffer:_onTimeout Timeout waiting for sentence boundary');
this.timer = null;
// Check if new text has been added since the timer was set.
const now = Date.now();
if (now - this.lastUpdateTime < TIMEOUT_RETRY_MSECS) {
@@ -384,7 +385,6 @@ class TtsStreamingBuffer extends Emitter {
this._setTimerIfNeeded();
return;
}
this.timer = null;
this._feedQueue(true);
}