midi2audio icon indicating copy to clipboard operation
midi2audio copied to clipboard

FileNotFoundError: [WinError 2] The system cannot find the file specified

Open arham23 opened this issue 4 years ago • 9 comments

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.

arham23 avatar Apr 23 '20 01:04 arham23

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?

kevinm54 avatar Mar 02 '21 05:03 kevinm54

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!

brooke-ec avatar May 09 '21 10:05 brooke-ec

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??

ghost avatar Sep 29 '21 02:09 ghost

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.

bzamecnik avatar Sep 27 '22 13:09 bzamecnik

I'm experiencing this same issue, win 11

Pixouls avatar Jan 28 '23 23:01 Pixouls

I'm experiencing the same issue

Nasko-5 avatar Feb 05 '23 16:02 Nasko-5

Same issue please help fast

axnoel avatar Jan 18 '24 19:01 axnoel

@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.

bzamecnik avatar Jan 19 '24 03:01 bzamecnik

Ok i solved it installing fluidsynth with chocolatey

sumaikun avatar Feb 19 '24 05:02 sumaikun