diff options
| author | historia <historiavg@proton.me> | 2026-08-31 19:45:57 -0400 |
|---|---|---|
| committer | historia <historiavg@proton.me> | 2026-08-31 19:45:57 -0400 |
| commit | 10e72d4960e865acf5346ab8cf518ed5844fe45c (patch) | |
| tree | adf8c10386b9da6280c247f1fed137ef1a514157 /app/converter/clients | |
| parent | 4bd0282da65db9f118ef5250582ab67079fad538 (diff) | |
| download | tts-audiobook-generator-10e72d4960e865acf5346ab8cf518ed5844fe45c.tar.gz | |
feat: generate a book with all installed models to compare
Diffstat (limited to 'app/converter/clients')
| -rw-r--r-- | app/converter/clients/audiocpp.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/app/converter/clients/audiocpp.py b/app/converter/clients/audiocpp.py index a1888bc..df1884d 100644 --- a/app/converter/clients/audiocpp.py +++ b/app/converter/clients/audiocpp.py @@ -406,7 +406,8 @@ class AudioCppTTSClient(BaseTTSClient): model_id: Optional[str] = None, instructions: Optional[str] = None, request_options: Optional[Dict[str, str]] = None, - quiet: bool = False): + quiet: bool = False, + unload_models: Optional[bool] = None): super().__init__(chunks_dir, quiet=quiet) self.api_url = (api_url or config.AUDIOCPP_API_URL).rstrip("/") # Per-run model selection: the --model CLI flag (or the Generate @@ -415,6 +416,12 @@ class AudioCppTTSClient(BaseTTSClient): # don't require --model. self.model_id = (model_id or "").strip() self._model_id_explicit = bool(self.model_id) + # Unload previously-loaded server models at connect time: None + # follows the AUDIOCPP_UNLOAD_MODELS setting (read at connect, so + # a Settings change this session is honored); True/False force it + # regardless of the setting ("All (multiple generation)" runs pass + # True so each per-model conversion starts with a clean VRAM). + self._unload_models_override = unload_models # Validate before connecting so bad values fail fast without a server. self.language = normalize_language( language if language is not None else config.LANGUAGE) @@ -570,7 +577,10 @@ class AudioCppTTSClient(BaseTTSClient): self._report(f"[INFO] Sending instruction with every request: {self.instructions}") self._report("[INFO] Its effect (style, emotion, delivery) depends on the " "model family; models without instruction support ignore it.") - if config.AUDIOCPP_UNLOAD_MODELS: + unload = (config.AUDIOCPP_UNLOAD_MODELS + if self._unload_models_override is None + else self._unload_models_override) + if unload: self._unload_server_models() def _require_synthesis_task(self, models: List[Dict[str, str]]) -> None: @@ -595,7 +605,8 @@ class AudioCppTTSClient(BaseTTSClient): on its first request. Failures only warn: an older server without the endpoint, or a busy one, must not block a working setup. Controlled by config.AUDIOCPP_UNLOAD_MODELS (the TUI Settings - "Unload models" option). + "Unload models" option), or forced per run via the unload_models + override ("All (multiple generation)" runs unload between models). """ request = urllib.request.Request( f"{self.api_url}/v1/tasks/unload_all_models", data=b"", |
