mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2026-01-25 02:07:56 +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);
|
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
|
// Now we iterate over the queue items
|
||||||
// and deduct their lengths until we've accounted for chunkEnd characters.
|
// and deduct their lengths until we've accounted for chunkEnd characters.
|
||||||
let remaining = chunkEnd;
|
let remaining = chunkEnd;
|
||||||
@@ -301,6 +309,14 @@ class TtsStreamingBuffer extends Emitter {
|
|||||||
this.bufferedLength -= chunkEnd;
|
this.bufferedLength -= chunkEnd;
|
||||||
|
|
||||||
const modifiedChunk = chunk.replace(/\n\n/g, '\n \n');
|
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}`);
|
this.logger.debug(`TtsStreamingBuffer:_feedQueue sending chunk to tts: ${modifiedChunk}`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user