keunwoochoi / keras_STFT_layer

Do STFT in Keras
MIT License
63 stars 9 forks source link

Running the example_stft.py and example_melgram.py #2

Closed mpariente closed 4 years ago

mpariente commented 7 years ago

Hi Keunwoochoi,

When I run the example_stft.py , I get this error message :

Using TensorFlow backend.
Traceback (most recent call last):
  File "example_stft.py", line 8, in <module>
    specgram = stft.Spectrogram(n_dft=512, input_shape=(len_src, 1), n_hop=256)
  File "/home/claire/Bureau/All/Stage2016/Codes/keras_STFT_layer-master/stft.py", line 220, in Spectrogram
    logamplitude=logamplitude)
  File "/home/claire/Bureau/All/Stage2016/Codes/keras_STFT_layer-master/stft.py", line 176, in get_spectrogram_tensors
    STFT_magnitude = Logam_layer()(STFT_magnitude)
  File "/home/claire/anaconda2/lib/python2.7/site-packages/keras/engine/topology.py", line 514, in __call__
    self.add_inbound_node(inbound_layers, node_indices, tensor_indices)
  File "/home/claire/anaconda2/lib/python2.7/site-packages/keras/engine/topology.py", line 572, in add_inbound_node
    Node.create_node(self, inbound_layers, node_indices, tensor_indices)
  File "/home/claire/anaconda2/lib/python2.7/site-packages/keras/engine/topology.py", line 149, in create_node
    output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0]))
  File "/home/claire/anaconda2/lib/python2.7/site-packages/keras/layers/core.py", line 556, in call
    return self.function(x, **arguments)
  File "/home/claire/Bureau/All/Stage2016/Codes/keras_STFT_layer-master/stft.py", line 89, in <lambda>
    return Lambda(lambda x: logam(x), name=name,
  File "/home/claire/Bureau/All/Stage2016/Codes/keras_STFT_layer-master/stft.py", line 79, in logam
    log_spec = 10*K.log(K.maximum(x, 1e-10))/K.log(10)
  File "/home/claire/anaconda2/lib/python2.7/site-packages/keras/backend/tensorflow_backend.py", line 566, in log
    return tf.log(x)
  File "/home/claire/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/gen_math_ops.py", line 1094, in log
    result = _op_def_lib.apply_op("Log", x=x, name=name)
  File "/home/claire/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/op_def_library.py", line 530, in apply_op
    _Attr(op_def, input_arg.type_attr))
  File "/home/claire/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/op_def_library.py", line 61, in _SatisfiesTypeConstraint
    ", ".join(dtypes.as_dtype(x).name for x in allowed_list)))
TypeError: DataType int32 for attr 'T' not in list of allowed values: float16, float32, float64, complex64, complex128

I'm sorry it's a bit long but I don't understand where it comes from.

And also when I'm running the example_melgram.py, I have this error :

Traceback (most recent call last):
  File "example_melgram.py", line 8, in <module>
    melgram = melgram.Melspectrogram(n_dft=512, n_hop=256, input_shape=(len_src, 1), sr=12000)
TypeError: Melspectrogram() takes at least 3 arguments (4 given)

Could you help me please, Thank you in advance!

keunwoochoi commented 7 years ago

Can you first try it with Theano? Or with dim_ordering()=th? I also don't get the message now but I always develop it with Theano first.

keunwoochoi commented 7 years ago

PS. Formatting with markdown always help!

mpariente commented 7 years ago

So I changed to Theano backend in the keras.json file and now I get this error...

Using Theano backend.
output shape of logam: (None, 469, 257)
Traceback (most recent call last):
  File "example_stft.py", line 11, in <module>
    src, sr = librosa.load('src/bensound-cute.mp3', sr=12000, duration=10.0)  # whole signal
  File "/home/claire/anaconda2/lib/python2.7/site-packages/librosa/core/audio.py", line 109, in load
    with audioread.audio_open(os.path.realpath(path)) as input_file:
  File "/home/claire/anaconda2/lib/python2.7/site-packages/audioread/__init__.py", line 114, in audio_open
    raise NoBackendError()
audioread.NoBackendError

Thanks again

PS. I heard of Markdown recently and begin to use it but what do you mean with it now? Formatting in markdown to post on Git? Sorry that I don't understand. Edit : Ok got it :)

keunwoochoi commented 7 years ago

:) Yep. Now I see audioread.NoBackendError(). It's an error from librosa (which uses audioread to decode audio signals) and nothing about keras or stft layer. It's strange though, those files are standard mp3 format and I assumes it should be able to open it in any OS.

keunwoochoi commented 7 years ago

Oh, I didnt make it for Tensorflow. Can you try it with Theano? It's actually not a big problem, I'll try to fix it for TF soon.

On 23 Oct 2016, at 09:57, pianomanu notifications@github.com wrote:

Hi Keunwoochoi,

When I run the example_stft.py , I get this error message :

Using TensorFlow backend. Traceback (most recent call last): File "example_stft.py", line 8, in specgram = stft.Spectrogram(n_dft=512, input_shape=(len_src, 1), n_hop=256) File "/home/claire/Bureau/All/Stage2016/Codes/keras_STFT_layer-master/stft.py", line 220, in Spectrogram logamplitude=logamplitude) File "/home/claire/Bureau/All/Stage2016/Codes/keras_STFT_layer-master/stft.py", line 176, in get_spectrogram_tensors STFT_magnitude = Logam_layer()(STFT_magnitude) File "/home/claire/anaconda2/lib/python2.7/site-packages/keras/engine/topology.py", line 514, in call self.add_inbound_node(inbound_layers, node_indices, tensor_indices) File "/home/claire/anaconda2/lib/python2.7/site-packages/keras/engine/topology.py", line 572, in add_inbound_node Node.create_node(self, inbound_layers, node_indices, tensor_indices) File "/home/claire/anaconda2/lib/python2.7/site-packages/keras/engine/topology.py", line 149, in create_node output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0])) File "/home/claire/anaconda2/lib/python2.7/site-packages/keras/layers/core.py", line 556, in call return self.function(x, *arguments) File "/home/claire/Bureau/All/Stage2016/Codes/keras_STFT_layer-master/stft.py", line 89, in return Lambda(lambda x: logam(x), name=name, File "/home/claire/Bureau/All/Stage2016/Codes/keras_STFT_layer-master/stft.py", line 79, in logam log_spec = 10K.log(K.maximum(x, 1e-10))/K.log(10) File "/home/claire/anaconda2/lib/python2.7/site-packages/keras/backend/tensorflow_backend.py", line 566, in log return tf.log(x) File "/home/claire/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/gen_math_ops.py", line 1094, in log result = _op_def_lib.apply_op("Log", x=x, name=name) File "/home/claire/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/op_def_library.py", line 530, in apply_op _Attr(op_def, input_arg.type_attr)) File "/home/claire/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/op_def_library.py", line 61, in _SatisfiesTypeConstraint ", ".join(dtypes.as_dtype(x).name for x in allowed_list))) TypeError: DataType int32 for attr 'T' not in list of allowed values: float16, float32, float64, complex64, complex128

I'm sorry it's a bit long but I don't understand where it comes from.

And also when I'm running the example_melgram.py, I have this error :

Traceback (most recent call last): File "example_melgram.py", line 8, in melgram = melgram.Melspectrogram(n_dft=512, n_hop=256, input_shape=(len_src, 1), sr=12000) TypeError: Melspectrogram() takes at least 3 arguments (4 given)

Could you help me please, Thank you in advance!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

mpariente commented 7 years ago

Thanks again for the answer.

I found a way so that example_stft.py works. I installed ffmpeg with these commands

sudo add-apt-repository ppa:mc3man/trusty-media
sudo apt-get update
sudo apt-get install ffmpeg 

Then example_stft.py works (still not with tensorflow) but example_melgram.py still doesn't work and I have this error message :

Traceback (most recent call last):
  File "example_melgram.py", line 8, in <module>
    melgram = melgram.Melspectrogram(n_dft=512, n_hop=256, input_shape=(len_src, 1), sr=12000)
TypeError: Melspectrogram() takes at least 3 arguments (4 given)

I thank you in advance for your help,

keunwoochoi commented 7 years ago

Nice, so does it now work with both Theano and Tensorflow?

On 25 Oct 2016, at 15:30, pianomanu notifications@github.com wrote:

Thanks again for the answer.

I found a way so that example_stft.py works. I installed ffmpeg with these commands

sudo add-apt-repository ppa:mc3man/trusty-media sudo apt-get update sudo apt-get install ffmpeg```

Then example_stft.py works (still not with tensorflow) but example_melgram.py still doesn't work and I have this error message : Traceback (most recent call last): File "example_melgram.py", line 8, in <module> melgram = melgram.Melspectrogram(n_dft=512, n_hop=256, input_shape=(len_src, 1), sr=12000) TypeError: Melspectrogram() takes at least 3 arguments (4 given)

I thank you in advance for your help, — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

mpariente commented 7 years ago

No, It doesn't work with Tensorflow.

Also, do you have an idea why I get this error message for example_melgram.py??

keunwoochoi commented 7 years ago

Sorry, I missed you already mentioned that. Thanks for reporting! I just updated example code, please pull the repo, and run the example codes and ipython notebooks.