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

corrected STFT

parent 7bb76560
No related branches found
No related tags found
No related merge requests found
......@@ -100,13 +100,13 @@ def create_spectrogram(sig, directory, names, cmap, minimum, window_size=1024, o
:param overlap (float): Ratio of overlapping samples between each window (default 50%).
"""
if overlap >= 1:
hop = window - overlap
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 = window_size * overlap
hop = window_size * (1-overlap) # As hop length is the number of audio samples between adjacent STFT columns
stft = librosa.stft(sig, n_fft=int(window_size),
hop_length=int(overlap_size), window='hann') # Compute the STFT
hop_length=int(hop), window='hann') # Compute the STFT
stft = np.log10(np.abs(stft)) # Adapt the Complex-valued matrix
fig = plt.figure()
if minimum == 'True':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment