From 38c8fdcba7ce54ad0ad76be9ef0748df1c55ebc1 Mon Sep 17 00:00:00 2001 From: historia Date: Thu, 20 Aug 2026 23:50:37 -0400 Subject: feat: make_audiocpp_server_json.py takes an argument. remove chunk wording with audiocpp backend. --- converter/tts.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'converter/tts.py') diff --git a/converter/tts.py b/converter/tts.py index 1a41643..0d867a2 100644 --- a/converter/tts.py +++ b/converter/tts.py @@ -363,15 +363,21 @@ class _BaseTTSClient: return None @contextlib.contextmanager - def _chunk_heartbeat(self, chunk_num: int): - """Print a periodic "still working" message while a chunk generates.""" + def _chunk_heartbeat(self, chunk_num: int, label: Optional[str] = None): + """Print a periodic "still working" message while a request generates. + + ``label`` overrides the default "Chunk {chunk_num}" subject, for + backends that send one request per chapter without client-side + chunking (the audio.cpp default) where "chunk" would be misleading. + """ stop = threading.Event() + subject = label if label is not None else f"Chunk {chunk_num}" def _beat(): start = time.time() while not stop.wait(config.HEARTBEAT_INTERVAL_SECONDS): elapsed = time.time() - start - print(f"[...] Chunk {chunk_num} still generating — " + print(f"[...] {subject} still generating — " f"{int(elapsed // 60)}m {int(elapsed % 60)}s elapsed", flush=True) thread = threading.Thread(target=_beat, daemon=True) @@ -1170,7 +1176,9 @@ class AudioCppTTSClient(_BaseTTSClient): output_path: Optional[Path] = None with tempfile.TemporaryDirectory(prefix="tts_parts_") as parts_dir, \ - self._chunk_heartbeat(chunk_num): + self._chunk_heartbeat( + chunk_num, + label=None if self.chunk_text else "Request"): part_paths = [] for sub_num, sub_text in enumerate(sub_texts, 1): wav = self._request_wav_with_retry( -- cgit v1.2.3