Skip to content
Snippets Groups Projects
Commit e81e4b3b authored by Stephane Chavin's avatar Stephane Chavin
Browse files

debug utils

parent 7241b044
No related branches found
No related tags found
No related merge requests found
......@@ -87,7 +87,7 @@ def signal_processing(sig, rf, fs, high=None, low=None):
return sig
def create_spectrogram(sig, directory, names, window_size=1024, overlap=.5):
def create_spectrogram(sig, directory, names, cmap, window_size=1024, overlap=.5,):
"""
Create a spectrogram STFT with hanning window and save it into a directory
......@@ -101,15 +101,15 @@ def create_spectrogram(sig, directory, names, window_size=1024, overlap=.5):
print(f'You put a hop value over 1. This has been corrected to have {overlap} as overlap size between window')
overlap_size = overlap
else:
overlap_size = int(window_size * overlap)
overlap_size = window_size * overlap
stft = librosa.stft(sig, n_fft=window_size,
hop_length=overlap_size, window='hann') # Compute the STFT
stft = librosa.stft(sig, n_fft=int(window_size),
hop_length=int(overlap_size), window='hann') # Compute the STFT
stft = np.log10(np.abs(stft)) # Adapt the Complex-valued matrix
fig = plt.figure()
# plot the spectrogram
plt.imshow(stft[::-1], aspect='auto',
interpolation=None, cmap='viridis', vmin=stft.mean())
interpolation=None, cmap=cmap, vmin=stft.mean())
# Remove all the borders around the plot
plt.subplots_adjust(top=1, bottom=0, left=0, right=1)
if names:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment