Spaces:
Running
on
Zero
Running
on
Zero
Add example audio
Browse files- .gitattributes +3 -1
- app.py +10 -32
.gitattributes
CHANGED
|
@@ -33,4 +33,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*.png filter=lfs diff=lfs merge=lfs -text
|
| 36 |
-
*.zst filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*.png filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
*.mp3 filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
*.wav filter=lfs diff=lfs merge=lfs -text
|
app.py
CHANGED
|
@@ -1,39 +1,22 @@
|
|
| 1 |
-
# import os
|
| 2 |
-
# import sys
|
| 3 |
-
|
| 4 |
-
# os.chdir(os.path.join("src", "SongFormer"))
|
| 5 |
-
# sys.path.append(os.path.join("..", "third_party"))
|
| 6 |
-
# sys.path.append(".")
|
| 7 |
-
|
| 8 |
import os
|
| 9 |
import sys
|
| 10 |
-
|
| 11 |
current_file = os.path.abspath(__file__)
|
| 12 |
current_dir = os.path.dirname(current_file)
|
| 13 |
-
|
| 14 |
-
print(f"[INFO] 正在运行脚本:{script_name}")
|
| 15 |
-
print(f"[INFO] 当前文件所在目录为:{current_dir}")
|
| 16 |
-
# 设置工作目录为 `src/SongFormer`(如果该路径存在)
|
| 17 |
songformer_path = os.path.join(current_dir, "src", "SongFormer")
|
| 18 |
if os.path.exists(songformer_path):
|
| 19 |
os.chdir(songformer_path)
|
| 20 |
-
print(f"[INFO] 工作目录已修改为:{songformer_path}")
|
| 21 |
else:
|
| 22 |
-
print(f"
|
| 23 |
-
|
| 24 |
working_dir = os.getcwd()
|
| 25 |
-
|
| 26 |
-
# 添加第三方库路径到 sys.path(third_party)
|
| 27 |
third_party_path = os.path.join(current_dir, "src", "third_party")
|
| 28 |
if os.path.exists(third_party_path):
|
| 29 |
sys.path.insert(0, third_party_path)
|
| 30 |
-
print(f"[INFO] 已添加第三方库路径到 sys.path:{third_party_path}")
|
| 31 |
-
else:
|
| 32 |
-
print(f"[WARNING] third_party 路径不存在:{third_party_path}")
|
| 33 |
-
# 添加当前工作目录到 sys.path(通常是 src/SongFormer)
|
| 34 |
sys.path.insert(0, working_dir)
|
| 35 |
-
|
| 36 |
-
# 尝试添加多个可能用于 musicfm 导入的路径
|
| 37 |
musicfm_paths = [
|
| 38 |
os.path.join(current_dir, "src"),
|
| 39 |
os.path.join(current_dir, "third_party"),
|
|
@@ -42,13 +25,6 @@ musicfm_paths = [
|
|
| 42 |
for path in musicfm_paths:
|
| 43 |
if os.path.exists(path):
|
| 44 |
sys.path.insert(0, path)
|
| 45 |
-
print(f"[INFO] 已添加路径到 sys.path:{path}")
|
| 46 |
-
else:
|
| 47 |
-
print(f"[DEBUG] 路径不存在,跳过添加:{path}")
|
| 48 |
-
# 可选:打印 sys.path 的当前状态
|
| 49 |
-
print("\n[DEBUG] 当前 sys.path 设置如下:")
|
| 50 |
-
for idx, p in enumerate(sys.path):
|
| 51 |
-
print(f" {idx}: {p}")
|
| 52 |
|
| 53 |
# monkey patch to fix issues in msaf
|
| 54 |
import scipy
|
|
@@ -547,8 +523,10 @@ with gr.Blocks(
|
|
| 547 |
gr.Examples(
|
| 548 |
examples=[
|
| 549 |
# Add your example audio file paths
|
| 550 |
-
|
| 551 |
-
|
|
|
|
|
|
|
| 552 |
],
|
| 553 |
inputs=[audio_input],
|
| 554 |
label="Click to load example",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
import sys
|
| 3 |
+
|
| 4 |
current_file = os.path.abspath(__file__)
|
| 5 |
current_dir = os.path.dirname(current_file)
|
| 6 |
+
|
|
|
|
|
|
|
|
|
|
| 7 |
songformer_path = os.path.join(current_dir, "src", "SongFormer")
|
| 8 |
if os.path.exists(songformer_path):
|
| 9 |
os.chdir(songformer_path)
|
|
|
|
| 10 |
else:
|
| 11 |
+
print(f"The target working directory does not exist: {songformer_path}")
|
| 12 |
+
|
| 13 |
working_dir = os.getcwd()
|
| 14 |
+
|
|
|
|
| 15 |
third_party_path = os.path.join(current_dir, "src", "third_party")
|
| 16 |
if os.path.exists(third_party_path):
|
| 17 |
sys.path.insert(0, third_party_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
sys.path.insert(0, working_dir)
|
| 19 |
+
|
|
|
|
| 20 |
musicfm_paths = [
|
| 21 |
os.path.join(current_dir, "src"),
|
| 22 |
os.path.join(current_dir, "third_party"),
|
|
|
|
| 25 |
for path in musicfm_paths:
|
| 26 |
if os.path.exists(path):
|
| 27 |
sys.path.insert(0, path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
# monkey patch to fix issues in msaf
|
| 30 |
import scipy
|
|
|
|
| 523 |
gr.Examples(
|
| 524 |
examples=[
|
| 525 |
# Add your example audio file paths
|
| 526 |
+
["examples/BC_5cd6a6.mp3"],
|
| 527 |
+
["examples/BC_282ece.mp3"],
|
| 528 |
+
["examples/BHX_0158_letitrock.wav"],
|
| 529 |
+
["examples/BHX_0374_drunkonyou.wav"],
|
| 530 |
],
|
| 531 |
inputs=[audio_input],
|
| 532 |
label="Click to load example",
|