diff --git a/src/core/streaming-fetcher/Stream.ts b/src/core/streaming-fetcher/Stream.ts index dccdb79..62db6ce 100644 --- a/src/core/streaming-fetcher/Stream.ts +++ b/src/core/streaming-fetcher/Stream.ts @@ -90,9 +90,14 @@ export class Stream implements AsyncIterable { return; } - // Otherwise, yield message from the prefix to the terminator - const message = await this.parse(JSON.parse(line)); - yield message; + // (Louis custom fix do not override) Trim whitespace and check if line is not empty + // Reason: ElevenLabs occasionally returns empty chunks + const trimmedLine = line.trim(); + if (trimmedLine) { + const message = await this.parse(JSON.parse(trimmedLine)); + yield message; + } + prefixSeen = false; } }