由Python将MP3转换为MIDI(类型错误:无法加载插件:mtg-Melodia:Melodia)

MP3 to midi converting by python (TypeError: Failed to load plugin: mtg-melodia:melodia)(由Python将MP3转换为MIDI(类型错误:无法加载插件:mtg-Melodia:Melodia))

本文介绍了由Python将MP3转换为MIDI(类型错误:无法加载插件:mtg-Melodia:Melodia)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在CoLab主页中编写一些代码将MP3文件转换为MIDI。

所以我记得创建mp3格式的MIDI文件是一个很大的项目,我可能在将个人歌曲或音频文件导入到这个项目中时遇到了困难。(音频格式到MIDI,有些地方是用人工智能完成的(如PolyphonicPianoTranscription),(列表AudiotoMIDI conversion projects)。

所以我试着用这个函数把MP3转换成wav:

def MP3_to_WAV(MP3_file):
   from pydub import AudioSegment
   sound = AudioSegment.from_mp3(MP3_file)
   filename = os.path.basename(MP3_file)
   wav_file_name=output_path+filename.split('.')[0]+'.wav'
   sound.export(wav_file_name, format="wav")
   return wav_file_name

并尝试通过this指令和此函数将wav转换为MIDI:

def wav_to_midi(wav_f_n):
   filename2 = os.path.basename(wav_f_n)
   midi_file_name=output_path+filename2.split('.')[0]+'.midi'
   run_comand("python /content/audio_to_midi_melodia/audio_to_midi_melodia.py "+wav_file+' '+ midi_file_name+" 120")
   return midi_file_name
 

但在我的CoLab页面的WAV to Midi阻止代码(link)中,我收到以下错误:



Vamp::HostExt::PluginLoader: No library found in Vamp path for plugin "mtg-melodia:melodia"
Loading audio...
Extracting melody f0 with MELODIA...
Traceback (most recent call last):
  File "/content/audio_to_midi_melodia/audio_to_midi_melodia.py", line 225, in <module>
    savejams=args.jams)
  File "/content/audio_to_midi_melodia/audio_to_midi_melodia.py", line 174, in audio_to_midi_melodia
    parameters={"voicing": 0.2})
  File "/usr/local/lib/python3.7/dist-packages/vamp/collect.py", line 166, in collect
    plugin, step_size, block_size = vamp.load.load_and_configure(data, sample_rate, plugin_key, parameters, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/vamp/load.py", line 83, in load_and_configure
    vampyhost.ADAPT_CHANNEL_COUNT)
TypeError: Failed to load plugin: mtg-melodia:melodia
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-35-c99e6fb96073> in <module>()
     84     print('
'+files+'
')
     85     wav_file=MP3_to_WAV(files)
---> 86     midi_file=wav_to_midi(wav_file)
     87 
     88 

2 frames
<ipython-input-35-c99e6fb96073> in execute(command)
     55         return output
     56     else:
---> 57         raise ProcessException(command, exitCode, output)
     58 
     59 

TypeError: __init__() takes 2 positional arguments but 4 were given

我猜这一定是因为Python版本不匹配而导致的,但在这里被问到了。

感谢您的关注。

推荐答案

看起来根本问题是Vamp::HostExt::PluginLoader: No library found in Vamp path for plugin "mtg-melodia:melodia"

因此需要将mtg-Melodia:Melodia的路径添加到VAMP路径,或者需要安装和配置mtg-Melodia:Melodia。

看起来您正在使用以下url中的说明来设置mtg-Melodia。您可以在那里重新检查mtg-Melodia安装和配置的详细信息吗,您可能遗漏了一个步骤。
https://ourcodeworld.com/articles/read/983/how-to-extract-the-melody-from-an-audio-file-and-export-it-to-midi-generate-quantized-midi-using-python-in-ubuntu-18-04

这篇关于由Python将MP3转换为MIDI(类型错误:无法加载插件:mtg-Melodia:Melodia)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:由Python将MP3转换为MIDI(类型错误:无法加载插件:mtg-Melodia:Melodia)

基础教程推荐