mirror of
https://github.com/denizsafak/abogen.git
synced 2026-07-18 21:50:28 +02:00
feat: Integrate roman numeral normalization in chapter titles and enhance related tests
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user