@@ -280,7 +280,7 @@ def load_stft(
280280 stft_db = 10 * np .log10 (abs_sq_stft / abs_sq_stft .max () + 1e-20 )
281281 # Retrieve time vector in seconds corresponding to STFT
282282 time_vec = librosa .frames_to_time (
283- range (stft_db .shape [1 ]), sr = sr , hop_length = hop_length , n_fft = n_fft
283+ range (stft_db .shape [1 ]), sr = sr , hop_length = hop_length , n_fft = win_length
284284 )
285285
286286 # Remove frequencies that we do not need [FREQ_MIN - FREQ_MAX]
@@ -1113,10 +1113,11 @@ def extract_contour_keypoints(
11131113 'slope/hi[avg].y_px/x_px' : float (np .mean (der1 [: knee_idx + 1 ])),
11141114 'slope/mid[avg].y_px/x_px' : float (np .mean (der1 [knee_idx : heel_idx + 1 ])),
11151115 'slope/lo[avg].y_px/x_px' : float (np .mean (der1 [heel_idx :])),
1116- 'slope[box].y_px/x_px' : float (0.5 * (der1 [0 ] + der1 [- 1 ])),
1117- 'slope/hi[box].y_px/x_px' : float (0.5 * (der1 [0 ] + der1 [knee_idx ])),
1118- 'slope/mid[box].y_px/x_px' : float (0.5 * (der1 [knee_idx ] + der1 [heel_idx ])),
1119- 'slope/lo[box].y_px/x_px' : float (0.5 * (der1 [heel_idx ] + der1 [- 1 ])),
1116+ 'slope[box].y_px/x_px' : - float ((y_ [- 1 ] - y_ [0 ]) / (x_ [- 1 ] - x_ [0 ] + 1e-10 )),
1117+ 'slope/hi[box].y_px/x_px' : - float ((y_ [fc_idx ] - y_ [0 ]) / (x_ [fc_idx ] - x_ [0 ] + 1e-10 )),
1118+ 'slope/lo[box].y_px/x_px' : - float (
1119+ (y_ [- 1 ] - y_ [fc_idx ]) / (x_ [- 1 ] - x_ [fc_idx ] + 1e-10 )
1120+ ),
11201121 }
11211122
11221123 return path_ , points , slopes
@@ -1405,6 +1406,7 @@ def compute_wrapper(
14051406 annotations = None ,
14061407 bitdepth = 16 ,
14071408 mask_secondary_effects = False ,
1409+ plot_uncompressed_amplitude = False ,
14081410 debug = False ,
14091411 ** kwargs ,
14101412):
@@ -1839,16 +1841,24 @@ def compute_wrapper(
18391841 compressed_paths = []
18401842 mask_paths = []
18411843 masked_paths = []
1844+ waveplot_compressed_paths = []
1845+ waveplot_plots = []
18421846 if not fast_mode :
18431847 datas = [
18441848 (output_paths , 'jpg' , stft_db ),
18451849 ]
1846- else :
1847- datas = []
1850+ if plot_uncompressed_amplitude :
1851+ datas += [
1852+ (waveplot_plots , 'waveplot.jpg' , waveplot ),
1853+ ]
18481854 if 'stft_db' in segments :
18491855 datas += [
18501856 (compressed_paths , 'compressed.jpg' , segments ['stft_db' ]),
18511857 ]
1858+ if 'waveplot' in segments :
1859+ datas += [
1860+ (waveplot_compressed_paths , 'compressed.waveplot.jpg' , segments ['waveplot' ]),
1861+ ]
18521862
18531863 # Create masked image
18541864 if 'costs' in segments and 'stft_db' in segments :
@@ -1887,6 +1897,8 @@ def compute_wrapper(
18871897 'spectrogram' : {
18881898 'uncompressed.path' : output_paths ,
18891899 'compressed.path' : compressed_paths ,
1900+ 'waveplot.path' : waveplot_plots ,
1901+ 'waveplot.compressed.path' : waveplot_compressed_paths ,
18901902 'mask.path' : mask_paths ,
18911903 'masked.path' : masked_paths ,
18921904 },
0 commit comments