From 60596aa9588b88049b7d4e8199211db6d521c1e5 Mon Sep 17 00:00:00 2001 From: Stephane Chavin <stephane.chavin@lis-lab.fr> Date: Tue, 29 Oct 2024 09:14:24 +0100 Subject: [PATCH] corrected STFT --- utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utils.py b/utils.py index 14839f1..522a15c 100755 --- a/utils.py +++ b/utils.py @@ -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': -- GitLab