免费背景音人声分离解决方案MVSEP-MDX23,足以和Spleeter分庭抗礼

这篇具有很好参考价值的文章主要介绍了免费背景音人声分离解决方案MVSEP-MDX23,足以和Spleeter分庭抗礼。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

免费背景音人声分离解决方案MVSEP-MDX23,足以和Spleeter分庭抗礼

在音视频领域,把已经发布的混音歌曲或者音频文件逆向分离一直是世界性的课题。音波混合的物理特性导致在没有原始工程文件的情况下,将其还原和分离是一件很有难度的事情。

言及背景音人声分离技术,就不能不提Spleeter,它是一种用于音频源分离(音乐分离)的开源深度学习算法,由Deezer研究团队开发。使用的是一个性能取向的音源分离算法,并且为用户提供了已经预训练好的模型,能够开箱即用,这也是Spleeter泛用性高的原因之一,关于Spleeter,请移步:人工智能AI库Spleeter免费人声和背景音乐分离实践(Python3.10),这里不再赘述。

MVSEP-MDX23背景音人声分离技术由Demucs研发,Demucs来自Facebook Research团队,它的发源晚于Spleeter,早于MDX-Net,并且经历过4个大版本的迭代,每一代的模型结构都被大改。Demucs的生成质量从v3开始大幅质变,一度领先行业平均水平,v4是现在最强的开源乐器分离单模型,v1和v2的网络模型被用作MDX-net其中的一部分。

本次我们基于MVSEP-MDX23来对音频的背景音和人声进行分离。

本地分离人声和背景音

如果本地离线运行MVSEP-MDX23,首先克隆代码:

git clone https://github.com/jarredou/MVSEP-MDX23-Colab_v2.git

随后进入项目并安装依赖:

cd MVSEP-MDX23-Colab_v2  
pip3 install -r requirements.txt

随后直接进推理即可:

python3 inference.py --input_audio test.wav --output_folder ./results/

这里将test.wav进行人声分离,分离后的文件在results文件夹生成。

注意推理过程中会将分离模型下载到项目的models目录,极其巨大。

同时推理过程相当缓慢。

这里可以添加--single_onnx参数来提高推理速度,但音质上有一定的损失。

如果本地设备具备12G以上的显存,也可以添加--large_gpu参数来提高推理的速度。

如果本地没有N卡或者显存实在捉襟见肘,也可以通过--cpu参数来使用cpu进行推理,但是并不推荐这样做,因为本来就慢,用cpu就更慢了。

令人暖心的是,官方还利用Pyqt写了一个小的gui界面来提高操作友好度:

__author__ = 'Roman Solovyev (ZFTurbo), IPPM RAS'  
  
if __name__ == '__main__':  
    import os  
  
    gpu_use = "0"  
    print('GPU use: {}'.format(gpu_use))  
    os.environ["CUDA_VISIBLE_DEVICES"] = "{}".format(gpu_use)  
  
import time  
import os  
import numpy as np  
from PyQt5.QtCore import *  
from PyQt5 import QtCore  
from PyQt5.QtWidgets import *  
import sys  
from inference import predict_with_model  
  
  
root = dict()  
  
  
class Worker(QObject):  
    finished = pyqtSignal()  
    progress = pyqtSignal(int)  
  
    def __init__(self, options):  
        super().__init__()  
        self.options = options  
  
    def run(self):  
        global root  
        # Here we pass the update_progress (uncalled!)  
        self.options['update_percent_func'] = self.update_progress  
        predict_with_model(self.options)  
        root['button_start'].setDisabled(False)  
        root['button_finish'].setDisabled(True)  
        root['start_proc'] = False  
        self.finished.emit()  
  
    def update_progress(self, percent):  
        self.progress.emit(percent)  
  
  
