aboutsummaryrefslogtreecommitdiff
path: root/converter/tts.py
diff options
context:
space:
mode:
Diffstat (limited to 'converter/tts.py')
-rw-r--r--converter/tts.py16
1 files changed, 12 insertions, 4 deletions
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(