diff --git a/lib/utils/tts-streaming-buffer.js b/lib/utils/tts-streaming-buffer.js index b397aeeb..6745121f 100644 --- a/lib/utils/tts-streaming-buffer.js +++ b/lib/utils/tts-streaming-buffer.js @@ -437,7 +437,15 @@ class TtsStreamingBuffer extends Emitter { const findSentenceBoundary = (text, limit) => { // Look for punctuation or double newline that signals sentence end. - const sentenceEndRegex = /[.!?](?=\s|$)|\n\n/g; + // Includes: + // - ASCII: . ! ? + // - Arabic: ؟ (question mark), ۔ (full stop) + // - Japanese: 。 (full stop), !, ? (full-width exclamation/question) + // + // For languages that use spaces between sentences, we still require + // whitespace or end-of-string after the mark. For Japanese (no spaces), + // we treat the punctuation itself as a boundary regardless of following char. + const sentenceEndRegex = /[.!?؟۔](?=\s|$)|[。!?]|\n\n/g; let lastSentenceBoundary = -1; let match; while ((match = sentenceEndRegex.exec(text)) && match.index < limit) {