fix: subtitle FakeToken split, missing run_tts_segment_loop import

- subtitle_generation: split multi-sentence FakeToken into separate entries
- conversion.py: add missing run_tts_segment_loop import

No changes to spacy_utils or Language enum.
This commit is contained in:
Deniz Şafak
2026-07-23 03:15:21 +03:00
parent d5cddb9749
commit bd99ee1ba1
2 changed files with 16 additions and 4 deletions
+15 -3
View File
@@ -280,16 +280,28 @@ def _process_regex_sentences(
current_sentence = [] current_sentence = []
word_count = 0 word_count = 0
# Add any remaining tokens as a sentence # Add any remaining tokens as a sentence (split multi-sentence FakeToken)
if current_sentence: if current_sentence:
start_time = current_sentence[0]["start"] start_time = current_sentence[0]["start"]
end_time = current_sentence[-1]["end"] end_time = current_sentence[-1]["end"]
# Simplified text joining logic
sentence_text = "" sentence_text = ""
for t in current_sentence: for t in current_sentence:
sentence_text += t["text"] + (t.get("whitespace") or "") sentence_text += t["text"] + (t.get("whitespace") or "")
subtitle_entries.append((start_time, end_time, sentence_text.strip())) sentence_text = sentence_text.strip()
if len(current_sentence) == 1:
parts = re.split(rf"(?<={separator})\s+", sentence_text)
if len(parts) > 1:
d = end_time - start_time
for i, p in enumerate(parts):
e = end_time if i == len(parts) - 1 else start_time + d * len(p) / len(sentence_text)
subtitle_entries.append((start_time, e, p.strip()))
start_time = e
current_sentence = []
if current_sentence:
subtitle_entries.append((start_time, end_time, sentence_text))
# Fallback for last entry # Fallback for last entry
_apply_fallback_end_time(subtitle_entries, fallback_end_time) _apply_fallback_end_time(subtitle_entries, fallback_end_time)
+1 -1
View File
@@ -36,7 +36,7 @@ from abogen.domain.output_paths import (
) )
from abogen.domain.audio_helpers import build_ffmpeg_command, to_float32 from abogen.domain.audio_helpers import build_ffmpeg_command, to_float32
from abogen.domain.audio_sink import AudioSink, open_audio_sink from abogen.domain.audio_sink import AudioSink, open_audio_sink
from abogen.domain.conversion_engine import synthesize_text, SynthParams, SegmentStats, SegmentInfo from abogen.domain.conversion_engine import run_tts_segment_loop, synthesize_text, SynthParams, SegmentStats, SegmentInfo
from abogen.domain.intro_outro import resolve_intro, resolve_outro from abogen.domain.intro_outro import resolve_intro, resolve_outro
from abogen.domain.audio_buffer import ( from abogen.domain.audio_buffer import (
create_silence, create_silence,