You can see the plot looks a bit more populated, but still not even close to the other ones.Ĭonsidering the idea given in the first comment of this question, I used a manipulated version of the gray colormap to have black as the first entry (as normal) but with the second entry being the color that's normally halfway, and then 2,999 colors from there up to white. PLOTTED THE SPECTROGRAM WITHOUT SPECIFYING A COLORMAP I'm pretty sure there is something I can do, but I think I still don't know scipy enough to know what it is. I'd like it to look more like those above it, because I know they're much more accurate, but I don't really know how I can do it, and this one won't work at all. However, this spectrogram also shows the moment of complete silence accurately, and it is at least properly "populated" in the rest of it.īy seeing the third figure (the one I generated with scipy), one could easily think there are several parts of complete silence in those first 70 seconds, which is far from true. I'm pretty sure that, unfortunately, I can't change this view range. In the second figure, there is no y-axis mark, but I can see it has a bigger range than the 5 KHz, which I think accounts for the difference with the first figure. The accuracy of this becomes obvious when listening to the file. Also, the only moment in that 70-second span with complete silence is around the 35-second mark. I also tinkered with the figure size and the resolution, but it didn't really help either.Īs you can see in the first figure, the y-axis goes from 0 to 5 KHz, and many frequencies have some intensity at that level. This is not applied here in the figure I'm showing you, because I realized it's far from helping. I even tried to create the spectrogram with the same slice of the samples array, but by taking only every tenth value, then every twentieth, and so on, but this only made the spectrogram have horizontal lines instead of dots. Then, to get a better zoom, I created a spectrogram with only the first 700,000 elements of the samples array (see code), which, in the case of this file, represent about 70 seconds. I though I could live with some frequencies neglected given that I care, most of all, about speech frequencies. mp4 file, I set the sampling rate to 10 KHz to avoid having such a big y-axis in the plot and see if this helps. To create this spectrogram, trying to see if it was a figure-size/resolution issue, I tried a couple of things things, one by one, and the end result is this image (with both of them applied).įirst, when extracting the. The following images are spectrograms from Audacity and Aegisub, respectively, both for the same file for which the third image's spectrogram was created (with scipy). Plt.pcolormesh(times, frequencies, spectrogram, cmap=cMap) Sample_rate, samples = wavfile.read('audio-mono.wav')įrequencies, times, spectrogram = signal.spectrogram(samples, sample_rate)ĬMap = cm.get_cmap('gray', 3000) # Maybe I'm not understanding this very wellįig = plt.figure(figsize=(4,2), dpi=400, frameon=False) This is the code I used for the particular image I'm showing here: import matplotlib.pyplot as plt However, the spectrograms I'm getting don't look very "populated," and not at all like other spectrograms I get from other software. I need to generate spectrograms for audio files with Python and I'm following the solution given here.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |