aboutsummaryrefslogtreecommitdiff
path: root/audiobook.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 /audiobook.py
parentafd1c67d92c7f32389d5f652b9fa71530538a16f (diff)
downloadtts-audiobook-generator-1ff9a635bd9b033b631a6b525891b7eb44e189d3.tar.gz
feat: clearer split between local (managed) and remote URLs and server status
Diffstat (limited to 'audiobook.py')
-rwxr-xr-xaudiobook.py27
1 files changed, 24 insertions, 3 deletions
diff --git a/audiobook.py b/audiobook.py
index 1cc1085..7a9cbda 100755
--- a/audiobook.py
+++ b/audiobook.py
@@ -58,14 +58,16 @@ def convert(backend: str = None, voice: str = None, clone: str = None,
output_format: str = None, debug: bool = False,
model_id: str = None, instructions: str = None,
request_options: dict = None, input_dir: Path = None,
- output_dir: Path = None) -> int:
+ output_dir: Path = None, api_url: str = None) -> int:
"""Run one conversion pass with explicit options (used by the CLI and hub).
Returns the process exit code (0 on success, 1 on failure, 130 on
Ctrl-C). BACKEND defaults to config.BACKEND, OUTPUT_FORMAT to
config.AUDIO_FORMAT. LANGUAGE is already-normalized where required.
INPUT_DIR/OUTPUT_DIR override the default input/ and output/ folders
- when given.
+ when given. API_URL, when given, overrides the configured server URL
+ for the selected backend (used by the hub's "[remote]" entries and
+ --api-url).
"""
backend = backend or config.BACKEND
output_format = output_format or config.AUDIO_FORMAT
@@ -105,7 +107,7 @@ def convert(backend: str = None, voice: str = None, clone: str = None,
single_file=single_file, output_format=output_format,
language=language, backend=backend, voice=voice, debug=debug,
model_id=model_id, instructions=instructions,
- request_options=request_options,
+ request_options=request_options, api_url=api_url,
)
converter._book_files = book_files
converter._planned = planned
@@ -270,6 +272,14 @@ Examples:
"model. See the audio.cpp docs for the model's valid option "
"keys, e.g. --option emotion=neutral --option speed=1.1.")
)
+ parser.add_argument(
+ "--api-url", type=str, default=None, metavar="URL",
+ help=("URL of the TTS server to talk to, overriding the configured "
+ "endpoint for the selected backend. Accept a host:port "
+ "(e.g. 10.20.30.40:8080) or a full http(s):// URL. With "
+ "--backend qwen it overrides the endpoint for the active "
+ "voice mode (custom or clone).")
+ )
args = parser.parse_args()
@@ -346,6 +356,16 @@ Examples:
parser.error(f"--option expects KEY=VALUE (got {item!r})")
request_options[key.strip()] = value
+ api_url = None
+ if args.api_url is not None:
+ from backends import common as _common
+ try:
+ api_url = _common.normalize_remote_url(args.api_url)
+ except ValueError as exc:
+ parser.error(str(exc))
+ if not api_url:
+ parser.error("--api-url must not be empty")
+
sys.exit(convert(
backend=args.backend, voice=args.voice, clone=args.clone,
transcription=args.transcription, no_transcription=args.no_transcription,
@@ -354,6 +374,7 @@ Examples:
model_id=args.model, instructions=args.instructions,
request_options=request_options,
input_dir=args.input, output_dir=args.output,
+ api_url=api_url,
))