aboutsummaryrefslogtreecommitdiff
path: root/converter/tts.py
diff options
context:
space:
mode:
Diffstat (limited to 'converter/tts.py')
-rw-r--r--converter/tts.py26
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