From 8b18532f31a4b6ca3456c227c73f352591f2279b Mon Sep 17 00:00:00 2001 From: Hoan Luu Huu <110280845+xquanluu@users.noreply.github.com> Date: Wed, 7 May 2025 21:26:11 +0700 Subject: [PATCH] fixed tts streaming buffer cannot reset timeoutwhen lastUpdateTime is short (#1184) * fixed tts streaming buffer cannot reset timeoutwhen lastUpdateTime is short * wip --- lib/utils/tts-streaming-buffer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/utils/tts-streaming-buffer.js b/lib/utils/tts-streaming-buffer.js index f3813ef6..de55342d 100644 --- a/lib/utils/tts-streaming-buffer.js +++ b/lib/utils/tts-streaming-buffer.js @@ -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); }