class Ui_Dialog(object):  
    def setupUi(self, Dialog):  
        global root  
  
        Dialog.setObjectName("Settings")  
        Dialog.resize(370, 180)  
  
        self.checkbox_cpu = QCheckBox("Use CPU instead of GPU?", Dialog)  
        self.checkbox_cpu.move(30, 10)  
        self.checkbox_cpu.resize(320, 40)  
        if root['cpu']:  
            self.checkbox_cpu.setChecked(True)  
  
        self.checkbox_single_onnx = QCheckBox("Use single ONNX?", Dialog)  
        self.checkbox_single_onnx.move(30, 40)  
        self.checkbox_single_onnx.resize(320, 40)  
        if root['single_onnx']:  
            self.checkbox_single_onnx.setChecked(True)  
  
        self.pushButton_save = QPushButton(Dialog)  
        self.pushButton_save.setObjectName("pushButton_save")  
        self.pushButton_save.move(30, 120)  
        self.pushButton_save.resize(150, 35)  
  
        self.pushButton_cancel = QPushButton(Dialog)  
        self.pushButton_cancel.setObjectName("pushButton_cancel")  
        self.pushButton_cancel.move(190, 120)  
        self.pushButton_cancel.resize(150, 35)  
  
        self.retranslateUi(Dialog)  
        QtCore.QMetaObject.connectSlotsByName(Dialog)  
        self.Dialog = Dialog  
  
        # connect the two functions  
        self.pushButton_save.clicked.connect(self.return_save)  
        self.pushButton_cancel.clicked.connect(self.return_cancel)  
  
    def retranslateUi(self, Dialog):  
        _translate = QtCore.QCoreApplication.translate  
        Dialog.setWindowTitle(_translate("Settings", "Settings"))  
        self.pushButton_cancel.setText(_translate("Settings", "Cancel"))  
        self.pushButton_save.setText(_translate("Settings", "Save settings"))  
  
    def return_save(self):  
        global root  
        # print("save")  
        root['cpu'] = self.checkbox_cpu.isChecked()  
        root['single_onnx'] = self.checkbox_single_onnx.isChecked()  
        self.Dialog.close()  
  
    def return_cancel(self):  
        global root  
        # print("cancel")  
        self.Dialog.close()  
  
  
class MyWidget(QWidget):  
    def __init__(self):  
        super().__init__()  
        self.initUI()  
  
    def initUI(self):  
        self.resize(560, 360)  
        self.move(300, 300)  
        self.setWindowTitle('MVSEP music separation model')  
        self.setAcceptDrops(True)  
  
    def dragEnterEvent(self, event):  
        if event.mimeData().hasUrls():  
            event.accept()  
        else:  
            event.ignore()  
  
    def dropEvent(self, event):  
        global root  
        files = [u.toLocalFile() for u in event.mimeData().urls()]  
        txt = ''  
        root['input_files'] = []  
        for f in files:  
            root['input_files'].append(f)  
            txt += f + '\n'  
        root['input_files_list_text_area'].insertPlainText(txt)  
        root['progress_bar'].setValue(0)  
  
    def execute_long_task(self):  
        global root  
  
        if len(root['input_files']) == 0 and 1:  
            QMessageBox.about(root['w'], "Error", "No input files specified!")  
            return  
  
        root['progress_bar'].show()  
        root['button_start'].setDisabled(True)  
        root['button_finish'].setDisabled(False)  
        root['start_proc'] = True  
  
        options = {  
            'input_audio': root['input_files'],  
            'output_folder': root['output_folder'],  
            'cpu': root['cpu'],  
            'single_onnx': root['single_onnx'],  
            'overlap_large': 0.6,  
            'overlap_small': 0.5,  
        }  
  
        self.update_progress(0)  
        self.thread = QThread()  
        self.worker = Worker(options)  
        self.worker.moveToThread(self.thread)  
  
        self.thread.started.connect(self.worker.run)  
        self.worker.finished.connect(self.thread.quit)  
        self.worker.finished.connect(self.worker.deleteLater)  
        self.thread.finished.connect(self.thread.deleteLater)  
        self.worker.progress.connect(self.update_progress)  
  
        self.thread.start()  
  
    def stop_separation(self):  
        global root  
        self.thread.terminate()  
        root['button_start'].setDisabled(False)  
        root['button_finish'].setDisabled(True)  
        root['start_proc'] = False  
        root['progress_bar'].hide()  
  
    def update_progress(self, progress):  
        global root  
        root['progress_bar'].setValue(progress)  
  
    def open_settings(self):  
        global root  
        dialog = QDialog()  
        dialog.ui = Ui_Dialog()  
        dialog.ui.setupUi(dialog)  
        dialog.exec_()  
  
  
