File size: 940 Bytes
1d31599 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
---
license: apache-2.0
datasets:
- HuggingFaceFW/fineweb-edu
language:
- aa
metrics:
- accuracy
library_name: adapter-transformers
tags:
- music
---
pip install spleeter
import os
from spleeter.separator import Separator
from spleeter.audio.adapter import AudioAdapter
def separate_vocals(input_file, output_dir):
# 创建一个Separator对象,使用2stems预训练模型(vocals 和 accompaniment)
separator = Separator('spleeter:2stems')
# 创建输出目录(如果不存在)
os.makedirs(output_dir, exist_ok=True)
# 执行分离
separator.separate_to_file(input_file, output_dir)
print(f"分离完成。结果保存在 {output_dir}")
# 使用示例
if __name__ == "__main__":
input_mp3 = "path/to/your/input.mp3" # 替换为你的MP3文件路径
output_directory = "path/to/output/directory" # 替换为你想要保存输出的目录
separate_vocals(input_mp3, output_directory) |