mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-19 04:17:44 +00:00
fd_1574: should not send only whitespace to streaming tts engine (#1415)
This commit is contained in:
@@ -278,6 +278,14 @@ class TtsStreamingBuffer extends Emitter {
|
||||
}
|
||||
const chunk = combinedText.slice(0, chunkEnd);
|
||||
|
||||
// Check if the chunk is only whitespace before processing the queue
|
||||
// If so, wait for more meaningful text
|
||||
if (isWhitespace(chunk)) {
|
||||
this.logger.debug('TtsStreamingBuffer:_feedQueue chunk is only whitespace, waiting for more text');
|
||||
this._setTimerIfNeeded();
|
||||
return;
|
||||
}
|
||||
|
||||
// Now we iterate over the queue items
|
||||
// and deduct their lengths until we've accounted for chunkEnd characters.
|
||||
let remaining = chunkEnd;
|
||||
@@ -301,6 +309,14 @@ class TtsStreamingBuffer extends Emitter {
|
||||
this.bufferedLength -= chunkEnd;
|
||||
|
||||
const modifiedChunk = chunk.replace(/\n\n/g, '\n \n');
|
||||
|
||||
if (isWhitespace(modifiedChunk)) {
|
||||
this.logger.debug('TtsStreamingBuffer:_feedQueue modified chunk is only whitespace, restoring queue');
|
||||
this.queue.unshift({ type: 'text', value: chunk });
|
||||
this.bufferedLength += chunkEnd;
|
||||
this._setTimerIfNeeded();
|
||||
return;
|
||||
}
|
||||
this.logger.debug(`TtsStreamingBuffer:_feedQueue sending chunk to tts: ${modifiedChunk}`);
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user