def dialog_select_input_files():  
    global root  
    files, _ = QFileDialog.getOpenFileNames(  
        None,  
        "QFileDialog.getOpenFileNames()",  
        "",  
        "All Files (*);;Audio Files (*.wav, *.mp3, *.flac)",  
    )  
    if files:  
        txt = ''  
        root['input_files'] = []  
        for f in files:  
            root['input_files'].append(f)  
            txt += f + '\n'  
        root['input_files_list_text_area'].insertPlainText(txt)  
        root['progress_bar'].setValue(0)  
    return files  
  
  
def dialog_select_output_folder():  
    global root  
    foldername = QFileDialog.getExistingDirectory(  
        None,  
        "Select Directory"  
    )  
    root['output_folder'] = foldername + '/'  
    root['output_folder_line_edit'].setText(root['output_folder'])  
    return foldername  
  
  
def create_dialog():  
    global root  
    app = QApplication(sys.argv)  
  
    w = MyWidget()  
  
    root['input_files'] = []  
    root['output_folder'] = os.path.dirname(os.path.abspath(__file__)) + '/results/'  
    root['cpu'] = False  
    root['single_onnx'] = False  
  
    button_select_input_files = QPushButton(w)  
    button_select_input_files.setText("Input audio files")  
    button_select_input_files.clicked.connect(dialog_select_input_files)  
    button_select_input_files.setFixedHeight(35)  
    button_select_input_files.setFixedWidth(150)  
    button_select_input_files.move(30, 20)  
  
    input_files_list_text_area = QTextEdit(w)  
    input_files_list_text_area.setReadOnly(True)  
    input_files_list_text_area.setLineWrapMode(QTextEdit.NoWrap)  
    font = input_files_list_text_area.font()  
    font.setFamily("Courier")  
    font.setPointSize(10)  
    input_files_list_text_area.move(30, 60)  
    input_files_list_text_area.resize(500, 100)  
  
    button_select_output_folder = QPushButton(w)  
    button_select_output_folder.setText("Output folder")  
    button_select_output_folder.setFixedHeight(35)  
    button_select_output_folder.setFixedWidth(150)  
    button_select_output_folder.clicked.connect(dialog_select_output_folder)  
    button_select_output_folder.move(30, 180)  
  
    output_folder_line_edit = QLineEdit(w)  
    output_folder_line_edit.setReadOnly(True)  
    font = output_folder_line_edit.font()  
    font.setFamily("Courier")  
    font.setPointSize(10)  
    output_folder_line_edit.move(30, 220)  
    output_folder_line_edit.setFixedWidth(500)  
    output_folder_line_edit.setText(root['output_folder'])  
  
    progress_bar = QProgressBar(w)  
    # progress_bar.move(30, 310)  
    progress_bar.setValue(0)  
    progress_bar.setGeometry(30, 310, 500, 35)  
    progress_bar.setAlignment(QtCore.Qt.AlignCenter)  
    progress_bar.hide()  
    root['progress_bar'] = progress_bar  
  
    button_start = QPushButton('Start separation', w)  
    button_start.clicked.connect(w.execute_long_task)  
    button_start.setFixedHeight(35)  
    button_start.setFixedWidth(150)  
    button_start.move(30, 270)  
  
    button_finish = QPushButton('Stop separation', w)  
    button_finish.clicked.connect(w.stop_separation)  
    button_finish.setFixedHeight(35)  
    button_finish.setFixedWidth(150)  
    button_finish.move(200, 270)  
    button_finish.setDisabled(True)  
  
    button_settings = QPushButton('⚙', w)  
    button_settings.clicked.connect(w.open_settings)  
    button_settings.setFixedHeight(35)  
    button_settings.setFixedWidth(35)  
    button_settings.move(495, 270)  
    button_settings.setDisabled(False)  
  
    mvsep_link = QLabel(w)  
    mvsep_link.setOpenExternalLinks(True)  
    font = mvsep_link.font()  
    font.setFamily("Courier")  
    font.setPointSize(10)  
    mvsep_link.move(415, 30)  
    mvsep_link.setText('Powered by <a href="https://mvsep.com">MVSep.com</a>')  
  
    root['w'] = w  
    root['input_files_list_text_area'] = input_files_list_text_area  
    root['output_folder_line_edit'] = output_folder_line_edit  
    root['button_start'] = button_start  
    root['button_finish'] = button_finish  
    root['button_settings'] = button_settings  
  
    # w.showMaximized()  
    w.show()  
    sys.exit(app.exec_())  
  
  
