试图使程序将MIDI文件转换为其他文件类型。
这是无效的代码示例:
from midi2audio import FluidSynth
midfile = "F:\\ai nea\\Actual Project\\"+input()
output = "F:\\ai nea\\Actual Project\\output.mp3"
soundfont= "F:\\ai nea\\Actual Project\\FluidR3 GM.sf2"
fs = FluidSynth(sound_font=soundfont)
fs.midi_to_audio(midfile,output)
这是一个异常(exception):
Traceback (most recent call last):
File "F:/ai nea/Actual Project/contest.py", line 6, in <module>
fs.midi_to_audio(midfile,output)
File "C:\Users\Will\AppData\Local\Programs\Python\Python37\lib\site-packages\midi2audio.py", line 46, in midi_to_audio
subprocess.call(['fluidsynth', '-ni', self.sound_font, midi_file, '-F', audio_file, '-r', str(self.sample_rate)])
File "C:\Users\Will\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 339, in call
with Popen(*popenargs, **kwargs) as p:
File "C:\Users\Will\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 800, in __init__
restore_signals, start_new_session)
File "C:\Users\Will\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 1207, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
有任何想法吗?
最佳答案
找不到您的程序“fluidsynth.exe”。您可以解决此问题,将程序的位置放在PATH
环境变量中。