@@ -342,10 +342,12 @@ def compute_f0(self, audio, lvl):
342342 if lvl [0 , c ] < self .f0_lvl_threshold :
343343 continue
344344
345+ audio_tmp = np .concatenate (
346+ (audio [:, c ][::- 1 ], audio [:, c ], audio [:, c ][::- 1 ])
347+ )
345348 if self .f0_algorithm == "YIN" :
346- # TODO: replace with real-time version, add real-time SWIPE, relax min/max limits
347349 f0_tmp , _ , conf_tmp = libf0 .yin (
348- np . concatenate (( audio [:, c ][:: - 1 ], audio [:, c ], audio [:, c ][:: - 1 ])) ,
350+ audio_tmp ,
349351 Fs = self .fs ,
350352 N = self .fft_len ,
351353 H = self .fft_len ,
@@ -356,7 +358,13 @@ def compute_f0(self, audio, lvl):
356358 )
357359 f0 [:, c ] = np .mean (f0_tmp ) # take the center frame
358360 conf [:, c ] = 1 - np .mean (conf_tmp )
359-
361+ elif self .f0_algorithm == "SWIPE" :
362+ # TODO: replace with real-time version when available
363+ f0_tmp , _ , conf_tmp = libf0 .swipe (
364+ audio [:, c ], Fs = self .fs , H = self .fft_len , F_min = 80.0 , F_max = 640.0
365+ )
366+ f0 [:, c ] = np .mean (f0_tmp )
367+ conf [:, c ] = 1 - np .mean (conf_tmp )
360368 else :
361369 f0 [:, c ] = np .zeros (f0 .shape [0 ])
362370 conf [:, c ] = np .zeros (f0 .shape [0 ])
0 commit comments