aboutsummaryrefslogtreecommitdiff
path: root/tests/test_tts.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_tts.py')
-rw-r--r--tests/test_tts.py27
1 files changed, 15 insertions, 12 deletions
diff --git a/tests/test_tts.py b/tests/test_tts.py
index 813332d..f2dda0e 100644
--- a/tests/test_tts.py
+++ b/tests/test_tts.py
@@ -296,23 +296,23 @@ class FasterTTSClientGenerateTests(unittest.TestCase):
sentences = [" ".join(f"word{i}" for i in range(6)) + "." for _ in range(3)]
text = " ".join(sentences)
pcm_parts = [b"\x01\x00" * 10, b"\x02\x00" * 20, b"\x03\x00" * 30]
- with patch.object(tts, "MAX_REQUEST_WORDS", 10), \
+ with patch.object(config, "CHUNK_SIZE", 10), \
patch.object(client, "_request_pcm", side_effect=pcm_parts) as mock_pcm:
result = client.generate_chunk(text, 1)
self.assertEqual(mock_pcm.call_count, 3)
_, _, _, frames = self._read_wav(Path(result))
self.assertEqual(frames, b"".join(pcm_parts))
- def test_subchunk_size_is_clamped_to_request_ceiling(self):
+ def test_subchunk_size_follows_config_chunk_size(self):
client = self._make_client()
text = " ".join(f"word{i}" for i in range(8))
pcm = b"\x01\x00" * 10
with patch.object(config, "CHUNK_SIZE", 4), \
patch.object(client, "_request_pcm", return_value=pcm) as mock_pcm:
result = client.generate_chunk(text, 1)
- # CHUNK_SIZE no longer drives request size: the hard ceiling
- # does, so the whole (8-word) text is one request here.
- self.assertEqual(mock_pcm.call_count, 1)
+ # The sub-chunk split follows config.CHUNK_SIZE, so the whole
+ # (8-word) text needs two 4-word requests here.
+ self.assertEqual(mock_pcm.call_count, 2)
self.assertIsNotNone(result)
def test_stale_chunk_files_are_removed(self):
@@ -489,7 +489,7 @@ class QwenTTSClientGenerateTests(unittest.TestCase):
first = self._write_wav(Path(self._tmp.name) / "one.wav", b"\x01\x00" * 10)
second = self._write_wav(Path(self._tmp.name) / "two.wav", b"\x02\x00" * 20)
text = " ".join(f"word{i}" for i in range(12))
- with patch.object(tts, "MAX_REQUEST_WORDS", 5), \
+ with patch.object(config, "CHUNK_SIZE", 5), \
patch.object(client, "_generate_custom_voice",
side_effect=[(str(first),), (str(second),),
(str(first),)]) as mock_generate:
@@ -627,26 +627,29 @@ class AudioCppTTSClientHealthTests(unittest.TestCase):
self.assertGreaterEqual(client._seed, 0)
def test_preset_mode_routes_to_clone_model_when_configured(self):
- with patch.object(config, "AUDIOCPP_CLONE_MODEL_ID", "qwen3-tts-clone"):
+ with patch.object(config, "AUDIOCPP_MODEL_ID", "qwen3-tts"), \
+ patch.object(config, "AUDIOCPP_CLONE_MODEL_ID", "qwen3-tts-clone"):
client = self._client(
voice="narrator",
models={"data": [{"id": "qwen3-tts"}, {"id": "qwen3-tts-clone"}]})
self.assertEqual(client.model_id, "qwen3-tts-clone")
def test_preset_mode_falls_back_when_clone_model_not_on_server(self):
- with patch.object(config, "AUDIOCPP_CLONE_MODEL_ID", "qwen3-tts-clone"), \
+ with patch.object(config, "AUDIOCPP_MODEL_ID", "qwen3-tts"), \
+ patch.object(config, "AUDIOCPP_CLONE_MODEL_ID", "qwen3-tts-clone"), \
self.assertLogs("converter.tts", level="WARNING") as logs:
client = self._client(
voice="narrator",
models={"data": [{"id": "qwen3-tts"}, {"id": "pocket-tts"}]})
- self.assertEqual(client.model_id, config.AUDIOCPP_MODEL_ID)
+ self.assertEqual(client.model_id, "qwen3-tts")
self.assertTrue(any("qwen3-tts-clone" in line for line in logs.output))
def test_clone_model_id_ignored_for_speaker_mode(self):
- with patch.object(config, "AUDIOCPP_CLONE_MODEL_ID", "qwen3-tts-clone"):
+ with patch.object(config, "AUDIOCPP_MODEL_ID", "qwen3-tts"), \
+ patch.object(config, "AUDIOCPP_CLONE_MODEL_ID", "qwen3-tts-clone"):
client = self._client(
models={"data": [{"id": "qwen3-tts"}, {"id": "qwen3-tts-clone"}]})
- self.assertEqual(client.model_id, config.AUDIOCPP_MODEL_ID)
+ self.assertEqual(client.model_id, "qwen3-tts")
def test_clone_model_id_equal_to_primary_is_noop(self):
with patch.object(config, "AUDIOCPP_CLONE_MODEL_ID",
@@ -787,7 +790,7 @@ class AudioCppTTSClientRequestTests(unittest.TestCase):
parts = [self._wav_bytes(b"\x01\x00" * 10),
self._wav_bytes(b"\x02\x00" * 20),
self._wav_bytes(b"\x03\x00" * 30)]
- with patch.object(tts, "MAX_REQUEST_WORDS", 10), \
+ with patch.object(config, "CHUNK_SIZE", 10), \
patch.object(client, "_request_wav", side_effect=parts) as mock_request:
result = client.generate_chunk(text, 1)
self.assertEqual(mock_request.call_count, 3)