<p>To add to what has been stated, I recommend reading through <a href="https://arxiv.org/abs/1709.01922" rel="nofollow noreferrer">A Comparison of Audio Signal Preprocessing Methods for Deep Neural Networks on Music Tagging</a> by Keunwoo Choi, György Fazekas, Kyunghyun Cho, and Mark Sandler. </p>

<p>For their data, they achieved nearly identical classification accuracy between simple STFTs and melspectrograms. So melspectrograms seem to be the clear winner for dimension reduction if you don't mind the preprocessing. The authors also found, as jonner mentions, that log-scaling (essentially converting amplitude to a db scale) improves accuracy. You can easily do this with Librosa (using your code) like this:</p>

<pre><code>y,sr= librosa.core.load(r'C:\Users\Tej\Desktop\NoiseWork\NoiseOnly\song.wav')
S = librosa.feature.melspectrogram(y=y, sr=sr)
S_db = librosa.core.power_to_db(S)
</code></pre>

<p>As for normalization after db-scaling, that seems hit or miss depending on your data. From the paper above, the authors found nearly no difference using various normalization techniques for their data.</p>

<p>One last thing that should be mentioned is a somewhat new method called Per-Channel Energy Normalization. I recommend reading <a href="http://www.justinsalamon.com/uploads/4/3/9/4/4394963/lostanlen_pcen_spl2018.pdf" rel="nofollow noreferrer">Per-Channel Energy Normalization: Why and How</a> by Vincent Lostanlen, Justin Salamon, Mark Cartwright, Brian McFee,
Andrew Farnsworth, Steve Kelling, and Juan Pablo Bello. Unfortunately, there are some parameters that need adjusting depending on the data, but in many cases seems to do as well as or better than logmelspectrograms. You can implement it in Librosa like this:</p>

<pre><code>y,sr= librosa.core.load(r'C:\Users\Tej\Desktop\NoiseWork\NoiseOnly\song.wav')
S = librosa.feature.melspectrogram(y=y, sr=sr)
S_pcen = librosa.pcen(S)
</code></pre>

<p>Although, like I mentioned, there are parameters within pcen that need adjusting! Here is <a href="https://librosa.github.io/librosa/generated/librosa.core.pcen.html" rel="nofollow noreferrer">Librosa's documentation on PCEN</a> to get you started if you are interested.</p>
Which Spectrogram best represents features of an audio file for CNN based model?
<p>I am looking to understand various spectrograms for audio analysis. I want to convert an audio file into 10 second chunks, generate spectrograms for each and use a CNN model to train on top of those images to see if they are good or bad. </p>

<p>I have looked at linear, log, mel, etc and read somewhere that mel based spectrogram is best to be used for this. But with no proper verifiable information. I have used the simple following code to generate mel spectrogram. </p>

<pre><code>y,sr= librosa.core.load(r'C:\Users\Tej\Desktop\NoiseWork\NoiseOnly\song.wav')
S = librosa.feature.melspectrogram(y=y, sr=sr)
librosa.display.specshow(librosa.power_to_db(S, ref=np.max))
</code></pre>

<p>My question is which spectrogram best represents features of an audio file for training with CNN? I have used linear but some audio files the linear spectrogram seems to be the same</p>