From 6fb6da30043778ac913a0188a2e2b3bd56d8911a Mon Sep 17 00:00:00 2001 From: Bernhard Schrader Date: Mon, 26 Jan 2026 23:34:52 +0100 Subject: [PATCH] Add WebUI host and port options --- README.md | 4 ++++ soprano/webui.py | 26 +++++++++++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index c5c4b96..75ba207 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,10 @@ Start WebUI: ```bash soprano-webui # hosted on http://127.0.0.1:7860 by default ``` +> **Tip:** Use `--host` and `--port` to change the bind address, for example: +> ```bash +> soprano-webui --host 0.0.0.0 --port 8080 +> ``` > **Tip:** You can increase cache size and decoder batch size to increase inference speed at the cost of higher memory usage. For example: > ```bash > soprano-webui --cache-size 1000 --decoder-batch-size 4 diff --git a/soprano/webui.py b/soprano/webui.py index fcdef46..c55d33a 100644 --- a/soprano/webui.py +++ b/soprano/webui.py @@ -23,9 +23,13 @@ help='Backend to use for inference') parser.add_argument('--cache-size', '-c', type=int, default=100, help='Cache size in MB (for lmdeploy backend)') -parser.add_argument('--decoder-batch-size', '-bs', type=int, default=1, - help='Batch size when decoding audio') -args = parser.parse_args() +parser.add_argument('--decoder-batch-size', '-bs', type=int, default=1, + help='Batch size when decoding audio') +parser.add_argument('--host', default='127.0.0.1', + help='Host/IP to bind the WebUI server (default: 127.0.0.1)') +parser.add_argument('--port', type=int, default=None, + help='Port to bind the WebUI server (default: auto-select)') +args = parser.parse_args() # Initialize model print("Loading Soprano TTS model...") @@ -217,13 +221,13 @@ def find_free_port(start_port=7860, max_tries=100): continue raise OSError("Could not find a free port") -def main(): - # Start Gradio interface - port = find_free_port(7860) - print(f"Starting Gradio interface on port {port}") - demo.launch( - server_name="127.0.0.1", - server_port=port, +def main(): + # Start Gradio interface + port = args.port if args.port is not None else find_free_port(7860) + print(f"Starting Gradio interface on port {port}") + demo.launch( + server_name=args.host, + server_port=port, share=False, theme=gr.themes.Soft(primary_hue="green"), css=""" @@ -237,4 +241,4 @@ def main(): ) if __name__ == "__main__": - main() \ No newline at end of file + main()