feat: Integrate roman numeral normalization in chapter titles and enhance related tests

This commit is contained in:
JB
2025-10-10 09:31:27 -07:00
parent 3a91e79cb6
commit 443dee09b6
3 changed files with 201 additions and 22 deletions
+8
View File
@@ -41,6 +41,7 @@ from abogen.constants import (
VOICES_INTERNAL,
)
from abogen.chunking import ChunkLevel, build_chunks_for_chapters
from abogen.kokoro_text_normalization import normalize_roman_numeral_titles
from abogen.utils import (
calculate_text_length,
clean_text,
@@ -2049,6 +2050,13 @@ def enqueue_job() -> ResponseReturnValue:
cover_path, cover_mime = _persist_cover_image(extraction, stored_path)
if extraction.chapters:
original_titles = [chapter.title for chapter in extraction.chapters]
normalized_titles = normalize_roman_numeral_titles(original_titles)
if normalized_titles != original_titles:
for chapter, new_title in zip(extraction.chapters, normalized_titles):
chapter.title = new_title
metadata_tags = extraction.metadata or {}
total_chars = extraction.total_characters or calculate_text_length(extraction.combined_text)
total_chapter_count = len(extraction.chapters)