mirror of
https://github.com/RVC-Boss/GPT-SoVITS.git
synced 2026-07-22 18:30:05 +08:00
fix(webui): 顶部注入仓库根到 sys.path, 兼容直接运行此脚本
问题: 直接运行 python GPT_SoVITS/inference_webui.py 时(非经 webui.py), sys.path 无仓库根, 导致 on_model_name_change 触发时 'from tools.list_metadata import parse_list_line' 报 ModuleNotFoundError。 修复: 顶部计算仓库根(dirname(dirname(__file__))) 并 insert 到 sys.path, 与 webui.py 启动方式行为一致。对经 webui.py 启动的场景无副作用(去重判断)。 实测: proplus 工作区直接启动, 选模型->40样本+emotion 正常, 无报错。
This commit is contained in:
parent
b7153dcae7
commit
8b3f7e3dd6
@ -11,6 +11,11 @@ from __future__ import annotations
|
||||
import psutil
|
||||
import os
|
||||
|
||||
# 确保仓库根在 sys.path, 使 from tools.xxx 可用 (兼容直接运行此脚本或经 webui.py 启动)
|
||||
_now_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
if _now_dir not in __import__('sys').path:
|
||||
__import__('sys').path.insert(0, _now_dir)
|
||||
|
||||
def set_high_priority():
|
||||
"""把当前 Python 进程设为 HIGH_PRIORITY_CLASS"""
|
||||
if os.name != "nt":
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user