if __name__ == '__main__':  
    create_dialog()

效果如下:

界面虽然朴素,但相当实用,Spleeter可没给我们提供这个待遇。

Colab云端分离人声和背景音

托Google的福,我们也可以在Colab云端使用MVSEP-MDX23:

https://colab.research.google.com/github/jarredou/MVSEP-MDX23-Colab_v2/blob/v2.3/MVSep-MDX23-Colab.ipynb#scrollTo=uWX5WOqjU0QC

首先安装MVSEP-MDX23:

#@markdown #Installation  
#@markdown *Run this cell to install MVSep-MDX23*  
print('Installing... This will take 1 minute...')  
%cd /content  
from google.colab import drive  
drive.mount('/content/drive')  
!git clone https://github.com/jarredou/MVSEP-MDX23-Colab_v2.git &> /dev/null  
%cd /content/MVSEP-MDX23-Colab_v2  
!pip install -r requirements.txt &> /dev/null  
# onnxruntime-gpu nightly fix for cuda12.2  
!python -m pip install ort-nightly-gpu --index-url=https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/ort-cuda-12-nightly/pypi/simple/  
print('Installation done !')

随后编写推理代码:

#@markdown #Separation  
from pathlib import Path  
import glob  
  
%cd /content/MVSEP-MDX23-Colab_v2  
  
  
input = '/content/drive/MyDrive' #@param {type:"string"}  
output_folder = '/content/drive/MyDrive/output' #@param {type:"string"}  
#@markdown ---  
#@markdown *Bigshifts=1 to disable that feature*  
  
BigShifts = 7 #@param {type:"slider", min:1, max:41, step:1}  
#@markdown ---  
overlap_InstVoc = 1 #@param {type:"slider", min:1, max:40, step:1}  
overlap_VitLarge = 1 #@param {type:"slider", min:1, max:40, step:1}  
#@markdown ---  
weight_InstVoc = 8 #@param {type:"slider", min:0, max:10, step:1}  
weight_VitLarge = 5 #@param {type:"slider", min:0, max:10, step:1}  
#@markdown ---  
use_VOCFT = False #@param {type:"boolean"}  
overlap_VOCFT = 0.1 #@param {type:"slider", min:0, max:0.95, step:0.05}  
weight_VOCFT = 2 #@param {type:"slider", min:0, max:10, step:1}  
#@markdown ---  
vocals_instru_only = True #@param {type:"boolean"}  
overlap_demucs = 0.6 #@param {type:"slider", min:0, max:0.95, step:0.05}  
#@markdown ---  
output_format = 'PCM_16' #@param ["PCM_16", "FLOAT"]  
if vocals_instru_only:  
    vocals_only = '--vocals_only true'  
