import os
import scipy.io
import scipy.io.wavfile
import numpy as np
import matplotlib.pyplot as plt
from scipy import signal
from scipy.signal import spectrogram, get_window
dataset_path = os.path.join(os.environ['HOME'], 'shared', 'data', 'assignment_1')
wavedata = os.path.join(dataset_path, 'example.wav')
fs, audio_buffer = scipy.io.wavfile.read(wavedata)
a = np.array(audio_buffer)
window = get_window('hann', frame_size) # we will us a Hann window for the DFTs
freqs, times, spec = scipy.signal.spectrogram(audio_buffer, fs, window='hann')
plt.pcolormesh(times, freqs, spec)
np.log(spec)
plt.ylabel('Frequency [Hz]')
plt.xlabel('Time [sec]')
plt.show()
I tried to make a spectrogram. The problem is that it is almost completely violet. How can I fix this?