使用spleeter对音乐分轨(人声&伴奏 分离)

前言

需要一首伴奏,在网上搜索了好久 都没有找到(专业音频处理软件又懒得下), 就搜到了spleeter,本文主要记录一下使用spleeter的过程 不解释原理

  1. 安装conda环境
  2. 下载spleeter
  3. 执行

conda

Conda 是开源的包管理系统和环境管理系统,可以安装软件包的多个版本和依赖,而且方便切换.conda的安装参考https://www.jianshu.com/p/edaa744ea47d本文不赘述

spleeter

Spleeter基于TensorFlow开发,本身运行速度非常快。分离过程可以在GPU或CPU上执行 需要python环境3.6-3.7

安装使用Spleeter

因spleeter 需要使用python3.6-3.7 本示例中使用conda创建python3.6环境

#创建py36环境
conda create -n py36 python=3.6 anaconda
#使用py36环境
conda activate py36
#解除环境
conda deactivate

安装spleeter

# install using conda
conda install -c conda-forge spleeter
# download an example audio file (if you don't have wget, use another tool for downloading)
wget https://github.com/deezer/spleeter/raw/master/audio_example.mp3
# separate the example audio into two components
spleeter separate -i audio_example.mp3 -p spleeter:2stems -o output

执行spleeter会检查是否有2stems学习库 没有自动下载 也可自行下载
解压放在执行目录下 pretrained_models/2stems

编写脚本

#!/bin/bash
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/abcd/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/Users/abcd/miniconda3/etc/profile.d/conda.sh" ]; then
        . "/Users/abcd/miniconda3/etc/profile.d/conda.sh"
    else
        export PATH="/Users/abcd/miniconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<
# 使用python 3.6环境
conda activate py36
echo "输入音乐目录:"
read path
if [ -f "$path" ]; then
 spleeter separate -i "$path" -p spleeter:2stems -o output
else
 echo "$path 不存在" 
fi

# >>> conda initialize >>>
....... 此部分内容可在.bash_profile文件中复制过来使用
# <<< conda initialize <<<

猜你喜欢

转载自blog.csdn.net/sinat_25926481/article/details/111246156