From f1f8e899c46de80d7f9fbb8f0b53983e18167bd2 Mon Sep 17 00:00:00 2001 From: historia Date: Wed, 19 Aug 2026 03:32:06 -0400 Subject: fix: reduce excessive logging --- converter/tts.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'converter/tts.py') 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 -- cgit v1.2.3