aboutsummaryrefslogtreecommitdiff
path: root/app/tests
diff options
context:
space:
mode:
authorhistoria <historiavg@proton.me>2026-08-24 13:50:50 -0400
committerhistoria <historiavg@proton.me>2026-08-24 13:50:50 -0400
commitdff790664389d60d16729092a58d9c0dc490a953 (patch)
tree7c29996d78b0c1ae82fa9c4dc71ed39bb70d180e /app/tests
parentaac8febbdb45b7994e209bc74a44f8fc98fc745d (diff)
downloadtts-audiobook-generator-dff790664389d60d16729092a58d9c0dc490a953.tar.gz
remove: --chunk flag (always force client-side chunking)
Diffstat (limited to 'app/tests')
-rw-r--r--app/tests/test_converter.py49
-rw-r--r--app/tests/test_hub.py4
-rw-r--r--app/tests/test_tts.py80
3 files changed, 24 insertions, 109 deletions
diff --git a/app/tests/test_converter.py b/app/tests/test_converter.py
index 2fe0f5d..9b0ddb4 100644
--- a/app/tests/test_converter.py
+++ b/app/tests/test_converter.py
@@ -226,7 +226,6 @@ class DebugDumpTests(unittest.TestCase):
self._debug_folder.start()
self.debug_root = Path(self._tmp.name)
self.converter = AudiobookConverter.__new__(AudiobookConverter)
- self.converter.client_chunks = True
self.converter.tts = MagicMock()
def tearDown(self):
@@ -383,7 +382,6 @@ class SynthesizeChunkLoggingTests(unittest.TestCase):
def setUp(self):
self.converter = AudiobookConverter.__new__(AudiobookConverter)
- self.converter.client_chunks = True
self.converter.tts = MagicMock()
def test_failed_chunk_logs_single_error(self):
@@ -403,13 +401,11 @@ class SynthesizeChunkLoggingTests(unittest.TestCase):
self.assertIn("Chunk 1/1 error: boom", logs.output[0])
-class ServerSideChunkingOutputTests(unittest.TestCase):
- """With client-side chunking off (audiocpp default), the console skips
- the chunk vocabulary because the whole request is one server call."""
+class ChunkProgressOutputTests(unittest.TestCase):
+ """The console reports chunk progress while a conversion runs."""
- def _converter(self, client_chunks: bool):
+ def _converter(self):
converter = AudiobookConverter.__new__(AudiobookConverter)
- converter.client_chunks = client_chunks
converter.backend = tts.BACKEND_AUDIOCPP
converter.speed = 1.0
converter.output_format = "mp3"
@@ -417,49 +413,20 @@ class ServerSideChunkingOutputTests(unittest.TestCase):
converter.tts.process_chunk_with_retry.return_value = "chunk.wav"
return converter
- def test_client_chunking_prints_chunk_progress(self):
+ def test_prints_chunk_progress(self):
buf = io.StringIO()
with redirect_stdout(buf):
- self._converter(client_chunks=True)._synthesize_chunks(["Hello."])
+ self._converter()._synthesize_chunks(["Hello."])
out = buf.getvalue()
self.assertIn("PROCESSING 1 CHUNKS", out)
self.assertIn("Chunk 1/1 completed", out)
self.assertIn("Successful: 1/1", out)
- def test_server_side_chunking_suppresses_chunk_output(self):
- buf = io.StringIO()
- with redirect_stdout(buf):
- self._converter(client_chunks=False)._synthesize_chunks(["Hello."])
- self.assertEqual(buf.getvalue(), "")
-
- def test_server_side_chunking_suppresses_chapter_chunk_suffix(self):
- buf = io.StringIO()
- with patch.object(converter_mod.audio, "combine_chunks", return_value=True), \
- redirect_stdout(buf):
- ok = self._converter(client_chunks=False)._convert_text(
- "Hello world.", Path("out.mp3"), time.time(), chapter=(2, 5))
- self.assertTrue(ok)
- out = buf.getvalue()
- self.assertIn("Chapter 2/5 converted", out)
- self.assertNotIn("chunk", out.lower())
-
- def test_single_request_run_notes_long_wait(self):
- buf = io.StringIO()
- with patch.object(converter_mod.audio, "combine_chunks", return_value=True), \
- redirect_stdout(buf):
- ok = self._converter(client_chunks=False)._convert_text(
- "Hello world.", Path("out.mp3"), time.time(), chapter=(2, 5))
- self.assertTrue(ok)
- out = buf.getvalue()
- self.assertIn("Sending the chapter 2/5 to the audio.cpp server as a "
- "single request", out)
- self.assertIn("expected for this to take a very long time", out)
-
- def test_client_chunking_run_keeps_chunk_phrasing(self):
+ def test_run_keeps_chunk_phrasing(self):
buf = io.StringIO()
with patch.object(converter_mod.audio, "combine_chunks", return_value=True), \
redirect_stdout(buf):
- ok = self._converter(client_chunks=True)._convert_text(
+ ok = self._converter()._convert_text(
"Hello world.", Path("out.mp3"), time.time(), chapter=(2, 5))
self.assertTrue(ok)
out = buf.getvalue()
@@ -468,7 +435,7 @@ class ServerSideChunkingOutputTests(unittest.TestCase):
self.assertIn("Chapter 2/5 converted (1/1 chunks)", out)
def test_partial_chunks_abort_without_assembling(self):
- converter = self._converter(client_chunks=True)
+ converter = self._converter()
converter.tts.process_chunk_with_retry.side_effect = ["chunk_0001.wav", None]
text = " ".join(f"word{i}" for i in range(8))
with patch.object(config, "CHUNK_SIZE", 5), \
diff --git a/app/tests/test_hub.py b/app/tests/test_hub.py
index 2fe0b2f..1b7630e 100644
--- a/app/tests/test_hub.py
+++ b/app/tests/test_hub.py
@@ -429,8 +429,8 @@ class ConvertFlowTests(unittest.TestCase):
self.addCleanup(patcher.stop)
def _answer_common_options(self):
- # Output format, speed, single-file, chunk, debug.
- self.tui.script += ["m4b", "1.5", False, False, False]
+ # Output format, speed, single-file, debug.
+ self.tui.script += ["m4b", "1.5", False, False]
# ------------------------------------------------------------------
# audio.cpp: remote server (no local checkout / server.json)
diff --git a/app/tests/test_tts.py b/app/tests/test_tts.py
index a2df07f..87f98df 100644
--- a/app/tests/test_tts.py
+++ b/app/tests/test_tts.py
@@ -906,7 +906,7 @@ class AudioCppTTSClientRequestTests(unittest.TestCase):
@staticmethod
def _make_client(preset_mode=False, voice="Vivian", language="English", seed=-1,
- chunk_text=True, family="qwen3_tts", task="tts",
+ family="qwen3_tts", task="tts",
instructions=None, request_options=None):
client = AudioCppTTSClient.__new__(AudioCppTTSClient)
client.api_url = "http://127.0.0.1:8080"
@@ -915,7 +915,6 @@ class AudioCppTTSClientRequestTests(unittest.TestCase):
client.voice = voice
client.language = language
client._seed = seed
- client.chunk_text = chunk_text
client.family = family
client.task = task
client.profile = tts.AUDIOCPP_FAMILY_PROFILES.get(
@@ -972,30 +971,8 @@ class AudioCppTTSClientRequestTests(unittest.TestCase):
payload = json.loads(mock_urlopen.call_args[0][0].data.decode("utf-8"))
self.assertNotIn("seed", payload)
- def test_whole_text_sent_as_one_request_without_client_chunking(self):
- client = self._make_client(chunk_text=False)
- # 9 words with CHUNK_SIZE=5 would split in two if client chunking
- # were on.
- text = " ".join(f"word{i}" for i in range(9))
- with patch.object(config, "CHUNK_SIZE", 5), \
- patch.object(client, "_request_wav",
- return_value=self._wav_bytes()) as mock_request:
- result = client.generate_chunk(text, 1)
- self.assertIsNotNone(result)
- self.assertEqual(mock_request.call_count, 1)
- self.assertEqual(mock_request.call_args[0][0], text)
-
- def test_single_request_timeout_scales_with_text_length(self):
- client = self._make_client(chunk_text=False)
- long_text = " ".join(f"word{i}" for i in range(1500)) # ~10 min of audio
- with patch("converter.tts.urllib.request.urlopen",
- return_value=self._post_response(self._wav_bytes())) as mock_urlopen:
- client._request_wav(long_text)
- timeout = mock_urlopen.call_args[1]["timeout"]
- self.assertGreater(timeout, config.API_TIMEOUT)
-
- def test_client_chunking_keeps_configured_timeout(self):
- client = self._make_client(chunk_text=True)
+ def test_request_timeout_is_the_configured_api_timeout(self):
+ client = self._make_client()
long_text = " ".join(f"word{i}" for i in range(1500))
with patch("converter.tts.urllib.request.urlopen",
return_value=self._post_response(self._wav_bytes())) as mock_urlopen:
@@ -1208,8 +1185,7 @@ class AudioCppTTSClientRequestTests(unittest.TestCase):
class AudioCppHeartbeatTests(unittest.TestCase):
- """The heartbeat label drops 'Chunk' when the server does its own
- long-form chunking (chunk_text=False, the default)."""
+ """The heartbeat reports chunk progress while a request generates."""
def setUp(self):
self._tmp = tempfile.TemporaryDirectory()
@@ -1221,7 +1197,7 @@ class AudioCppHeartbeatTests(unittest.TestCase):
self._tmp.cleanup()
@staticmethod
- def _client(chunk_text):
+ def _client():
client = AudioCppTTSClient.__new__(AudioCppTTSClient)
client.api_url = "http://127.0.0.1:8080"
client.model_id = config.AUDIOCPP_MODEL_ID
@@ -1229,7 +1205,6 @@ class AudioCppHeartbeatTests(unittest.TestCase):
client.voice = "Vivian"
client.language = "English"
client._seed = -1
- client.chunk_text = chunk_text
client.family = "qwen3_tts"
client.profile = tts.AUDIOCPP_DEFAULT_FAMILY_PROFILE
return client
@@ -1244,8 +1219,8 @@ class AudioCppHeartbeatTests(unittest.TestCase):
wav_file.writeframes(b"\x01\x00" * 10)
return buffer.getvalue()
- def _run(self, chunk_text):
- client = self._client(chunk_text)
+ def _run(self):
+ client = self._client()
def slow_request(*_args, **_kwargs):
time.sleep(0.12)
@@ -1260,13 +1235,8 @@ class AudioCppHeartbeatTests(unittest.TestCase):
self.assertTrue(result)
return buf.getvalue()
- def test_server_side_chunking_heartbeat_has_no_chunk_word(self):
- out = self._run(chunk_text=False)
- self.assertIn("Request still generating", out)
- self.assertNotIn("Chunk", out)
-
- def test_client_side_chunking_heartbeat_keeps_chunk_word(self):
- out = self._run(chunk_text=True)
+ def test_heartbeat_reports_chunk_progress(self):
+ out = self._run()
self.assertIn("Chunk 1 still generating", out)
@@ -1290,7 +1260,6 @@ class AudioCppTTSClientTruncationTests(unittest.TestCase):
client.voice = "narrator"
client.language = "English"
client._seed = -1
- client.chunk_text = True
client.family = "qwen3_tts"
client.profile = tts.AUDIOCPP_FAMILY_PROFILES["qwen3_tts"]
return client
@@ -1336,7 +1305,7 @@ class BackendWiringTests(unittest.TestCase):
backend=tts.BACKEND_AUDIOCPP, voice="narrator",
language="ja")
mock_audiocpp.assert_called_once_with(voice="narrator", language="Japanese",
- chunk_text=False, model_id=None,
+ model_id=None,
instructions=None,
request_options={})
mock_faster.assert_not_called()
@@ -1347,22 +1316,10 @@ class BackendWiringTests(unittest.TestCase):
AudiobookConverter(voice_mode=tts.VOICE_MODE_CUSTOM,
backend=tts.BACKEND_AUDIOCPP)
mock_audiocpp.assert_called_once_with(voice=None, language=config.LANGUAGE,
- chunk_text=False, model_id=None,
+ model_id=None,
instructions=None,
request_options={})
- def test_audiocpp_backend_chunk_flag_forces_client_chunking(self):
- with patch("converter.converter.AudioCppTTSClient") as mock_audiocpp:
- converter = AudiobookConverter(voice_mode=tts.VOICE_MODE_CLONE,
- backend=tts.BACKEND_AUDIOCPP,
- voice="narrator", chunk=True)
- mock_audiocpp.assert_called_once_with(voice="narrator",
- language=config.LANGUAGE,
- chunk_text=True, model_id=None,
- instructions=None,
- request_options={})
- self.assertTrue(converter.client_chunks)
-
def test_audiocpp_backend_model_id_is_wired_through(self):
with patch("converter.converter.AudioCppTTSClient") as mock_audiocpp:
AudiobookConverter(voice_mode=tts.VOICE_MODE_CLONE,
@@ -1370,7 +1327,7 @@ class BackendWiringTests(unittest.TestCase):
model_id="higgs")
mock_audiocpp.assert_called_once_with(
voice="narrator", language=config.LANGUAGE,
- chunk_text=False, model_id="higgs", instructions=None,
+ model_id="higgs", instructions=None,
request_options={})
def test_audiocpp_backend_instructions_and_options_are_wired_through(self):
@@ -1382,7 +1339,7 @@ class BackendWiringTests(unittest.TestCase):
"speed": "1.1"})
mock_audiocpp.assert_called_once_with(
voice=None, language=config.LANGUAGE,
- chunk_text=False, model_id=None,
+ model_id=None,
instructions="A warm adult narrator",
request_options={"emotion": "neutral", "speed": "1.1"})
@@ -1411,19 +1368,10 @@ class BackendWiringTests(unittest.TestCase):
voice="narrator")
self.assertIsNone(converter.voice_clone_ref_audio)
- def test_chapter_chunks_audiocpp_default_is_one_request(self):
+ def test_chapter_chunks_audiocpp_splits(self):
converter = self._audiocpp_converter(voice="narrator")
text = " ".join(f"word{i}" for i in range(50))
with patch.object(config, "CHUNK_SIZE", 10):
- self.assertEqual(converter._chapter_chunks(text), [text])
-
- def test_chapter_chunks_audiocpp_chunk_flag_splits(self):
- with patch("converter.converter.AudioCppTTSClient"):
- converter = AudiobookConverter(voice_mode=tts.VOICE_MODE_CLONE,
- backend=tts.BACKEND_AUDIOCPP,
- voice="narrator", chunk=True)
- text = " ".join(f"word{i}" for i in range(50))
- with patch.object(config, "CHUNK_SIZE", 10):
chunks = converter._chapter_chunks(text)
self.assertGreater(len(chunks), 1)
self.assertTrue(all(len(chunk.split()) <= 10 for chunk in chunks))