1
$\begingroup$

I am new to signal preprocessing, I read about mel_spectrograms, MFCC's. Now I want to apply it and use the CNN model, But the data which I have for practice is having audio of different durations, now because of this, the mel_spectrograms will be of different shapes. for using them as inputs, the model requires inputs to have a fixed shape. So, what should I do to make them have a specific shape??

$\endgroup$
2
  • 1
    $\begingroup$ Could you address the problem on the model side instead? $\endgroup$ – Olli Niemitalo Nov 4 '20 at 15:47
  • 1
    $\begingroup$ The model which I want to use is CNN, so in the end, we use dense layers that required fixed input shape, for images we resize with cropping or padding. for audio data what we have to do to make the input to have a fixed shape? $\endgroup$ – Ravi Teja Nov 5 '20 at 4:57
0
$\begingroup$

In this case, usually, Normalization is done. For example in your training and testing data, you need the same shape, so that you should try something like,

mean = np.mean(X_train_features, axis=0)
std = np.std(X_train_features, axis=0)
X_train_features = (X_train_features - mean)/std

Here X_train_features can be a data frame of spectrogram or mfcc features.

The same thing you can apply for testing features. One thing to remember is the number of columns in shape of training and testing should be the same.

You can also check some Kaggle kernels which are related to Audio processing.

$\endgroup$
1
  • $\begingroup$ I believe the question is not about the dynamic range of the features but about the length of the feature vectors. I think the question is how to handle different feature vector lengths and not how to normalise their values. In this case, I believe it is more appropriate to either zero-pad the shorter vectors (could also do some phase preservation zero-padding), cut the long ones to the duration of the shortest or resample the audio or the feature vectors (for example with an interpolation function). $\endgroup$ – ZaellixA Nov 19 '20 at 22:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.