keunwoochoi / kapre

kapre: Keras Audio Preprocessors
MIT License
920 stars 146 forks source link

ImportError: cannot import name 'Melspectrogram' #119

Open ghassan100 opened 3 years ago

ghassan100 commented 3 years ago

from kapre.time_frequency import Melspectrogram, Spectrogram

kenders2000 commented 3 years ago

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)
bagustris commented 3 years ago

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.

keunwoochoi commented 3 years ago

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.