aboutsummaryrefslogtreecommitdiff
path: root/app/converter/tts.py
diff options
context:
space:
mode:
authorhistoria <historiavg@proton.me>2026-08-24 16:08:33 -0400
committerhistoria <historiavg@proton.me>2026-08-24 16:08:33 -0400
commit1ff9a635bd9b033b631a6b525891b7eb44e189d3 (patch)
tree6dbcd7e682d516770be4c0724db793666c93dd5f /app/converter/tts.py
parentafd1c67d92c7f32389d5f652b9fa71530538a16f (diff)
downloadtts-audiobook-generator-1ff9a635bd9b033b631a6b525891b7eb44e189d3.tar.gz
feat: clearer split between local (managed) and remote URLs and server status
Diffstat (limited to 'app/converter/tts.py')
-rw-r--r--app/converter/tts.py15
1 files changed, 10 insertions, 5 deletions
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(