Does anyone know how to install fluidsynth or pyfluidsynth on windows 10? AttributeError: module 'fluidsynth' has no attribute 'Synth'

2.6k Views Asked by At

I've tried to install fluidsynth and pyfluidsynth on windows 10 so many times in order to let magenta.music function play_sequence(note_seq,synth=mm.fluidsynth) play a note sequence and show it on my jupyter notebook.

I tried to clone the github repository, install it with pip, but nothing seems to work. I check that Synth class was on my fluidsynth.py script and I found it so I don't know where is the problem.

The error I get is this one:


AttributeError Traceback (most recent call last) in 2 #MIDI file from raw pitch curve 3 file = 'midi ----> 4 midi_pianoroll(file) 5 play_midi(file + '.mid')

in midi_pianoroll(file_prefix) 16 17 # This is a colab utility method that plays a NoteSequence. ---> 18 mm.play_sequence(note_seq,synth=mm.fluidsynth) 19 return 20

~\Anaconda3\lib\site-packages\magenta\music\notebook_utils.py in play_sequence(sequence, synth, sample_rate, colab_ephemeral, **synth_args) 99 **synth_args: Additional keyword arguments to pass to the synth function. 100 """ --> 101 array_of_floats = synth(sequence, sample_rate=sample_rate, **synth_args) 102 103 try:

~\Anaconda3\lib\site-packages\magenta\music\midi_synth.py in fluidsynth(sequence, sample_rate, sf2_path) 53 """ 54 midi = midi_io.note_sequence_to_pretty_midi(sequence) ---> 55 return midi.fluidsynth(fs=sample_rate, sf2_path=sf2_path)

~\Anaconda3\lib\site-packages\pretty_midi\pretty_midi.py in fluidsynth(self, fs, sf2_path) 916 # Get synthesized waveform for each instrument 917 waveforms = [i.fluidsynth(fs=fs, --> 918 sf2_path=sf2_path) for i in self.instruments] 919 # Allocate output waveform, with #sample = max length of all waveforms 920 synthesized = np.zeros(np.max([w.shape[0] for w in waveforms]))

~\Anaconda3\lib\site-packages\pretty_midi\pretty_midi.py in (.0) 916 # Get synthesized waveform for each instrument 917 waveforms = [i.fluidsynth(fs=fs, --> 918 sf2_path=sf2_path) for i in self.instruments] 919 # Allocate output waveform, with #sample = max length of all waveforms 920 synthesized = np.zeros(np.max([w.shape[0] for w in waveforms]))

~\Anaconda3\lib\site-packages\pretty_midi\instrument.py in fluidsynth(self, fs, sf2_path) 426 427 # Create fluidsynth instance --> 428 fl = fluidsynth.Synth(samplerate=fs) 429 # Load in the soundfont 430 sfid = fl.sfload(sf2_path)

AttributeError: module 'fluidsynth' has no attribute 'Synth'

2

There are 2 best solutions below

0
On

For Windows, you have to:

  1. Build it: https://github.com/FluidSynth/fluidsynth/wiki/BuildingWithCMake#building-with-msys2-on-windows (cause it is installed on os, not on python)

  2. Then in your IDE terminal (let's say PyCharm) type: pip install --upgrade pyfluidsynth

  3. You can also install pretty_midi for later usage (pip install pretty_midi)

0
On