Adapters
Afar
music
spleete / README.md
Yinghoo's picture
Update Readme.md
1d31599 verified
|
raw
history blame
940 Bytes
metadata
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)