Closed mv00147 closed 6 years ago
@mv00147 , I edited your comment for markdown formatting, it will makes everyone happy!
A common way is to convert it to melspectrogram. See my audio processing code, except I made a mistake of applying **2
on the top of power-melspectrogram, which is already squared representation of time-freq representation. Then make each sample a 3-d representation - height, width, and channel, where num_channel will be 1 if you're using mono signal.
@mv00147 In my "build_datasets()" method in my training script, I do like @keunwoochoi suggested and make mel-spectrograms:
aud, sr = librosa.load(audio_path, sr=None)
melgram = librosa.logamplitude(librosa.feature.melspectrogram(aud, sr=sr, n_mels=96),ref_power=1.0)[np.newaxis,np.newaxis,:,:]
This melgram is basically a 2-d image. Then you can add it to the list of training data you're setting up in your "X" array:
X_train[train_count,:,:] = melgram
where train_count is just an increment each time you load a new audio file.
Does that help?
(hopefully it did!)
Dear Scott, I wish to train the CNN presented by Keunwoochoi with my dataset which is available in the path_1 specified in this code. They are .wav files. How do I represent it in a suitable format so it can be input to the network for training? This is my code. Unfortunately most tutorials on the web only explain training CNN on image data and not audio.