From 2a14b98cddc3f5b45b0a9829a41bb6be1ce8476b Mon Sep 17 00:00:00 2001 From: JamesWalker <73320775+TatsuhiroC@users.noreply.github.com> Date: Sun, 14 Sep 2025 23:08:24 +0800 Subject: [PATCH] Update webui.py offline mode the original webui.py cannot run without internet connection. Now, it could run offline, if we already run it once before with models in huggingface cache. --- webui.py | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/webui.py b/webui.py index cff9d94..6399f2e 100644 --- a/webui.py +++ b/webui.py @@ -14,12 +14,25 @@ from funasr import AutoModel -model = "iic/SenseVoiceSmall" -model = AutoModel(model=model, - vad_model="iic/speech_fsmn_vad_zh-cn-16k-common-pytorch", - vad_kwargs={"max_single_segment_time": 30000}, - trust_remote_code=True, - ) +try: + # Try to connect internet + model = AutoModel( + model="iic/SenseVoiceSmall", + vad_model="iic/speech_fsmn_vad_zh-cn-16k-common-pytorch", + vad_kwargs={"max_single_segment_time": 30000}, + trust_remote_code=True, + ) +except Exception: + # If it fails, use the model in cache + local_model = os.path.expanduser("~/.cache/modelscope/hub/models/iic/SenseVoiceSmall/") + local_vad = os.path.expanduser("~/.cache/modelscope/hub/models/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/") + model = AutoModel( + model=local_model, + vad_model=local_vad, + vad_kwargs={"max_single_segment_time": 30000}, + trust_remote_code=True, + disable_update=True, # Critical! Keep it offline + ) import re