diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_chunking.py | 2 | ||||
| -rw-r--r-- | tests/test_converter.py | 22 | ||||
| -rw-r--r-- | tests/test_tts.py | 18 |
3 files changed, 23 insertions, 19 deletions
diff --git a/tests/test_chunking.py b/tests/test_chunking.py index 3cd926b..2904e40 100644 --- a/tests/test_chunking.py +++ b/tests/test_chunking.py @@ -10,7 +10,7 @@ from converter.chunking import split_into_chunks class ChunkSizeDefaultTests(unittest.TestCase): """Guard the request-size setting: each API call is one model generation, and the servers silently truncate audio when a single - generation runs too long (~2.5 min faster backend, ~11 min Gradio + generation runs too long (~2.5 min faster backend, ~11 min Qwen demo), so the default chunk size must stay well inside that budget. There is no hard ceiling beyond CHUNK_SIZE; users raising it accept the truncation risk themselves.""" diff --git a/tests/test_converter.py b/tests/test_converter.py index e7c0776..f09e151 100644 --- a/tests/test_converter.py +++ b/tests/test_converter.py @@ -56,17 +56,17 @@ class ConfigurationValidationTests(unittest.TestCase): def test_language_defaults_to_config(self): with patch("converter.converter.QwenTTSClient") as mock_tts: - AudiobookConverter() + AudiobookConverter(backend=tts.BACKEND_QWEN) self.assertEqual(mock_tts.call_args.kwargs["language"], config.LANGUAGE) def test_output_format_defaults_to_config(self): with patch("converter.converter.QwenTTSClient"): - converter = AudiobookConverter() + converter = AudiobookConverter(backend=tts.BACKEND_QWEN) self.assertEqual(converter.output_format, config.AUDIO_FORMAT) def test_language_normalized_before_tts_client(self): with patch("converter.converter.QwenTTSClient") as mock_tts: - converter = AudiobookConverter(language="ja") + converter = AudiobookConverter(language="ja", backend=tts.BACKEND_QWEN) self.assertEqual(converter.language, "Japanese") self.assertEqual(mock_tts.call_args.kwargs["language"], "Japanese") @@ -129,7 +129,7 @@ class NarratorTagTests(unittest.TestCase): converter = AudiobookConverter.__new__(AudiobookConverter) converter.voice_mode = voice_mode converter.voice_clone_ref_audio = ref_audio - converter.backend = tts.BACKEND_GRADIO + converter.backend = tts.BACKEND_QWEN converter.voice = None return converter @@ -274,8 +274,8 @@ class DebugDumpTests(unittest.TestCase): def test_debug_flag_wiring(self): with patch("converter.converter.QwenTTSClient"): - self.assertFalse(AudiobookConverter().debug) - self.assertTrue(AudiobookConverter(debug=True).debug) + self.assertFalse(AudiobookConverter(backend=tts.BACKEND_QWEN).debug) + self.assertTrue(AudiobookConverter(debug=True, backend=tts.BACKEND_QWEN).debug) class SetupLoggingTests(unittest.TestCase): @@ -496,14 +496,14 @@ class PreflightOverwritesTests(unittest.TestCase): (converter_mod.BOOKS_FOLDER / "book.txt").unlink() with patch("builtins.input", side_effect=AssertionError("should not prompt")): book_files, planned = AudiobookConverter.preflight_overwrites( - tts.BACKEND_GRADIO, None, tts.VOICE_MODE_CUSTOM, None, "mp3") + tts.BACKEND_QWEN, None, tts.VOICE_MODE_CUSTOM, None, "mp3") self.assertEqual(book_files, []) self.assertEqual(planned, []) def test_new_book_planned_without_prompt(self): with patch("builtins.input", side_effect=AssertionError("should not prompt")): book_files, planned = AudiobookConverter.preflight_overwrites( - tts.BACKEND_GRADIO, None, tts.VOICE_MODE_CUSTOM, None, "mp3") + tts.BACKEND_QWEN, None, tts.VOICE_MODE_CUSTOM, None, "mp3") self.assertEqual(len(book_files), 1) self.assertEqual(planned, [(book_files[0], "book_Vivian")]) @@ -511,14 +511,14 @@ class PreflightOverwritesTests(unittest.TestCase): (converter_mod.AUDIOBOOKS_FOLDER / "book_Vivian.mp3").write_bytes(b"existing") with patch("builtins.input", return_value=""): book_files, planned = AudiobookConverter.preflight_overwrites( - tts.BACKEND_GRADIO, None, tts.VOICE_MODE_CUSTOM, None, "mp3") + tts.BACKEND_QWEN, None, tts.VOICE_MODE_CUSTOM, None, "mp3") self.assertEqual(planned, [(book_files[0], "book_Vivian")]) def test_existing_output_declined_is_skipped(self): (converter_mod.AUDIOBOOKS_FOLDER / "book_Vivian.mp3").write_bytes(b"existing") with patch("builtins.input", return_value="n"): book_files, planned = AudiobookConverter.preflight_overwrites( - tts.BACKEND_GRADIO, None, tts.VOICE_MODE_CUSTOM, None, "mp3") + tts.BACKEND_QWEN, None, tts.VOICE_MODE_CUSTOM, None, "mp3") self.assertEqual(len(book_files), 1) self.assertEqual(planned, []) @@ -536,7 +536,7 @@ class RunOverwritePromptTests(unittest.TestCase): self.converter = AudiobookConverter.__new__(AudiobookConverter) self.converter.voice_mode = tts.VOICE_MODE_CUSTOM self.converter.voice_clone_ref_audio = None - self.converter.backend = tts.BACKEND_GRADIO + self.converter.backend = tts.BACKEND_QWEN self.converter.voice = None self.converter.speed = 1.0 self.converter.single_file = False diff --git a/tests/test_tts.py b/tests/test_tts.py index bebbaf6..89248f2 100644 --- a/tests/test_tts.py +++ b/tests/test_tts.py @@ -1142,19 +1142,21 @@ class BackendWiringTests(unittest.TestCase): voice="narrator", language=config.LANGUAGE, chunk_text=False, model_id="higgs") - def test_gradio_backend_uses_qwen_client(self): + def test_qwen_backend_uses_qwen_client(self): with patch("converter.converter.FasterTTSClient") as mock_faster, \ patch("converter.converter.QwenTTSClient") as mock_qwen, \ patch("converter.converter.AudioCppTTSClient") as mock_audiocpp: - AudiobookConverter(voice_mode=tts.VOICE_MODE_CUSTOM) + AudiobookConverter(voice_mode=tts.VOICE_MODE_CUSTOM, + backend=tts.BACKEND_QWEN) mock_qwen.assert_called_once() mock_faster.assert_not_called() mock_audiocpp.assert_not_called() - def test_gradio_clone_mode_still_requires_reference(self): + def test_qwen_clone_mode_still_requires_reference(self): with patch("converter.converter.QwenTTSClient"): with self.assertRaises(ValueError): - AudiobookConverter(voice_mode=tts.VOICE_MODE_CLONE) + AudiobookConverter(voice_mode=tts.VOICE_MODE_CLONE, + backend=tts.BACKEND_QWEN) def test_audiocpp_clone_mode_does_not_require_reference(self): # Cloning is server-side for the audiocpp backend, so the @@ -1182,9 +1184,10 @@ class BackendWiringTests(unittest.TestCase): self.assertGreater(len(chunks), 1) self.assertTrue(all(len(chunk.split()) <= 10 for chunk in chunks)) - def test_chapter_chunks_gradio_always_splits(self): + def test_chapter_chunks_qwen_always_splits(self): with patch("converter.converter.QwenTTSClient"): - converter = AudiobookConverter(voice_mode=tts.VOICE_MODE_CUSTOM) + converter = AudiobookConverter(voice_mode=tts.VOICE_MODE_CUSTOM, + backend=tts.BACKEND_QWEN) text = " ".join(f"word{i}" for i in range(50)) with patch.object(config, "CHUNK_SIZE", 10): chunks = converter._chapter_chunks(text) @@ -1257,7 +1260,8 @@ class BackendWiringTests(unittest.TestCase): ref.write_bytes(b"x") with patch("converter.converter.QwenTTSClient"): converter = AudiobookConverter(voice_mode=tts.VOICE_MODE_CLONE, - voice_clone_ref_audio=str(ref)) + voice_clone_ref_audio=str(ref), + backend=tts.BACKEND_QWEN) self.assertEqual(converter._narrator_tag(), "ref") |
