我一直在尝试获取Google现在提供的Hello Magenta示例,我使用spyder作为我的IDE,我已经安装了tensorflow-gpu和magenta-gpu。我目前收到此错误:
Traceback (most recent call last):
File "<ipython-input-1-1f0eccfc01aa>", line 46, in <module>
mm.play_sequence(twinkle_twinkle,synth=mm.fluidsynth)
File "C:\Users\Allen\Anaconda3\envs\tensorflow\lib\site-packages\magenta\music\notebook_utils.py", line 98, in play_sequence
array_of_floats = synth(sequence, sample_rate=sample_rate, **synth_args)
File "C:\Users\Allen\Anaconda3\envs\tensorflow\lib\site-packages\magenta\music\midi_synth.py", line 55, in fluidsynth
return midi.fluidsynth(fs=sample_rate, sf2_path=sf2_path)
File "C:\Users\Allen\Anaconda3\envs\tensorflow\lib\site-packages\pretty_midi\pretty_midi.py", line 918, in fluidsynth
sf2_path=sf2_path) for i in self.instruments]
File "C:\Users\Allen\Anaconda3\envs\tensorflow\lib\site-packages\pretty_midi\pretty_midi.py", line 918, in <listcomp>
sf2_path=sf2_path) for i in self.instruments]
File "C:\Users\Allen\Anaconda3\envs\tensorflow\lib\site-packages\pretty_midi\instrument.py", line 428, in fluidsynth
fl = fluidsynth.Synth(samplerate=fs)
AttributeError: module 'fluidsynth' has no attribute 'Synth'
import magenta.music as mm
import magenta
import tensorflow
import numpy as np
from ctypes.util import find_library
import ctypes.util
orig_ctypes_util_find_library = ctypes.util.find_library
def proxy_find_library(lib):
if lib == 'fluidsynth':
return 'libfluidsynth.so.1'
else:
return orig_ctypes_util_find_library(lib)
ctypes.util.find_library = proxy_find_library
from magenta.protobuf import music_pb2
twinkle_twinkle = music_pb2.NoteSequence()
# Add the notes to the sequence.
twinkle_twinkle.notes.add(pitch=60, start_time=0.0, end_time=0.5, velocity=80)
twinkle_twinkle.notes.add(pitch=60, start_time=0.5, end_time=1.0, velocity=80)
twinkle_twinkle.notes.add(pitch=67, start_time=1.0, end_time=1.5, velocity=80)
twinkle_twinkle.notes.add(pitch=67, start_time=1.5, end_time=2.0, velocity=80)
twinkle_twinkle.notes.add(pitch=69, start_time=2.0, end_time=2.5, velocity=80)
twinkle_twinkle.notes.add(pitch=69, start_time=2.5, end_time=3.0, velocity=80)
twinkle_twinkle.notes.add(pitch=67, start_time=3.0, end_time=4.0, velocity=80)
twinkle_twinkle.notes.add(pitch=65, start_time=4.0, end_time=4.5, velocity=80)
twinkle_twinkle.notes.add(pitch=65, start_time=4.5, end_time=5.0, velocity=80)
twinkle_twinkle.notes.add(pitch=64, start_time=5.0, end_time=5.5, velocity=80)
twinkle_twinkle.notes.add(pitch=64, start_time=5.5, end_time=6.0, velocity=80)
twinkle_twinkle.notes.add(pitch=62, start_time=6.0, end_time=6.5, velocity=80)
twinkle_twinkle.notes.add(pitch=62, start_time=6.5, end_time=7.0, velocity=80)
twinkle_twinkle.notes.add(pitch=60, start_time=7.0, end_time=8.0, velocity=80)
twinkle_twinkle.total_time = 8
twinkle_twinkle.tempos.add(qpm=60);
# This is a colab utility method that visualizes a NoteSequence.
mm.plot_sequence(twinkle_twinkle)
# This is a colab utility method that plays a NoteSequence.
mm.play_sequence(twinkle_twinkle,synth=mm.fluidsynth)