midi2audio
midi2audio copied to clipboard
FileNotFoundError: [WinError 2] The system cannot find the file specified
Hi, when running the following script in order to convert a directory of midi files to wav I get the following error:
from midi2audio import FluidSynth
import os
import sys
files = [file for file in os.listdir('./') if '.mid' in file]
target_dir = 'C:\\Users\\Arham\\Desktop\\GuitarWavs'
if not os.path.exists(target_dir):
print("Creating directory: " + target_dir)
os.mkdir(target_dir)
print("Converting files...")
for file in files:
fs = FluidSynth()
fs.midi_to_audio(file, target_dir+'\\'+file[0:file.index('.mid')]+'.wav')
print('Convertion complete!')
Error:
Traceback (most recent call last):
File "miditowav.py", line 27, in <module>
fs.midi_to_audio(os.path.join(os.getcwd(),file), target_dir+'\\'+file[0:file.index('.mid')]+'.wav')
File "C:\Users\Arham\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\Arham\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 323, in call
with Popen(*popenargs, **kwargs) as p:
File "C:\Users\Arham\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "C:\Users\Arham\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 1178, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
I believe this has something to do with the fact that midi2audio runs fluidsynth as a subprocess but I'm unsure of the problem. I've installed fluidsynth on my system (Windows 10) via vcpkg with visual studio and I've added the fluidsynth_x86-windows/bin path to my system PATH variable.
I thought that the above would solve the problem but it hasn't. I'd appreciate any help in solving this.
I'm having the same issue. I've tried downloading a soundfont file to the [user]/.fluidsynth/default_sound_font.sf2 location but that doesn't seem to work. Is this a Windows compatibility issue?
If you are running Windows 10 make sure to have downloaded the x64 version of fluidsynth rather than the x86 version. This fixed the issue for me!
If you are running Windows 10 make sure to have downloaded the x64 version of fluidsynth rather than the x86 version. This fixed the issue for me!
Didn't quiet understand how to do it in windows.. what should I do after downloading it??
Make sure you construct the file path correctly. There may be a problem with concatenating the path manually. Better use os.path.join()
.
Also you can utilize os.path.splitext()
to change the extension. But it should not cause a problem like this.
I'm experiencing this same issue, win 11
I'm experiencing the same issue
Same issue please help fast
@axnoel, @Nasko-5, @Pixouls: Please provide any relevant details to replicate the issue, such as a minimal sample of code you're calling that's crashing. Also make sure you've installed to need sound fonts to the proper locations. I don't have Windows so I can't run it in such environment.
Ok i solved it installing fluidsynth with chocolatey