else:  
    vocals_only = ''  
  
  
if use_VOCFT:  
    use_VOCFT = '--use_VOCFT true'  
else:  
    use_VOCFT = ''  
  
if Path(input).is_file():  
  file_path = input  
  Path(output_folder).mkdir(parents=True, exist_ok=True)  
  !python inference.py \  
        --large_gpu \  
        --weight_InstVoc {weight_InstVoc} \  
        --weight_VOCFT {weight_VOCFT} \  
        --weight_VitLarge {weight_VitLarge} \  
        --input_audio "{file_path}" \  
        --overlap_demucs {overlap_demucs} \  
        --overlap_VOCFT {overlap_VOCFT} \  
        --overlap_InstVoc {overlap_InstVoc} \  
        --overlap_VitLarge {overlap_VitLarge} \  
        --output_format {output_format} \  
        --BigShifts {BigShifts} \  
        --output_folder "{output_folder}" \  
        {vocals_only} \  
        {use_VOCFT}  
  
else:  
  file_paths = sorted([f'"{glob.escape(path)}"' for path in glob.glob(input + "/*")])[:]  
  input_audio_args = ' '.join(file_paths)  
  Path(output_folder).mkdir(parents=True, exist_ok=True)  
  !python inference.py \  
          --large_gpu \  
          --weight_InstVoc {weight_InstVoc} \  
          --weight_VOCFT {weight_VOCFT} \  
          --weight_VitLarge {weight_VitLarge} \  
          --input_audio {input_audio_args} \  
          --overlap_demucs {overlap_demucs} \  
          --overlap_VOCFT {overlap_VOCFT} \  
          --overlap_InstVoc {int(overlap_InstVoc)} \  
          --overlap_VitLarge {int(overlap_VitLarge)} \  
          --output_format {output_format} \  
          --BigShifts {BigShifts} \  
          --output_folder "{output_folder}" \  
          {vocals_only} \  
          {use_VOCFT}

这里默认使用google云盘的目录,也可以修改为当前服务器的目录地址。

结语

MVSEP-MDX23 和 Spleeter 都是音频人声背景音分离软件,作为用户,我们到底应该怎么选择?

MVSEP-MDX23 基于 Demucs4 和 MDX 神经网络架构,可以将音乐分离成“bass”、“drums”、“vocals”和“other”四个部分。MVSEP-MDX23 在 2023 年的音乐分离挑战中获得了第三名,并且在 MultiSong 数据集上的质量比较中表现出色。它提供了 Python 命令行工具和 GUI 界面,支持 CPU 和 GPU 加速,可以在本地运行。

Spleeter 是由 Deezer 开发的开源音频分离库,它使用深度学习模型将音频分离成不同的音轨,如人声、伴奏等。Spleeter 提供了预训练的模型,可以在命令行或作为 Python 库使用。它的优势在于易用性和灵活性,可以根据需要分离不同数量的音轨。

总的来说,MVSEP-MDX23 在音频分离的性能和精度上表现出色,尤其适合需要高质量音频分离的专业用户。而 Spleeter 则更适合普通用户和开发者,因为它易于使用,并且具有更多的定制选项。文章来源地址https://www.toymoban.com/news/detail-761426.html

