关闭启动时FunASR联网检查
parent
9a81e6ea55
commit
1c0d3d145b
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
import logging
|
||||
import threading
|
||||
from typing import Any, Dict
|
||||
from funasr import AutoModel
|
||||
|
||||
from app.core.config import settings
|
||||
|
|
@ -31,6 +32,14 @@ _punc_realtime_model_lock = threading.Lock()
|
|||
_punc_realtime_inference_lock = threading.Lock() # 推理互斥锁,防止并发状态混乱
|
||||
|
||||
|
||||
def _auto_model_common_kwargs() -> Dict[str, Any]:
|
||||
"""Copy shared FunASR options and prevent callers from re-enabling update checks."""
|
||||
kwargs = dict(settings.FUNASR_AUTOMODEL_KWARGS)
|
||||
# Keep this explicit at each AutoModel boundary: startup must not wait on PyPI access.
|
||||
kwargs.pop("disable_update", None)
|
||||
return kwargs
|
||||
|
||||
|
||||
def _resolve_device(device: str) -> str:
|
||||
"""解析设备字符串,将 auto 转换为实际的设备"""
|
||||
from app.core.device import detect_device
|
||||
|
|
@ -56,8 +65,9 @@ def get_global_vad_model(device: str):
|
|||
_global_vad_model = AutoModel(
|
||||
model=resolved_vad_path,
|
||||
device=resolved_device,
|
||||
disable_update=True,
|
||||
speech_noise_thres=0.6, # VAD 语音噪声阈值(FunASR默认0.6,设为0.7稍微严格一些,分段更碎)
|
||||
**settings.FUNASR_AUTOMODEL_KWARGS,
|
||||
**_auto_model_common_kwargs(),
|
||||
)
|
||||
logger.info("全局语音活动检测(VAD)模型加载成功 (speech_noise_thres=0.6)")
|
||||
except Exception as e:
|
||||
|
|
@ -91,7 +101,8 @@ def get_global_punc_model(device: str):
|
|||
_global_punc_model = AutoModel(
|
||||
model=resolved_punc_path,
|
||||
device=resolved_device,
|
||||
**settings.FUNASR_AUTOMODEL_KWARGS,
|
||||
disable_update=True,
|
||||
**_auto_model_common_kwargs(),
|
||||
)
|
||||
logger.info("全局标点符号模型(离线)加载成功")
|
||||
except Exception as e:
|
||||
|
|
@ -125,7 +136,8 @@ def get_global_punc_realtime_model(device: str):
|
|||
_global_punc_realtime_model = AutoModel(
|
||||
model=resolved_punc_realtime_path,
|
||||
device=resolved_device,
|
||||
**settings.FUNASR_AUTOMODEL_KWARGS,
|
||||
disable_update=True,
|
||||
**_auto_model_common_kwargs(),
|
||||
)
|
||||
logger.info("全局标点符号模型(实时)加载成功")
|
||||
except Exception as e:
|
||||
|
|
|
|||
Loading…
Reference in New Issue