FACED commited on
Commit
56669f6
·
verified ·
1 Parent(s): 29aeb73

Upload folder using huggingface_hub

Browse files
Files changed (6) hide show
  1. .gitattributes +1 -0
  2. README.md +32 -13
  3. app.py +54 -0
  4. packages.txt +1 -0
  5. requirements.txt +8 -0
  6. test.mp3 +3 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ test.mp3 filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,13 +1,32 @@
1
- ---
2
- title: Suno
3
- emoji: 🏆
4
- colorFrom: gray
5
- colorTo: gray
6
- sdk: gradio
7
- sdk_version: 5.23.1
8
- app_file: app.py
9
- pinned: false
10
- license: apache-2.0
11
- ---
12
-
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Suno 音乐分离工具
2
+
3
+ 这是一个基于Facebook Research的Demucs v4 AI模型的音乐分离工具,可以将音乐分离为人声和伴奏两个部分。
4
+
5
+ ## 功能特点
6
+
7
+ - 支持多种音频格式(mp3、wav等)
8
+ - 高质量的人声和伴奏分离
9
+ - 简洁易用的界面
10
+ - 快速处理
11
+
12
+ ## 使用方法
13
+
14
+ 1. 上传您想要分离的音频文件
15
+ 2. 点击"提交"按钮
16
+ 3. 等待处理完成后,可以下载分离后的人声和伴奏
17
+
18
+ ## 技术说明
19
+
20
+ - 使用Facebook Research的[Demucs v4](https://github.com/facebookresearch/demucs) AI模型进行音频分离
21
+ - 基于Gradio构建用户界面
22
+ - 支持大多数常见音频格式
23
+
24
+ ## 示例文件
25
+
26
+ 应用中提供了一个测试音频文件,您可以直接使用它来测试分离效果。
27
+
28
+ ## 注意事项
29
+
30
+ - 分离质量取决于原始音频的质量和特性
31
+ - 处理时间取决于音频长度和服务器负载
32
+ - 大文件处理可能需要更长时间
app.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ from scipy.io.wavfile import write
4
+ import tempfile
5
+ import shutil
6
+
7
+ def inference(audio_file):
8
+ """处理上传的音频文件并分离人声和伴奏"""
9
+ # 创建输出目录
10
+ os.makedirs("out", exist_ok=True)
11
+
12
+ # 使用demucs分离音频
13
+ output_dir = "out"
14
+ os.system(f"python -m demucs.separate -n htdemucs --two-stems=vocals '{audio_file}' -o {output_dir}")
15
+
16
+ # 获取分离后的文件路径
17
+ base_name = os.path.basename(audio_file)
18
+ name_without_ext = os.path.splitext(base_name)[0]
19
+
20
+ vocals_path = os.path.join(output_dir, "htdemucs", name_without_ext, "vocals.wav")
21
+ no_vocals_path = os.path.join(output_dir, "htdemucs", name_without_ext, "no_vocals.wav")
22
+
23
+ return vocals_path, no_vocals_path
24
+
25
+ # 创建API接口
26
+ title = "Suno 音乐分离工具"
27
+ description = """
28
+ ### 使用说明
29
+ 1. 上传音频文件(支持mp3、wav等格式)
30
+ 2. 点击"提交"按钮
31
+ 3. 等待处理完成后下载分离后的人声和伴奏
32
+
33
+ ### 技术说明
34
+ - 本工具使用Facebook Research的Demucs v4 AI模型进行音频分离
35
+ - 分离质量取决于原始音频的质量和特性
36
+ """
37
+
38
+ # 创建应用界面
39
+ demo = gr.Interface(
40
+ fn=inference,
41
+ inputs=gr.Audio(type="filepath", label="上传音频文件"),
42
+ outputs=[
43
+ gr.Audio(type="filepath", label="人声"),
44
+ gr.Audio(type="filepath", label="伴奏")
45
+ ],
46
+ title=title,
47
+ description=description,
48
+ theme="huggingface",
49
+ examples=[["test.mp3"]]
50
+ )
51
+
52
+ if __name__ == "__main__":
53
+ # 启动服务器
54
+ demo.launch()
packages.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ ffmpeg
requirements.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ git+https://github.com/facebookresearch/demucs#egg=demucs
2
+ scipy
3
+ invisible-watermark
4
+ fonts
5
+ font-roboto
6
+ numpy<1.26
7
+ gradio>=3.50.0
8
+
test.mp3 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4b431d535d235bd81b62f816f08c3f1afb6679d2706d84b3b75903b7df909507
3
+ size 262867