diff options
| author | historia <historiavg@proton.me> | 2026-09-09 23:25:52 -0400 |
|---|---|---|
| committer | historia <historiavg@proton.me> | 2026-09-09 23:25:52 -0400 |
| commit | 31459b281b6a5368c692b3c42c91e522995ebd57 (patch) | |
| tree | ea6a53f4252e6a08d954c4b2fc9369d8db376d0a /app/tests/test_converter.py | |
| parent | 130dcd988e0554a6343c92fd45d808fd508789b3 (diff) | |
| download | tts-audiobook-generator-31459b281b6a5368c692b3c42c91e522995ebd57.tar.gz | |
feat: smart chunking to avoid chunk boundaries mid-sentence
Diffstat (limited to 'app/tests/test_converter.py')
| -rw-r--r-- | app/tests/test_converter.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/app/tests/test_converter.py b/app/tests/test_converter.py index 85ae6ca..9084898 100644 --- a/app/tests/test_converter.py +++ b/app/tests/test_converter.py @@ -585,6 +585,24 @@ class ChunkClampPromptTests(unittest.TestCase): with patch.object(config, "CHUNK_SIZE", 80): self.assertFalse(chunk_clamp_needed(self._entry())) + def test_per_run_clamp_caps_the_chapter_chunks(self): + # The popup's clamp caps the chapter chunks themselves, so each + # progress unit and debug dump spans one generation request. + converter = AudiobookConverter.__new__(AudiobookConverter) + converter.chunk_size = 4 + with patch.object(config, "CHUNK_SIZE", 250): + chunks = converter._chapter_chunks(" ".join(f"Sw{i} ." for i in range(12))) + self.assertGreater(len(chunks), 1) + self.assertTrue(all(len(c.split()) <= 4 for c in chunks)) + + def test_chapter_chunks_follow_chunk_size_without_a_clamp(self): + converter = AudiobookConverter.__new__(AudiobookConverter) + self.assertIsNone(converter.chunk_size) + with patch.object(config, "CHUNK_SIZE", 8): + chunks = converter._chapter_chunks(" ".join(f"Sw{i} ." for i in range(20))) + self.assertGreater(len(chunks), 1) + self.assertTrue(all(len(c.split()) <= 8 for c in chunks)) + def test_prompt_answers(self): entry = self._entry() with patch("builtins.input", return_value=""): |
