diff options
| author | historia <historiavg@proton.me> | 2026-08-20 23:50:37 -0400 |
|---|---|---|
| committer | historia <historiavg@proton.me> | 2026-08-20 23:50:37 -0400 |
| commit | 38c8fdcba7ce54ad0ad76be9ef0748df1c55ebc1 (patch) | |
| tree | 911e031ee0e4b902fcd3954df3838a920416e8a3 /converter/tts.py | |
| parent | 5c3df0a434059bd0d541bda35a51e49e3c44dd55 (diff) | |
| download | tts-audiobook-generator-38c8fdcba7ce54ad0ad76be9ef0748df1c55ebc1.tar.gz | |
feat: make_audiocpp_server_json.py takes an argument. remove chunk wording with audiocpp backend.
Diffstat (limited to 'converter/tts.py')
| -rw-r--r-- | converter/tts.py | 16 |
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( |
