mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-28 04:59:52 +01:00
fix: Windows 平台架构对应的目录
This commit is contained in:
parent
e13b93a308
commit
10c06e25e0
1 changed files with 9 additions and 18 deletions
|
|
@ -22,13 +22,13 @@ class PLATFORM(Enum):
|
||||||
|
|
||||||
|
|
||||||
class ARCH(Enum):
|
class ARCH(Enum):
|
||||||
WINDOWS = {"arm": "x64", "intel": "x64"}
|
WINDOWS = {"arm": "arm64", "intel": "x64"}
|
||||||
MACOS = {"arm": "arm64", "intel": "x64"}
|
MACOS = {"arm": "arm64", "intel": "x64"}
|
||||||
LINUX = {"arm": "arm64", "intel": "x64"}
|
LINUX = {"arm": "arm64", "intel": "x64"}
|
||||||
|
|
||||||
|
|
||||||
class LIB_PATH(Enum):
|
class LIB_PATH(Enum):
|
||||||
WINDOWS = "libs/win/x64"
|
WINDOWS = "libs/win/{arch}"
|
||||||
MACOS = "libs/mac/{arch}"
|
MACOS = "libs/mac/{arch}"
|
||||||
LINUX = "libs/linux/{arch}"
|
LINUX = "libs/linux/{arch}"
|
||||||
|
|
||||||
|
|
@ -92,16 +92,6 @@ def get_arch(system: PLATFORM) -> tuple[str, str]:
|
||||||
return architecture, arch_name
|
return architecture, arch_name
|
||||||
|
|
||||||
|
|
||||||
def get_lib_path(system: PLATFORM, arch_name: str) -> str:
|
|
||||||
"""根据平台架构获取 Opus 库文件路径"""
|
|
||||||
platform_dict = _get_platform_dict()
|
|
||||||
lib_path_value = platform_dict[system]["lib_path"].value
|
|
||||||
|
|
||||||
if isinstance(lib_path_value, str) and "{arch}" in lib_path_value:
|
|
||||||
return lib_path_value.format(arch=arch_name)
|
|
||||||
return lib_path_value
|
|
||||||
|
|
||||||
|
|
||||||
def get_lib_name(system: PLATFORM, local: bool = True) -> str | list[str]:
|
def get_lib_name(system: PLATFORM, local: bool = True) -> str | list[str]:
|
||||||
"""根据平台架构获取 Opus 库名称"""
|
"""根据平台架构获取 Opus 库名称"""
|
||||||
key = "name" if local else "system_name"
|
key = "name" if local else "system_name"
|
||||||
|
|
@ -184,9 +174,7 @@ def get_search_paths(system: PLATFORM, arch_name: str) -> list[tuple[str, str]]:
|
||||||
logger.debug(f"找到 libs 目录: {lib_path}")
|
logger.debug(f"找到 libs 目录: {lib_path}")
|
||||||
|
|
||||||
# 添加项目根目录作为最后的备选
|
# 添加项目根目录作为最后的备选
|
||||||
if not search_paths or str(Path(APP_DIR) / "libs") not in [
|
if not search_paths or APP_DIR not in [s[0] for s in search_paths]:
|
||||||
s[0] for s in search_paths
|
|
||||||
]:
|
|
||||||
search_paths.append((APP_DIR, lib_name))
|
search_paths.append((APP_DIR, lib_name))
|
||||||
|
|
||||||
# 调试日志:显示所有搜索路径
|
# 调试日志:显示所有搜索路径
|
||||||
|
|
@ -263,7 +251,8 @@ def _setup_dll_search_path(system: PLATFORM, lib_dir: str) -> None:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if hasattr(os, "add_dll_directory"):
|
if hasattr(os, "add_dll_directory"):
|
||||||
os.add_dll_directory(lib_dir)
|
dll_dir_handle = os.add_dll_directory(lib_dir)
|
||||||
|
setattr(sys, "_opus_dll_dir_handle", dll_dir_handle)
|
||||||
logger.debug(f"已添加DLL搜索路径: {lib_dir}")
|
logger.debug(f"已添加DLL搜索路径: {lib_dir}")
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
logger.warning(f"添加DLL搜索路径失败: {e}")
|
logger.warning(f"添加DLL搜索路径失败: {e}")
|
||||||
|
|
@ -337,8 +326,10 @@ def setup_opus() -> bool:
|
||||||
|
|
||||||
# 打补丁确保 opuslib_next 能找到正确的库路径
|
# 打补丁确保 opuslib_next 能找到正确的库路径
|
||||||
if final_lib_path:
|
if final_lib_path:
|
||||||
|
loaded = _load_opus_library(final_lib_path)
|
||||||
|
if loaded:
|
||||||
_patch_find_library("opus", final_lib_path)
|
_patch_find_library("opus", final_lib_path)
|
||||||
return _load_opus_library(final_lib_path)
|
return loaded
|
||||||
|
|
||||||
logger.error("无法加载 Opus 库")
|
logger.error("无法加载 Opus 库")
|
||||||
return False
|
return False
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue