kapre icon indicating copy to clipboard operation
kapre copied to clipboard

ImportError: cannot import name 'Melspectrogram'

Open ghassan100 opened this issue 3 years ago • 3 comments

from kapre.time_frequency import Melspectrogram, Spectrogram

ghassan100 avatar Feb 21 '21 22:02 ghassan100

I believe this API is a deprecated, you will want to use ApplyFilterbank instead, from the docstring:

input_shape = (2048, 1)  # mono signal
n_fft = 1024
n_hop = n_fft // 2
kwargs = {
    'sample_rate': 22050,
    'n_freq': n_fft // 2 + 1,
    'n_mels': 128,
    'f_min': 0.0,
    'f_max': 8000,
}
model = Sequential()
model.add(kapre.STFT(n_fft=n_fft, hop_length=n_hop, input_shape=input_shape))
model.add(Magnitude())
# (batch, n_frame=3, n_freq=n_fft // 2 + 1, ch=1) and dtype is float
model.add(ApplyFilterbank(type='mel', filterbank_kwargs=kwargs))
# (batch, n_frame=3, n_mels=128, ch=1)

kenders2000 avatar Feb 22 '21 11:02 kenders2000

Is the following layer is the replacement? composed_melgram_layer = kapre.composed.get_melspectrogram_layer(input_shape=(44100, 1))

I am also looking for a compatible replacement for the Melspectrogram layer.

Any information is appreciated.

bagustris avatar Aug 05 '21 10:08 bagustris

Yes, you’re right.

On Aug 5, 2021, at 06:23, Bagus Tris Atmaja @.***> wrote:

 Is that tthe following layer is the replacement? composed_melgram_layer = kapre.composed.get_melspectrogram_layer(input_shape=(44100, 1))

I am also looking for a compatible replacement for the Melspectrogram layer.

Any information is appreciated.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

keunwoochoi avatar Aug 05 '21 12:08 keunwoochoi