diff options
| author | historia <historiavg@proton.me> | 2026-09-10 00:16:00 -0400 |
|---|---|---|
| committer | historia <historiavg@proton.me> | 2026-09-10 00:16:00 -0400 |
| commit | e2da233cd1baa859a5721542fc8b80d9f3f880e7 (patch) | |
| tree | 4e86797cbd7dce0434feef65bc0ad2e97bfbe4c0 /app/tests/test_audio.py | |
| parent | 31459b281b6a5368c692b3c42c91e522995ebd57 (diff) | |
| download | tts-audiobook-generator-e2da233cd1baa859a5721542fc8b80d9f3f880e7.tar.gz | |
Diffstat (limited to 'app/tests/test_audio.py')
| -rw-r--r-- | app/tests/test_audio.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/app/tests/test_audio.py b/app/tests/test_audio.py index 75de97c..04a6afc 100644 --- a/app/tests/test_audio.py +++ b/app/tests/test_audio.py @@ -51,6 +51,36 @@ class AtempoFiltersTests(unittest.TestCase): with self.assertRaises(ValueError): atempo_filters(-1.5) + def test_infinite_speed_rejected(self): + # inf passes a bare positivity check; without the finite guard + # atempo chaining would loop forever (inf / 2.0 stays inf). + with self.assertRaises(ValueError): + atempo_filters(float("inf")) + + def test_overflowing_speed_rejected(self): + with self.assertRaises(ValueError): + atempo_filters(1e309) + + def test_nan_speed_rejected(self): + with self.assertRaises(ValueError): + atempo_filters(float("nan")) + + def test_asplit_used_for_audio_streams(self): + # split is a video filter and rejects an audio stream, so a + # speed-adjusted copy needs asplit — in both command builders. + concat_cmd = build_concat_command( + Path("/tmp/_concat.txt"), Path("/tmp/out.mp3"), "mp3", + speed=1.5, speed_path=Path("/tmp/out_1.5.mp3")) + m4b_cmd = build_m4b_chapters_command( + Path("/tmp/_concat.txt"), Path("/tmp/_meta.txt"), + Path("/tmp/out.m4b"), speed=1.5, + speed_path=Path("/tmp/out_1.5.m4b"), + speed_metadata_file=Path("/tmp/_meta2.txt")) + for cmd in (concat_cmd, m4b_cmd): + filter_complex = cmd[cmd.index("-filter_complex") + 1] + self.assertIn("[0:a]asplit=2", filter_complex) + self.assertNotIn("[0:a]split=2", filter_complex) + class CleanupChunksTests(unittest.TestCase): def test_removes_only_chunk_files(self): |