到了这里,关于免费背景音人声分离解决方案MVSEP-MDX23,足以和Spleeter分庭抗礼的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 模版的分离编译 解决方案

    对于模版,在之前我们就已经讲过,模版不支持分离编译(即声明定义不在同一文件中)。 类中,我们知道,对于代码量比较小的函数,会默认识别成内联函数,增加代码运行的效率,而一些代码量比较大的函数,则仍然进行函数调用。  但是有些函数实在长,如果这些函数

    2024年02月07日
    浏览(19)
  • video视频背景层级过高解决方案

    uni-app开发的项目中使用video标签设置视频做为页面背景,video标签层级过高,页面中内容不展示。 官方提供了三种办法: cover-这个标签使用说明:这个标签APP端它不支持嵌套,就是就算这种都是不支持的,所以如果你的页面比较复杂的话这种方法是不行的,页面元素简单的话

    2024年02月03日
    浏览(30)
  • 现代 CSS 解决方案:文字颜色自动适配背景色!

    在 23 年的 CSS 新特性中,有一个非常重要的功能更新 -- 相对颜色 。 简单而言,相对颜色的功能,让我们在 CSS 中,对颜色有了更为强大的掌控能力。 其核心功能就是,让我们 能够基于一个现有颜色 A,通过一定的转换规则,快速生成我们想要的颜色 B 。 其功能能够涵盖:

    2024年02月03日
    浏览(47)
  • 前后端分离 后端获取不到header解决方案

    我这里只是把重要的逻辑放在里面,如果要看所有文件的话就太多了 这个案例不要拿来用,这个是有问题的,我只是讲一下问题在哪

    2024年02月12日
    浏览(55)
  • 关于微信小程序背景图手机上加载不出来问题的解决方案

    1.问题:平时在给背景图的时候大家的第一反应一定是在css中直接写background-image,直接就把图片当背景放在了那里,但是这样的方法在pc端还是可以的,在小程序端却存在着加载不出来的问题,现在我来给大家提供一个解决方法(插入图片的方法) 2.原理:一个大的父盒子,同时

    2024年02月04日
    浏览(74)
  • ruoyi-vue前后端分离框架上传图片不显示问题,nginx解决方案

    使用若依前后端分离框架,前端项目打包在Nginx,上传图片时,图片上传成功,但是在列表页和添加/修改页面没有正常显示。 插入成功后数据库保存数据样式: 回显数据时样式: 此时样式是打不开的,无法找到路径 解决办法:nginx.conf在location中添加alias location /prod-api/profil

    2024年02月02日
    浏览(40)
  • ENVI监督分类后背景值也被分成一种地物,解决方案和转移矩阵制作方法

    背景值也被分为一种地物是由于一开始没有选择mask掩膜,让背景不参与运算,百度可了解具体过程。 现在来解决已经分类完后怎么补救 之后转移矩阵的制作,对文件格式有着严格要求,分类结果如果裁剪或者地物名字发生更改,就不再是分类结果,无法进行转移矩阵的制作

    2024年02月11日
    浏览(30)
  • 前后端分离项目跨域问题No ‘Access-Control-Allow-Origin‘解决方案

    一.问题背景 前后端分离项目跨域问题,浏览器控制台报错: No \\\'Access-Control-Allow-Origin\\\' header is present on the requested resource. 请求方法为OPTIONS,状态值为302或403。 本文解决常见的CORS跨域问题,以及,集成CAS 5.3单点登录内嵌页面时,发送复杂请求产生的跨域问题。 二.解决方案

    2024年02月02日
    浏览(45)
  • 国内企业出海首选的免费开源生产执行管理系统(MES)解决方案

    Odoo制造执行系统 (MES) 系统的创新型实时解决方案,可帮助您了解最新生产数据 准确获取各地生产设施的数据对于短期业务执行以及长期战略规划都极为重要。为此,Odoo 提供了基于条码扫描仪的传统界面,以及支持互动的创新型平板电脑应用。条码扫描仪可加快数据录入速

    2024年02月04日
    浏览(41)
  • ChatGPT和Bard太贵,介绍8个免费开源的大模型解决方案!

    8个开源的ChatGPT和Bard的替代方案,带你发现更多广泛使用的开源框架和模型。 微信搜索关注《Python学研大本营》,加入读者群,分享更多精彩 LLaMA项目包含了一组基础语言模型,其规模从70亿到650亿个参数不等。这些模型在数以百万计的token上进行训练,而且它完全在公开的

    2024年02月14日
    浏览(40)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包