diff --git a/speech.py b/speech.py index bfbd5e8..0ea970e 100755 --- a/speech.py +++ b/speech.py @@ -519,16 +519,13 @@ def preprocess(raw_input): def simple_sentence_split(text: str, max_length: int = 500) -> list[str]: """Split text into sentences for streaming TTS. - Splits on sentence boundaries (.!?) for immediate streaming. - Only combines very short sentences (< 50 chars) with the next one. + Splits on every sentence boundary (.!?) for immediate streaming. Long sentences exceeding max_length are split at word boundaries. """ # Split on sentence boundaries, keeping the punctuation parts = re.split(r'([.!?]+\s*)', text) result = [] - current = "" - for i in range(0, len(parts), 2): sentence = parts[i].strip() punct = parts[i+1] if i+1 < len(parts) else "" @@ -536,21 +533,9 @@ def simple_sentence_split(text: str, max_length: int = 500) -> list[str]: if not sentence: continue - full_sentence = sentence + punct - - # If sentence is very short, combine with current buffer - if len(full_sentence) < 50 and current: - current += " " + full_sentence - elif current: - # Save buffered content and start fresh - result.append(current.strip()) - current = full_sentence - else: - current = full_sentence - - # Add remaining text - if current.strip(): - result.append(current.strip()) + full_sentence = (sentence + punct).strip() + if full_sentence: + result.append(full_sentence) # Split any sentences that exceed max_length at word boundaries final_result = []