Spaces:
Build error
Build error
积极的屁孩 commited on
Commit ·
677c37b
1
Parent(s): cdb0e04
delete setlangfilters and getlangfilters
Browse files
app.py
CHANGED
|
@@ -7,6 +7,39 @@ import torchaudio
|
|
| 7 |
import numpy as np
|
| 8 |
from huggingface_hub import snapshot_download, hf_hub_download
|
| 9 |
import subprocess
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
# 克隆Amphion仓库
|
| 12 |
if not os.path.exists("Amphion"):
|
|
|
|
| 7 |
import numpy as np
|
| 8 |
from huggingface_hub import snapshot_download, hf_hub_download
|
| 9 |
import subprocess
|
| 10 |
+
import re
|
| 11 |
+
|
| 12 |
+
# 修复LangSegment包导入问题
|
| 13 |
+
def fix_langsegment_imports():
|
| 14 |
+
try:
|
| 15 |
+
import LangSegment
|
| 16 |
+
langsegment_init_path = os.path.join(os.path.dirname(LangSegment.__file__), '__init__.py')
|
| 17 |
+
|
| 18 |
+
if os.path.exists(langsegment_init_path):
|
| 19 |
+
with open(langsegment_init_path, 'r') as f:
|
| 20 |
+
content = f.read()
|
| 21 |
+
|
| 22 |
+
# 检查是否存在已废弃的导入
|
| 23 |
+
if 'setLangfilters' in content or 'getLangfilters' in content:
|
| 24 |
+
print("正在修复LangSegment包中的导入问题...")
|
| 25 |
+
# 替换导入语句,删除setLangfilters和getLangfilters
|
| 26 |
+
fixed_content = re.sub(
|
| 27 |
+
r'from \.LangSegment import LangSegment,([^,]*),setLangfilters,getLangfilters',
|
| 28 |
+
r'from .LangSegment import LangSegment,\1',
|
| 29 |
+
content
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
# 写回文件
|
| 33 |
+
with open(langsegment_init_path, 'w') as f:
|
| 34 |
+
f.write(fixed_content)
|
| 35 |
+
print("LangSegment包导入修复完成")
|
| 36 |
+
else:
|
| 37 |
+
print("LangSegment包无需修复")
|
| 38 |
+
except Exception as e:
|
| 39 |
+
print(f"修复LangSegment包时出错: {e}")
|
| 40 |
+
|
| 41 |
+
# 在导入其他模块之前执行修复
|
| 42 |
+
fix_langsegment_imports()
|
| 43 |
|
| 44 |
# 克隆Amphion仓库
|
| 45 |
if not os.path.exists("Amphion"):
|