diff --git a/utils.py b/utils.py index 14839f1baeb7951192c37e8493a8a1782da94db3..522a15c40f8813ee535989afc62da47723f4ec81 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':