This repository has been archived on 2026-08-12. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Cyrene/scripts/voice/speechbrain_fix.py
T
AskaEth 41f653b672 refactor: QQ → OBv11 重命名 + 平台格式统一抽象
- 所有对外称呼从 QQ 改为 OBv11(注释/提示词/日志/配置项)
- 新增 PlatformFormat 结构体,统一管理平台消息标记格式
- defaultPlatformFormats() 注册表替代硬编码 qqTargetRe
- extractProactiveMessage 改为 Thinker 方法,遍历格式注册表匹配
- 配置项重命名: QQ_BOT_PORT → OBV11_BOT_PORT, QQBotPort → OBv11BotPort
- 标记格式: 【QQ群聊】→【OBv11群聊】、【QQ私聊】→【OBv11私聊】

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-22 20:48:07 +08:00

22 lines
864 B
Python

"""
Python 3.8 兼容性补丁: 修复 speechbrain 中的 list[int] 语法。
在导入 speechbrain 之前 import 本模块即可。
"""
import speechbrain.dataio.sampler as _s
# Force evaluation of the module to catch the error
# The fix: monkey-patch before import completes
import sys
from speechbrain.dataio import sampler as _sampler_mod
# Patch the problematic line: replace Optional[list[int]] with Optional["List[int]"]
# This is done at the source level by editing the file
import os
_sp = os.path.join(os.path.dirname(_sampler_mod.__file__), "sampler.py")
if os.path.exists(_sp):
with open(_sp) as f:
src = f.read()
if "from __future__ import annotations" not in src:
with open(_sp, "w") as f:
f.write("from __future__ import annotations\n" + src)
print("[speechbrain_fix] patched sampler.py for Python 3.8")