diff options
| author | historia <historiavg@proton.me> | 2026-08-19 03:32:06 -0400 |
|---|---|---|
| committer | historia <historiavg@proton.me> | 2026-08-19 03:32:06 -0400 |
| commit | f1f8e899c46de80d7f9fbb8f0b53983e18167bd2 (patch) | |
| tree | f871476a9b0288bded9d3757d6c39e2061967534 /converter/tts.py | |
| parent | 24cb17a35ebaf5829cefa943c5a528d4accd7dfc (diff) | |
| download | tts-audiobook-generator-f1f8e899c46de80d7f9fbb8f0b53983e18167bd2.tar.gz | |
fix: reduce excessive logging
Diffstat (limited to 'converter/tts.py')
| -rw-r--r-- | converter/tts.py | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/converter/tts.py b/converter/tts.py index 1f5606f..07cfa65 100644 --- a/converter/tts.py +++ b/converter/tts.py @@ -222,26 +222,36 @@ class QwenTTSClient(_BaseTTSClient): print(f"[OK] Reference text:\n{self.voice_clone_ref_text}") def _init_client(self, url: str, clone: bool = False) -> None: - """Initialize a Gradio client and store its API metadata.""" + """Initialize a Gradio client and store its API metadata. + + gradio_client prints its usage info directly to stdout while the + client is created and its API metadata loaded, so stdout is swapped + for a buffer for the whole process; the captured text is re-emitted + at DEBUG level for troubleshooting. + """ from gradio_client import Client logger.info("Connecting to Qwen API at %s...", url) old_stdout = sys.stdout - sys.stdout = io.TextIOWrapper(io.BytesIO(), encoding="utf-8", errors="replace") + captured = io.StringIO() + sys.stdout = captured try: try: client = Client(url, httpx_kwargs={"timeout": config.API_TIMEOUT}) except TypeError: # Older gradio_client versions don't support httpx_kwargs. client = Client(url) + if clone: + self.clone_client = client + self.clone_api_info = self._load_api_info(client) + else: + self.client = client + self.api_info = self._load_api_info(client) finally: sys.stdout = old_stdout - if clone: - self.clone_client = client - self.clone_api_info = self._load_api_info(client) - else: - self.client = client - self.api_info = self._load_api_info(client) + usage_info = captured.getvalue().strip() + if usage_info: + logger.debug("Gradio client output for %s:\n%s", url, usage_info) logger.info("Connected to Qwen API") @staticmethod |
