From 1ff9a635bd9b033b631a6b525891b7eb44e189d3 Mon Sep 17 00:00:00 2001 From: historia Date: Mon, 24 Aug 2026 16:08:33 -0400 Subject: feat: clearer split between local (managed) and remote URLs and server status --- app/converter/tts.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'app/converter/tts.py') diff --git a/app/converter/tts.py b/app/converter/tts.py index a90dbbe..41e3aa5 100644 --- a/app/converter/tts.py +++ b/app/converter/tts.py @@ -348,7 +348,7 @@ class QwenTTSClient(_BaseTTSClient): def __init__(self, voice_mode: str = "custom_voice", voice_clone_ref_audio: Optional[str] = None, voice_clone_ref_text: Optional[str] = None, skip_transcription: bool = False, - language: Optional[str] = None): + language: Optional[str] = None, api_url: Optional[str] = None): if voice_mode not in VOICE_MODES: raise ValueError( f"Unknown voice mode: {voice_mode!r} (expected one of {VOICE_MODES})" @@ -357,6 +357,9 @@ class QwenTTSClient(_BaseTTSClient): self.voice_clone_ref_audio = voice_clone_ref_audio self.voice_clone_ref_text = (voice_clone_ref_text or "").strip() self.skip_transcription = skip_transcription + # api_url overrides the configured endpoint for the active voice mode + # (used by the hub's "[remote]" backend entries and --api-url). + self.api_url = (api_url or "").strip() or None # Seed sent with every request: config.SEED as-is, or (with # CONSTANT_SEED and SEED < 0) one random value drawn per run and # reused for every request so the voice stays consistent across @@ -379,16 +382,18 @@ class QwenTTSClient(_BaseTTSClient): # ------------------------------------------------------------------ def _connect(self) -> None: - api_url = config.CLONE_API_URL if self.voice_mode == VOICE_MODE_CLONE else config.QWEN_API_URL + api_url = self.api_url or ( + config.CLONE_API_URL if self.voice_mode == VOICE_MODE_CLONE + else config.QWEN_API_URL) try: if self.voice_mode == VOICE_MODE_CLONE: # Voice clone uses the Base-model demo, which is a separate server # from the CustomVoice demo (that one only exposes /run_instruct). - self._init_client(config.CLONE_API_URL, clone=True) - print(f"[OK] Connected to Voice Clone API at {config.CLONE_API_URL}") + self._init_client(api_url, clone=True) + print(f"[OK] Connected to Voice Clone API at {api_url}") self._resolve_reference_text() else: - self._init_client(config.QWEN_API_URL, clone=False) + self._init_client(api_url, clone=False) print("[OK] Connected to Qwen API") except Exception as exc: raise RuntimeError( -- cgit v1.2.3